Created
September 28, 2021 16:46
-
-
Save jostmart/f8e8d72843894f165f3eb1f7b4d54c12 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ansible-playbook | |
- name: Docker cluster wide tasks | |
hosts: docker | |
become: yes | |
handlers: | |
# reload config | |
- name: reload alertmanager1 configuration | |
uri: | |
url: "{{ alertmanager1_reload_url }}" | |
method: POST | |
- name: reload alertmanager2 configuration | |
uri: | |
url: "{{ alertmanager2_reload_url }}" | |
method: POST | |
- name: reload alertmanager3 configuration | |
uri: | |
url: "{{ alertmanager3_reload_url }}" | |
method: POST | |
tasks: | |
- name: create a network for the monitoring | |
docker_network: | |
name: prometheus_timescale_network | |
driver: overlay | |
- name: Create Alertmanager folder | |
file: | |
path: /srv/alertmanager | |
state: directory | |
owner: nobody | |
group: nogroup | |
mode: 0775 | |
- name: Create Alertmanager etc folder | |
file: | |
path: /srv/alertmanager/etc | |
state: directory | |
owner: nobody | |
group: nogroup | |
mode: 0775 | |
- name: Deploy alertmanager configuration | |
template: | |
src: "{{ alertmanager_config_template }}" | |
dest: /srv/alertmanager/etc/alertmanager.yml | |
owner: root | |
mode: 0664 | |
notify: | |
- reload alertmanager1 configuration | |
- reload alertmanager2 configuration | |
- reload alertmanager3 configuration | |
- name: alertmanager on docker_swarm_initial_master | |
run_once: True | |
delegate_to: "{{ docker_swarm_initial_master }}" # could be any node | |
docker_swarm_service: | |
name: "{{ item.name }}" | |
image: "{{ item.image }}" | |
replicas: "{{ item.replicas }}" | |
placement: "{{ item.placement }}" | |
command: "{{ item.command }}" | |
networks: "{{ item.networks }}" | |
publish: "{{ item.publish }}" | |
mounts: "{{ item.mounts }}" | |
with_items: | |
- "{{ docker_swarm_service_alertmanager }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment