|
5 | 5 | vars: |
6 | 6 | elasticstack_elasticsearch_http_port: 9200 |
7 | 7 | elasticstack_initial_passwords: /usr/share/elasticsearch/initial_passwords |
| 8 | + elasticstack_elasticsearch_group_name: elasticsearch |
8 | 9 | tasks: |
9 | 10 |
|
10 | 11 | - name: Run Logstash syntax check |
|
22 | 23 |
|
23 | 24 | - name: Set elasticsearch_ca variable if not already done by user |
24 | 25 | ansible.builtin.set_fact: |
25 | | - elasticsearch_ca: "{{ groups['elasticsearch'][0] }}" |
| 26 | + elasticsearch_ca: "{{ groups[elasticstack_elasticsearch_group_name][0] }}" |
26 | 27 | when: elasticsearch_ca is undefined |
27 | 28 |
|
28 | 29 | - name: fetch Elastic password |
|
42 | 43 | sort -n | |
43 | 44 | tail -1 |
44 | 45 | register: logstash_count |
45 | | - when: "'elasticsearch' in group_names" |
| 46 | + when: "elasticstack_elasticsearch_group_name is defined and elasticstack_elasticsearch_group_name in group_names" |
46 | 47 |
|
47 | 48 | - name: Show full output |
48 | 49 | ansible.builtin.debug: |
49 | 50 | var: logstash_count |
50 | | - when: "'elasticsearch' in group_names" |
| 51 | + when: "elasticstack_elasticsearch_group_name is defined and elasticstack_elasticsearch_group_name in group_names" |
51 | 52 |
|
52 | 53 | - name: Fail when logstash index is empty |
53 | 54 | ansible.builtin.fail: |
54 | 55 | msg: "Logstash Index is empty" |
55 | | - when: "'elasticsearch' in group_names and logstash_count.stdout == 0" |
| 56 | + when: "elasticstack_elasticsearch_group_name is defined and elasticstack_elasticsearch_group_name in group_names and logstash_count.stdout == 0" |
56 | 57 |
|
57 | 58 | - name: Show number of received events |
58 | 59 | ansible.builtin.debug: |
59 | 60 | msg: "Elasticsearch received {{ logstash_count.stdout }} events so far" |
60 | | - when: "'elasticsearch' in group_names" |
| 61 | + when: "elasticstack_elasticsearch_group_name is defined and elasticstack_elasticsearch_group_name in group_names" |
61 | 62 |
|
62 | 63 | - name: Run Kibana checks |
63 | 64 | when: "'kibana' in group_names" |
|
112 | 113 | until: result.json.status == "green" |
113 | 114 | retries: 6 |
114 | 115 | delay: 10 |
115 | | - when: groups['elasticsearch'] | length > 1 |
| 116 | + when: groups[elasticstack_elasticsearch_group_name] | length > 1 |
116 | 117 |
|
117 | 118 | - name: Elasticsearch Node check |
118 | 119 | ansible.builtin.uri: |
|
125 | 126 | status_code: 200 |
126 | 127 | validate_certs: false |
127 | 128 | register: nodes |
128 | | - when: groups['elasticsearch'] | length > 1 |
| 129 | + when: groups[elasticstack_elasticsearch_group_name] | length > 1 |
129 | 130 |
|
130 | 131 | - name: Check if all Nodes see each other |
131 | 132 | ansible.builtin.assert: |
|
134 | 135 | fail_msg: "'{{ item }}' was not found in nodes.content" |
135 | 136 | success_msg: "'{{ item }}' was found in nodes.content" |
136 | 137 | with_inventory_hostnames: all |
137 | | - when: groups['elasticsearch'] | length > 1 |
| 138 | + when: groups[elasticstack_elasticsearch_group_name] | length > 1 |
138 | 139 |
|
0 commit comments