From f8767026a9b574e33f404dc145f5fd1e8217ed7b Mon Sep 17 00:00:00 2001 From: Sheppy Date: Thu, 5 Jan 2023 17:09:45 +0100 Subject: [PATCH] wip: async icinga & docker compose --- .gitignore | 1 + playbook.yaml | 4 ++ roles/docker-deployments/tasks/main.yaml | 66 ++++++++++++++----- .../templates/async-icinga-config.json.j2 | 10 +++ .../templates/async-icinga.yaml | 6 ++ 5 files changed, 72 insertions(+), 15 deletions(-) create mode 100644 roles/docker-deployments/templates/async-icinga-config.json.j2 create mode 100644 roles/docker-deployments/templates/async-icinga.yaml diff --git a/.gitignore b/.gitignore index d93e57c..746a233 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ ansible.log files/icinga_master_hosts.conf files/nsca_server.conf +files/async-icinga-config-dynamic.json hosts.ini diff --git a/playbook.yaml b/playbook.yaml index a89febe..65525de 100644 --- a/playbook.yaml +++ b/playbook.yaml @@ -7,6 +7,10 @@ - { role : monitoring-influx, tags : [ "influx" ] } - { role : base, tags : [ "base" ] } +- hosts: kube1 + roles: + - { role : docker-deployments,tags : [ "docker", "kube1" ] } + - hosts: monitoring roles: - { role : monitoring-master, tags : [ "monitoring-master", "icinga", "grafana" ] } diff --git a/roles/docker-deployments/tasks/main.yaml b/roles/docker-deployments/tasks/main.yaml index 0cf2b68..33bf69f 100644 --- a/roles/docker-deployments/tasks/main.yaml +++ b/roles/docker-deployments/tasks/main.yaml @@ -1,25 +1,61 @@ +- name: Create data-dir + file: + name: /data/ + state: directory + - name: Create opt-dir file: name: /opt/ state: directory -- name: Copy compose templates +- name: Async Icinga mount directory + file: + name: /data/async-icinga + state: directory + +- name: Async Icinga Service (static) template: - src: {{ item }} - dest: /opt/ + src: async-icinga-config.json.j2 + dest: /data/async-icinga/ + +- name: Async Icinga Service (dynamic from backup file) + copy: + src: async-icinga-config-dynamic.json + dest: /data/async-icinga/ + +- name: Create compose directories + file: + name: "/opt/{{ item }}" + state: directory with_items: - - athq-landing.yaml - - grafana.yaml - - potaris-en.yaml - - potaris.yaml - - sector32.yaml + - athq-landing + - grafana + - potaris-en + - potaris + - sector32 + - async-icinga - name: Copy compose templates - compose: - TODO + template: + src: "{{ item }}.yaml" + dest: "/opt/{{ item }}/" with_items: - - athq-landing.yaml - - grafana.yaml - - potaris-en.yaml - - potaris.yaml - - sector32.yaml + - athq-landing + - grafana + - potaris-en + - potaris + - sector32 + - async-icinga + +- name: Deploy compose templates + community.docker.docker_compose: + project_src: "/opt/{{ item }}/" + files: + - "{{ item }}.yaml" + with_items: + - athq-landing + - grafana + - potaris-en + - potaris + - sector32 + - async-icinga diff --git a/roles/docker-deployments/templates/async-icinga-config.json.j2 b/roles/docker-deployments/templates/async-icinga-config.json.j2 new file mode 100644 index 0000000..37d6ef5 --- /dev/null +++ b/roles/docker-deployments/templates/async-icinga-config.json.j2 @@ -0,0 +1,10 @@ +[ +{% for service in async_icinga_static_services %} + { + "{{ service['name'] }}" : { + "timeout" : "{{ service['timeout'] }}", + "token" : "{{ service['token'] }}" + } + }{% if not loop.last %},{% endif %} +{% endfor %} +] diff --git a/roles/docker-deployments/templates/async-icinga.yaml b/roles/docker-deployments/templates/async-icinga.yaml new file mode 100644 index 0000000..e0679b4 --- /dev/null +++ b/roles/docker-deployments/templates/async-icinga.yaml @@ -0,0 +1,6 @@ +async-icinga: + volumes: + - "/app/config/:/data/async-icinga/" + ports: + - 5001:5000 + image: registry.atlantishq.de/athq/async-icinga