ansible/swarm/local-proxy-prom-icinga2.yml
# Author Alain Ivars - All right reserved 2019
---
# - name: Create the Machines
# hosts: 127.0.0.1
# connection: local
# any_errors_fatal: True
# tasks:
# - name: Create the Machines task
# shell: >
# {{ playbook_dir }}/../../utils2devops/bin/docker-machine-cluster.sh -c 5
# register: stdout
# - name: debug output
# debug: msg={{ stdout }}
#
# - name: Enable monitoring (optional)
# hosts: 127.0.0.1
# connection: local
# any_errors_fatal: True
# tasks:
# - name: Enable monitoring task
# shell: >
# {{ playbook_dir }}/../../utils2devops/bin/enable-monitoring.sh -p {{ playbook_dir }}/../../utils2devops/docker/ -n 5
# register: stdout
# - name: debug output
# debug: msg={{ stdout }}
#
# - name: Create the Docker Swarm
# hosts: 127.0.0.1
# connection: local
# any_errors_fatal: True
# tasks:
# - name: Create the Docker Swarm task
# shell: >
# {{ playbook_dir }}/../../utils2devops/bin/swarm.sh -c -m 3 -w 2
# register: stdout
# - name: debug output
# debug: msg={{ stdout }}
#
- name: Deploy Traefik
hosts: 127.0.0.1
connection: local
any_errors_fatal: True
tasks:
- name: Deploy Traefik stack task
shell:
cmd: |
export DOMAIN=example.com
export TRAEFIK_PUBLIC_TAG=my-traefik-public
eval "$(docker-machine env node-1)"
docker stack deploy -c {{ playbook_dir }}/../../utils2devops/docker/local-proxy-prom-icinga2/traefik.yml traefik
<<EOF
EOF
register: stdout
tags: traefik
- name: debug output
debug: msg={{ stdout }}
- name: sleep for 10 seconds to give the time to the swarm to set everything
wait_for: timeout=10
delegate_to: localhost
- name: Deploy Ops Stacks Graphics UI (optional)
hosts: 127.0.0.1
connection: local
any_errors_fatal: True
tasks:
- name: Deploy portainer stack task
shell:
cmd: |
export DOMAIN=example.com
eval "$(docker-machine env node-1)"
docker stack deploy -c {{ playbook_dir }}/../../utils2devops/docker/local-proxy-prom-icinga2/portainer.yml portainer
<<EOF
EOF
register: stdout
tags: portainer
- name: debug output
debug: msg={{ stdout }}
- name: sleep for 15 seconds to give the time to the swarm to set everything
wait_for: timeout=15
delegate_to: localhost
- name: Deploy Ops Stacks part 1
hosts: 127.0.0.1
connection: local
any_errors_fatal: True
tasks:
- name: Deploy swarmprom stack task
shell:
cmd: |
export HASHED_PASSWORD="\$apr1\$QGOh2jEY\$Y/yn79f/425CRsIFQSeEI/"
export DOMAIN=example.com
export ADMIN_USER=admin
export TRAEFIK_PUBLIC_TAG=traefik-public
export SLACK_URL=${SLACK_HOOK_URL}${SLACK_HOOK_KEY}
export SLACK_CHANNEL=utils2devops-tests
export SLACK_USER=alainivars
eval "$(docker-machine env node-1)"
docker stack deploy -c {{ playbook_dir }}/../../utils2devops/docker/local-proxy-prom-icinga2/swarmprom.yml prom
<<EOF
EOF
register: stdout
tags: swarmprom
- name: debug output
debug: msg={{ stdout }}
- name: sleep for 90 seconds to give the time to the swarm to set everything
wait_for: timeout=90
delegate_to: localhost
- name: Deploy Ops Stacks part 2
hosts: 127.0.0.1
connection: local
any_errors_fatal: True
tasks:
- name: Deploy icinga2 stack task
shell:
cmd: |
export HASHED_PASSWORD="\$apr1\$QGOh2jEY\$Y/yn79f/425CRsIFQSeEI/"
export DOMAIN=example.com
export KIBANA_USER=admin
eval "$(docker-machine env node-1)"
docker stack deploy -c {{ playbook_dir }}/../../utils2devops/docker/local-proxy-prom-icinga2/icinga2.yml icinga
<<EOF
EOF
register: stdout
tags: icinga2
- name: debug output
debug: msg={{ stdout }}