ansible-role-prometheus_nod.../tasks/configure_prometheus_exporters_external.yml

96 lines
2.5 KiB
YAML
Raw Permalink Normal View History

2022-10-11 09:19:07 +02:00
---
- name: Ensure UFW is enabled and accepting HTTPS traffic
ufw:
state: enabled
policy: deny
rule: allow
to_port: '443'
- name: Ensure UFW is enabled and accepting HTTP traffic
ufw:
state: enabled
policy: deny
rule: allow
to_port: '80'
- name: Ensure the document root exists for node exporter
file:
2023-08-23 12:27:16 +02:00
path: "/var/www/node-metrics-{{ inventory_hostname }}.{{ domain }}/"
2022-10-11 09:19:07 +02:00
state: directory
owner: www-data
2023-01-27 23:55:00 +01:00
2022-10-11 09:19:07 +02:00
- name: Ensure the document root exists postfixnode exporter
file:
2023-08-23 12:27:16 +02:00
path: "/var/www/postfix-metrics-{{ inventory_hostname }}.{{ domain }}/"
2022-10-11 09:19:07 +02:00
state: directory
owner: www-data
2023-01-27 23:55:00 +01:00
# Add DNS entries in OVH
- name: Check if certificates exist
stat:
2023-08-23 12:27:16 +02:00
path: "/etc/letsencrypt/live/node-metrics-{{ inventory_hostname }}.{{ domain }}/fullchain.pem"
2023-01-27 23:55:00 +01:00
register: node_certificate
- name: Check if postfix certificates exist
stat:
2023-08-23 12:27:16 +02:00
path: "/etc/letsencrypt/live/postfix-metrics-{{ inventory_hostname }}.{{ domain }}/fullchain.pem"
2023-01-27 23:55:00 +01:00
register: postfix_certificate
- name: Request certificates for node and postfix
include_tasks: configure_prometheus_exporters_certificates.yml
when: not node_certificate.stat.exists or not postfix_certificate.stat.exists
2022-10-11 09:19:07 +02:00
- name: Enable the Apache2 SSL module
community.general.apache2_module:
state: present
name: ssl
2023-01-27 23:55:00 +01:00
2022-10-11 09:19:07 +02:00
- name: Enable the Apache2 rewrite module
community.general.apache2_module:
state: present
name: rewrite
2023-01-27 23:55:00 +01:00
2022-10-11 09:19:07 +02:00
- name: Enable the Apache2 authnz_external module
community.general.apache2_module:
state: present
name: authnz_external
2023-01-27 23:55:00 +01:00
2022-10-11 09:19:07 +02:00
- name: Enable the Apache2 proxy module
community.general.apache2_module:
state: present
name: proxy
2023-01-27 23:55:00 +01:00
2022-10-11 09:19:07 +02:00
- name: Enable the Apache2 proxy_http module
community.general.apache2_module:
state: present
name: proxy_http
2023-01-27 23:55:00 +01:00
2022-10-11 09:19:07 +02:00
- name: Enable the Apache2 proxy_wstunnel module
community.general.apache2_module:
state: present
name: proxy_wstunnel
2023-01-27 23:55:00 +01:00
2022-10-11 09:19:07 +02:00
- name: Enable the Apache2 authnz_external module
community.general.apache2_module:
state: present
name: authnz_external
2022-10-11 09:19:07 +02:00
- name: Ensure virtual hosts configuration is deployed
template:
src: templates/apache2.conf.j2
dest: /etc/apache2/sites-available/25-metrics-exporters.conf
backup: yes
2023-01-27 23:55:00 +01:00
2022-10-11 09:19:07 +02:00
- name: Ensure virtual hosts configuration is enabled
file:
dest: /etc/apache2/sites-enabled/25-metrics-exporters.conf
src: /etc/apache2/sites-available/25-metrics-exporters.conf
state: link
- name: Start Apache2 after request certificate
service:
name: apache2
state: started