- Add blackbox exporter role and playbooks - Add cadvisor, docker, httpbin roles - Add app3 deployment playbooks - Configure blackbox monitoring
59 lines
1.5 KiB
YAML
59 lines
1.5 KiB
YAML
---
|
|
- name: Create directory for blackbox config
|
|
file:
|
|
path: /etc/blackbox_exporter
|
|
state: directory
|
|
mode: '0755'
|
|
tags: blackbox
|
|
|
|
- name: Copy blackbox configuration
|
|
copy:
|
|
src: files/blackbox.yml
|
|
dest: /etc/blackbox_exporter/config.yml
|
|
mode: '0644'
|
|
tags: blackbox
|
|
|
|
- name: Ensure blackbox-exporter container is running
|
|
community.docker.docker_container:
|
|
name: "{{ blackbox_container_name }}"
|
|
image: "{{ blackbox_image }}"
|
|
state: started
|
|
restart_policy: unless-stopped
|
|
ports:
|
|
- "{{ blackbox_port }}:9115"
|
|
volumes:
|
|
- "/etc/blackbox_exporter/config.yml:/etc/blackbox_exporter/config.yml"
|
|
command:
|
|
- "--config.file=/etc/blackbox_exporter/config.yml"
|
|
- "--web.listen-address=:9115"
|
|
tags: blackbox
|
|
|
|
- name: Configure UFW for blackbox-exporter
|
|
ufw:
|
|
rule: allow
|
|
port: "{{ blackbox_port }}"
|
|
proto: tcp
|
|
comment: "Blackbox Exporter"
|
|
tags: blackbox
|
|
|
|
- name: Wait for blackbox-exporter to be ready
|
|
wait_for:
|
|
port: "{{ blackbox_port }}"
|
|
host: "{{ ansible_host }}"
|
|
delay: 2
|
|
timeout: 60
|
|
tags: blackbox
|
|
|
|
- name: Test blackbox-exporter with local target
|
|
uri:
|
|
url: "http://{{ ansible_host }}:{{ blackbox_port }}/probe?target=http://192.168.0.112:8080/get&module=http_2xx"
|
|
return_content: true
|
|
status_code: 200
|
|
register: blackbox_test
|
|
tags: blackbox
|
|
|
|
- name: Show blackbox-exporter status
|
|
debug:
|
|
msg: "Blackbox Exporter deployed at http://{{ ansible_host }}:{{ blackbox_port }}/"
|
|
tags: blackbox
|