ansible/swarm/local-proxy-prom-elk.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-with-prom-elk/traefik.yml traefik
<<EOF
EOF
register: stdout
tags: deploy_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-with-prom-elk/portainer.yml portainer
<<EOF
EOF
register: stdout
tags: deploy_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-with-prom-elk/swarmprom.yml prom
<<EOF
EOF
register: stdout
tags: deploy_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 elk 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-with-prom-elk/elk.yml elk
<<EOF
EOF
register: stdout
tags: deploy_elk
- name: debug output
debug: msg={{ stdout }}