From e29fd1c5d5ec995040175e7707737ae50ddc1ba5 Mon Sep 17 00:00:00 2001 From: Julian Labus Date: Fri, 15 Feb 2019 11:39:48 +0100 Subject: [PATCH] Roles: add service-cpthook --- roles/service-cpthook/README.md | 16 ++++++++++++++ roles/service-cpthook/handlers/main.yml | 9 ++++++++ roles/service-cpthook/meta/main.yml | 3 +++ roles/service-cpthook/tasks/main.yml | 22 +++++++++++++++++++ .../templates/cpthook.service.j2 | 18 +++++++++++++++ .../service-cpthook/templates/cpthook.yml.j2 | 18 +++++++++++++++ roles/service-cpthook/vars/main.yml | 4 ++++ 7 files changed, 90 insertions(+) create mode 100644 roles/service-cpthook/README.md create mode 100644 roles/service-cpthook/handlers/main.yml create mode 100644 roles/service-cpthook/meta/main.yml create mode 100644 roles/service-cpthook/tasks/main.yml create mode 100644 roles/service-cpthook/templates/cpthook.service.j2 create mode 100644 roles/service-cpthook/templates/cpthook.yml.j2 create mode 100644 roles/service-cpthook/vars/main.yml diff --git a/roles/service-cpthook/README.md b/roles/service-cpthook/README.md new file mode 100644 index 0000000..51395b2 --- /dev/null +++ b/roles/service-cpthook/README.md @@ -0,0 +1,16 @@ +# Ansible role service-cpthook + +Diese Ansible role installiert CptHook. + +- schreibt cpthook.yml +- schreibt cpthook.service +- kompiliert und installiert CptHook +- aktiviert die systemd unit `cpthook.service` + +# Benötigte Variablen + +- Variable `gopath` + +- Variable `cpthook_path` (Rollen-Variable) +- Variable `cpthook_config` (Rollen-Variable) +- Variable `cpthook_src` (Rollen-Variable) diff --git a/roles/service-cpthook/handlers/main.yml b/roles/service-cpthook/handlers/main.yml new file mode 100644 index 0000000..4afefa9 --- /dev/null +++ b/roles/service-cpthook/handlers/main.yml @@ -0,0 +1,9 @@ +--- +- name: reload systemd + systemd: + daemon_reload: yes + +- name: restart cpthook + systemd: + name: cpthook + state: restarted diff --git a/roles/service-cpthook/meta/main.yml b/roles/service-cpthook/meta/main.yml new file mode 100644 index 0000000..5ede082 --- /dev/null +++ b/roles/service-cpthook/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - { role: golang } diff --git a/roles/service-cpthook/tasks/main.yml b/roles/service-cpthook/tasks/main.yml new file mode 100644 index 0000000..e9f229f --- /dev/null +++ b/roles/service-cpthook/tasks/main.yml @@ -0,0 +1,22 @@ +--- +- name: write cpthook config + template: + src: "cpthook.yml.j2" + dest: "{{ cpthook_config }}" + notify: restart cpthook + +- name: create systemd unit for cpthook + template: + src: "cpthook.service.j2" + dest: "/etc/systemd/system/cpthook.service" + notify: reload systemd + +- name: build cpthook binary + shell: 'GOPATH={{ gopath }} go get -u {{ cpthook_src }}' + notify: restart cpthook + +- name: configure cpthook systemd unit + systemd: + name: "cpthook.service" + enabled: yes + state: started diff --git a/roles/service-cpthook/templates/cpthook.service.j2 b/roles/service-cpthook/templates/cpthook.service.j2 new file mode 100644 index 0000000..747205b --- /dev/null +++ b/roles/service-cpthook/templates/cpthook.service.j2 @@ -0,0 +1,18 @@ +[Unit] +Description=CptHook Webhook Gateway +Documentation=https://{{ cpthook_src }} +Wants=network-online.target +After=network-online.target + +[Service] +Type=simple + +User=nobody +Group=nogroup + +ExecStart={{ cpthook_path }} +Restart=always +RestartSec=5s + +[Install] +WantedBy=multi-user.target diff --git a/roles/service-cpthook/templates/cpthook.yml.j2 b/roles/service-cpthook/templates/cpthook.yml.j2 new file mode 100644 index 0000000..0a2e1d8 --- /dev/null +++ b/roles/service-cpthook/templates/cpthook.yml.j2 @@ -0,0 +1,18 @@ +# +# {{ ansible_managed }} +# + +http: + listen: "127.0.0.1:8084" + +irc: + host: "irc.hackint.eu" + port: 6697 + ssl: + enabled: true + nickname: "ffmwu-prom" + +modules: + prometheus: + enabled: true + channel: "#ffmwu-feed" diff --git a/roles/service-cpthook/vars/main.yml b/roles/service-cpthook/vars/main.yml new file mode 100644 index 0000000..f20b1ea --- /dev/null +++ b/roles/service-cpthook/vars/main.yml @@ -0,0 +1,4 @@ +--- +cpthook_path: "{{ gopath }}/bin/CptHook" +cpthook_config: "/etc/cpthook.yml" +cpthook_src: "github.com/fleaz/CptHook"