Merge pull request #257 from wazuh/fix-undefined-var-on-template
Check if var is defined
This commit is contained in:
commit
aab327144e
@ -12,6 +12,8 @@ This role will work on:
|
|||||||
* Fedora
|
* Fedora
|
||||||
* Debian
|
* Debian
|
||||||
* Ubuntu
|
* Ubuntu
|
||||||
|
|
||||||
|
For the elasticsearch role with XPack security the `unzip` command must be available on the Ansible master.
|
||||||
|
|
||||||
Role Variables
|
Role Variables
|
||||||
--------------
|
--------------
|
||||||
@ -53,6 +55,72 @@ Example Playbook
|
|||||||
- {role: ../roles/elastic-stack/ansible-elasticsearch, elasticsearch_network_host: '172.16.0.163', elasticsearch_master_candidate: true, elasticsearch_cluster_nodes: ['172.16.0.162','172.16.0.163','172.16.0.161']}
|
- {role: ../roles/elastic-stack/ansible-elasticsearch, elasticsearch_network_host: '172.16.0.163', elasticsearch_master_candidate: true, elasticsearch_cluster_nodes: ['172.16.0.162','172.16.0.163','172.16.0.161']}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- Three nodes Elasticsearch cluster with XPack security
|
||||||
|
```
|
||||||
|
---
|
||||||
|
- hosts: elastic-1
|
||||||
|
roles:
|
||||||
|
- role: ../roles/elastic-stack/ansible-elasticsearch
|
||||||
|
elasticsearch_network_host: 172.16.0.111
|
||||||
|
elasticsearch_node_name: node-1
|
||||||
|
single_node: false
|
||||||
|
elasticsearch_master_candidate: true
|
||||||
|
elasticsearch_bootstrap_node: true
|
||||||
|
elasticsearch_cluster_nodes:
|
||||||
|
- 172.16.0.111
|
||||||
|
- 172.16.0.112
|
||||||
|
- 172.16.0.113
|
||||||
|
elasticsearch_discovery_nodes:
|
||||||
|
- 172.16.0.111
|
||||||
|
- 172.16.0.112
|
||||||
|
- 172.16.0.113
|
||||||
|
elasticsearch_xpack_security: true
|
||||||
|
node_certs_generator: true
|
||||||
|
node_certs_generator_ip: 172.16.0.111
|
||||||
|
|
||||||
|
vars:
|
||||||
|
instances:
|
||||||
|
node-1:
|
||||||
|
name: node-1
|
||||||
|
ip: 172.16.0.111
|
||||||
|
node-2:
|
||||||
|
name: node-2
|
||||||
|
ip: 172.16.0.112
|
||||||
|
node-3:
|
||||||
|
name: node-3
|
||||||
|
ip: 172.16.0.113
|
||||||
|
|
||||||
|
- hosts: elastic-2
|
||||||
|
roles:
|
||||||
|
- role: ../roles/elastic-stack/ansible-elasticsearch
|
||||||
|
elasticsearch_network_host: 172.16.0.112
|
||||||
|
elasticsearch_node_name: node-2
|
||||||
|
single_node: false
|
||||||
|
elasticsearch_xpack_security: true
|
||||||
|
elasticsearch_master_candidate: true
|
||||||
|
node_certs_generator_ip: 172.16.0.111
|
||||||
|
elasticsearch_discovery_nodes:
|
||||||
|
- 172.16.0.111
|
||||||
|
- 172.16.0.112
|
||||||
|
- 172.16.0.113
|
||||||
|
|
||||||
|
- hosts: elastic-3
|
||||||
|
roles:
|
||||||
|
- role: ../roles/elastic-stack/ansible-elasticsearch
|
||||||
|
elasticsearch_network_host: 172.16.0.113
|
||||||
|
elasticsearch_node_name: node-3
|
||||||
|
single_node: false
|
||||||
|
elasticsearch_xpack_security: true
|
||||||
|
elasticsearch_master_candidate: true
|
||||||
|
node_certs_generator_ip: 172.16.0.111
|
||||||
|
elasticsearch_discovery_nodes:
|
||||||
|
- 172.16.0.111
|
||||||
|
- 172.16.0.112
|
||||||
|
- 172.16.0.113
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
License and copyright
|
License and copyright
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
|
|||||||
@ -6,10 +6,10 @@
|
|||||||
instances:
|
instances:
|
||||||
{% for (key,value) in instances.items() %}
|
{% for (key,value) in instances.items() %}
|
||||||
- name: "{{ value.name }}"
|
- name: "{{ value.name }}"
|
||||||
{% if value.ip %}
|
{% if value.ip is defined and value.ip | length > 0 %}
|
||||||
ip:
|
ip:
|
||||||
- "{{ value.ip }}"
|
- "{{ value.ip }}"
|
||||||
{% elif value.dns %}
|
{% elif value.dns is defined and value.dns | length > 0 %}
|
||||||
dns:
|
dns:
|
||||||
- "{{ value.dns }}"
|
- "{{ value.dns }}"
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user