aboutsummaryrefslogtreecommitdiff
path: root/ansible/roles/prometheus/tasks/precheck.yml
blob: 5b98a09b4b0efa40fcef15ce1126f63dc0ec371a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
---
- name: Precheck prometheus configuration
  ansible.builtin.import_role:
    name: service-precheck
  vars:
    service_precheck_services: "{{ prometheus_services }}"
    service_name: "{{ project_name }}"

- name: Get container facts
  become: true
  kolla_container_facts:
    action: get_containers
    container_engine: "{{ kolla_container_engine }}"
    name:
      - prometheus_server
      - prometheus_memcached_exporter
      - prometheus_mysqld_exporter
      - prometheus_alertmanager
      - prometheus_openstack_exporter
      - prometheus_elasticsearch_exporter
      - prometheus_blackbox_exporter
      - prometheus_libvirt_exporter
      - prometheus_openstack_network_exporter
  check_mode: false
  register: container_facts

- name: Check that prometheus_bcrypt_salt is correctly set
  ansible.builtin.assert:
    that:
      - prometheus_bcrypt_salt is defined
      - prometheus_bcrypt_salt is string or prometheus_bcrypt_salt is vault_encrypted
      - prometheus_bcrypt_salt | length == 22

- name: Check that prometheus_password is correctly set
  ansible.builtin.assert:
    that:
      - prometheus_password is defined
      - prometheus_password is string or prometheus_password is vault_encrypted
      - prometheus_password | length > 0

- name: Check that prometheus_grafana_password is correctly set
  ansible.builtin.assert:
    that:
      - prometheus_grafana_password is defined
      - prometheus_grafana_password is string or prometheus_grafana_password is vault_encrypted
      - prometheus_grafana_password | length > 0
  when: enable_grafana | bool

- name: Check that prometheus_skyline_password is correctly set
  ansible.builtin.assert:
    that:
      - prometheus_skyline_password is defined
      - prometheus_skyline_password is string or prometheus_skyline_password is vault_encrypted
      - prometheus_skyline_password | length > 0
  when: enable_skyline | bool

- name: Checking free port for Prometheus server
  ansible.builtin.wait_for:
    host: "{{ 'api' | kolla_address }}"
    port: "{{ prometheus_port }}"
    connect_timeout: 1
    timeout: 1
    state: stopped
  when:
    - container_facts.containers['prometheus_server'] is not defined
    - inventory_hostname in groups['prometheus']
    - enable_prometheus_server | bool

- name: Checking free port for Prometheus mysqld_exporter
  ansible.builtin.wait_for:
    host: "{{ 'api' | kolla_address }}"
    port: "{{ prometheus_mysqld_exporter_port }}"
    connect_timeout: 1
    timeout: 1
    state: stopped
  when:
    - container_facts.containers['prometheus_mysqld_exporter'] is not defined
    - inventory_hostname in groups['prometheus-mysqld-exporter']
    - enable_prometheus_mysqld_exporter | bool

- name: Checking free port for Prometheus memcached_exporter
  ansible.builtin.wait_for:
    host: "{{ 'api' | kolla_address }}"
    port: "{{ prometheus_memcached_exporter_port }}"
    connect_timeout: 1
    timeout: 1
    state: stopped
  when:
    - container_facts.containers['prometheus_memcached_exporter'] is not defined
    - inventory_hostname in groups['prometheus-memcached-exporter']
    - enable_prometheus_memcached_exporter | bool

- name: Checking free ports for Prometheus Alertmanager
  ansible.builtin.wait_for:
    host: "{{ 'api' | kolla_address }}"
    port: "{{ item }}"
    connect_timeout: 1
    timeout: 1
    state: stopped
  when:
    - container_facts.containers['prometheus_alertmanager'] is not defined
    - inventory_hostname in groups['prometheus-alertmanager']
    - enable_prometheus_alertmanager | bool
  with_items:
    - "{{ prometheus_alertmanager_port }}"
    - "{{ prometheus_alertmanager_cluster_port }}"

- name: Checking free ports for Prometheus openstack-exporter
  ansible.builtin.wait_for:
    host: "{{ 'api' | kolla_address }}"
    port: "{{ item }}"
    connect_timeout: 1
    timeout: 1
    state: stopped
  when:
    - container_facts.containers['prometheus_openstack_exporter'] is not defined
    - inventory_hostname in groups['prometheus-openstack-exporter']
    - enable_prometheus_openstack_exporter | bool
  with_items:
    - "{{ prometheus_openstack_exporter_port }}"

- name: Checking free ports for Prometheus elasticsearch-exporter
  ansible.builtin.wait_for:
    host: "{{ 'api' | kolla_address }}"
    port: "{{ item }}"
    connect_timeout: 1
    timeout: 1
    state: stopped
  when:
    - container_facts.containers['prometheus_elasticsearch_exporter'] is not defined
    - inventory_hostname in groups['prometheus-elasticsearch-exporter']
    - enable_prometheus_elasticsearch_exporter | bool
  with_items:
    - "{{ prometheus_elasticsearch_exporter_port }}"

- name: Checking free ports for Prometheus blackbox-exporter
  ansible.builtin.wait_for:
    host: "{{ 'api' | kolla_address }}"
    port: "{{ item }}"
    connect_timeout: 1
    timeout: 1
    state: stopped
  when:
    - container_facts.containers['prometheus_blackbox_exporter'] is not defined
    - inventory_hostname in groups['prometheus-blackbox-exporter']
    - enable_prometheus_blackbox_exporter | bool
  with_items:
    - "{{ prometheus_blackbox_exporter_port }}"

- name: Checking free ports for Prometheus libvirt-exporter
  ansible.builtin.wait_for:
    host: "{{ 'api' | kolla_address }}"
    port: "{{ item }}"
    connect_timeout: 1
    timeout: 1
    state: stopped
  when:
    - container_facts.containers['prometheus_libvirt_exporter'] is not defined
    - inventory_hostname in groups['prometheus-libvirt-exporter']
    - enable_prometheus_libvirt_exporter | bool
  with_items:
    - "{{ prometheus_libvirt_exporter_port }}"

- name: Checking free ports for Prometheus network-exporter
  ansible.builtin.wait_for:
    host: "{{ 'api' | kolla_address }}"
    port: "{{ item }}"
    connect_timeout: 1
    timeout: 1
    state: stopped
  when:
    - container_facts.containers['prometheus_openstack_network_exporter'] is not defined
    - inventory_hostname in groups['prometheus-openstack-network-exporter']
    - enable_prometheus_openstack_network_exporter | bool
  with_items:
    - "{{ prometheus_openstack_network_exporter_port }}"