From 87f5eb61b9479c9f9382184714c5360672d26178 Mon Sep 17 00:00:00 2001 From: Jose M Date: Thu, 25 Jun 2020 12:53:57 +0200 Subject: [PATCH] Add tasks compatibility with private and public addresses --- .../tasks/security_actions.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/roles/opendistro/opendistro-elasticsearch/tasks/security_actions.yml b/roles/opendistro/opendistro-elasticsearch/tasks/security_actions.yml index 1582d418..d2db187b 100644 --- a/roles/opendistro/opendistro-elasticsearch/tasks/security_actions.yml +++ b/roles/opendistro/opendistro-elasticsearch/tasks/security_actions.yml @@ -30,6 +30,18 @@ when: filebeat_node_name is defined + - name: Configure IP (Private address) + set_fact: + target_address: "{{ hostvars[inventory_hostname]['private_ip'] }}" + when: + - hostvars[inventory_hostname]['private_ip'] is defined + + - name: Configure IP (Public address) + set_fact: + target_address: "{{ inventory_hostname }}" + when: + - hostvars[inventory_hostname]['private_ip'] is not defined + - name: Copy the node & admin certificates to Elasticsearch cluster copy: @@ -113,12 +125,12 @@ -key {{ opendistro_conf_path }}/admin.key -cd {{ opendistro_sec_plugin_conf_path }}/ -nhnv -icl - -h {{ inventory_hostname }} + -h {{ target_address }} run_once: true - name: Create custom user uri: - url: "https://{{ inventory_hostname }}:9200/_cluster/health/" + url: "https://{{ target_address }}:9200/_cluster/health/" method: PUT user: "admin" # Default OpenDistro user is always "admin" password: "{{ opendistro_admin_password }}"