diff --git a/elk_metrics_6x/roles/elastic_apm_server/tasks/apm_setup.yml b/elk_metrics_6x/roles/elastic_apm_server/tasks/apm_setup.yml index af92fd96..aa770006 100644 --- a/elk_metrics_6x/roles/elastic_apm_server/tasks/apm_setup.yml +++ b/elk_metrics_6x/roles/elastic_apm_server/tasks/apm_setup.yml @@ -13,6 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +- name: Refresh local facts + setup: + filter: ansible_local + gather_subset: "!all" + tags: + - always + - name: Load templates shell: >- apm-server setup @@ -34,3 +41,20 @@ retries: 5 delay: 5 run_once: true + when: + - ((ansible_local['elastic']['setup']['apm_loaded_templates'] is undefined) or + (not (ansible_local['elastic']['setup']['apm_loaded_templates'] | bool))) or + (elk_package_state | default('present')) == "latest" + tags: + - setup + +- name: Set template fact + ini_file: + dest: "/etc/ansible/facts.d/elastic.fact" + section: "setup" + option: apm_loaded_templates + value: true + when: + - templates is changed + tags: + - setup diff --git a/elk_metrics_6x/roles/elastic_auditbeat/tasks/auditbeat_setup.yml b/elk_metrics_6x/roles/elastic_auditbeat/tasks/auditbeat_setup.yml index 83d35fba..69929d04 100644 --- a/elk_metrics_6x/roles/elastic_auditbeat/tasks/auditbeat_setup.yml +++ b/elk_metrics_6x/roles/elastic_auditbeat/tasks/auditbeat_setup.yml @@ -13,6 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +- name: Refresh local facts + setup: + filter: ansible_local + gather_subset: "!all" + tags: + - always + - name: Load templates shell: >- auditbeat setup @@ -34,5 +41,20 @@ retries: 5 delay: 5 run_once: true + when: + - ((ansible_local['elastic']['setup']['auditbeat_loaded_templates'] is undefined) or + (not (ansible_local['elastic']['setup']['auditbeat_loaded_templates'] | bool))) or + (elk_package_state | default('present')) == "latest" + tags: + - setup + +- name: Set template fact + ini_file: + dest: "/etc/ansible/facts.d/elastic.fact" + section: "setup" + option: auditbeat_loaded_templates + value: true + when: + - templates is changed tags: - setup diff --git a/elk_metrics_6x/roles/elastic_data_hosts/tasks/main.yml b/elk_metrics_6x/roles/elastic_data_hosts/tasks/main.yml index a2d80925..5f08eb6c 100644 --- a/elk_metrics_6x/roles/elastic_data_hosts/tasks/main.yml +++ b/elk_metrics_6x/roles/elastic_data_hosts/tasks/main.yml @@ -23,3 +23,19 @@ include_vars: "data-node-variables.yml" tags: - always + +- name: Ensure local facts directory exists + file: + dest: "/etc/ansible/facts.d" + state: directory + group: "root" + owner: "root" + mode: "0755" + recurse: no + +- name: Initialize local facts + ini_file: + dest: "/etc/ansible/facts.d/elastic.fact" + section: "setup" + option: cacheable + value: true diff --git a/elk_metrics_6x/roles/elastic_filebeat/tasks/filebeat_setup.yml b/elk_metrics_6x/roles/elastic_filebeat/tasks/filebeat_setup.yml index e4f01468..331e26ac 100644 --- a/elk_metrics_6x/roles/elastic_filebeat/tasks/filebeat_setup.yml +++ b/elk_metrics_6x/roles/elastic_filebeat/tasks/filebeat_setup.yml @@ -13,6 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +- name: Refresh local facts + setup: + filter: ansible_local + gather_subset: "!all" + tags: + - always + - name: Load templates shell: >- filebeat setup @@ -34,5 +41,20 @@ retries: 5 delay: 5 run_once: true + when: + - ((ansible_local['elastic']['setup']['filebeat_loaded_templates'] is undefined) or + (not (ansible_local['elastic']['setup']['filebeat_loaded_templates'] | bool))) or + (elk_package_state | default('present')) == "latest" + tags: + - setup + +- name: Set template fact + ini_file: + dest: "/etc/ansible/facts.d/elastic.fact" + section: "setup" + option: filebeat_loaded_templates + value: true + when: + - templates is changed tags: - setup diff --git a/elk_metrics_6x/roles/elastic_heartbeat/tasks/heartbeat_setup.yml b/elk_metrics_6x/roles/elastic_heartbeat/tasks/heartbeat_setup.yml index 1edcb14d..c5856793 100644 --- a/elk_metrics_6x/roles/elastic_heartbeat/tasks/heartbeat_setup.yml +++ b/elk_metrics_6x/roles/elastic_heartbeat/tasks/heartbeat_setup.yml @@ -13,6 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +- name: Refresh local facts + setup: + filter: ansible_local + gather_subset: "!all" + tags: + - always + - name: Load templates shell: >- heartbeat setup @@ -28,9 +35,26 @@ - "--machine-learning" - "--dashboards" register: templates + environment: + no_proxy: "{{ hostvars[groups['kibana'][0]]['ansible_host'] }}" until: templates is success retries: 5 delay: 5 run_once: true + when: + - ((ansible_local['elastic']['setup']['heartbeat_loaded_templates'] is undefined) or + (not (ansible_local['elastic']['setup']['heartbeat_loaded_templates'] | bool))) or + (elk_package_state | default('present')) == "latest" + tags: + - setup + +- name: Set template fact + ini_file: + dest: "/etc/ansible/facts.d/elastic.fact" + section: "setup" + option: heartbeat_loaded_templates + value: true + when: + - templates is changed tags: - setup diff --git a/elk_metrics_6x/roles/elastic_journalbeat/tasks/journalbeat_setup.yml b/elk_metrics_6x/roles/elastic_journalbeat/tasks/journalbeat_setup.yml index 849968f8..172153e4 100644 --- a/elk_metrics_6x/roles/elastic_journalbeat/tasks/journalbeat_setup.yml +++ b/elk_metrics_6x/roles/elastic_journalbeat/tasks/journalbeat_setup.yml @@ -13,6 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +- name: Refresh local facts + setup: + filter: ansible_local + gather_subset: "!all" + tags: + - always + - name: Load templates shell: >- journalbeat setup @@ -28,9 +35,26 @@ - "--machine-learning" - "--dashboards" register: templates + environment: + no_proxy: "{{ hostvars[groups['kibana'][0]]['ansible_host'] }}" until: templates is success retries: 5 delay: 5 run_once: true + when: + - ((ansible_local['elastic']['setup']['journalbeat_loaded_templates'] is undefined) or + (not (ansible_local['elastic']['setup']['journalbeat_loaded_templates'] | bool))) or + (elk_package_state | default('present')) == "latest" + tags: + - setup + +- name: Set template fact + ini_file: + dest: "/etc/ansible/facts.d/elastic.fact" + section: "setup" + option: journalbeat_loaded_templates + value: true + when: + - templates is changed tags: - setup diff --git a/elk_metrics_6x/roles/elastic_metricbeat/tasks/metricbeat_setup.yml b/elk_metrics_6x/roles/elastic_metricbeat/tasks/metricbeat_setup.yml index d5676ddc..7aee47a9 100644 --- a/elk_metrics_6x/roles/elastic_metricbeat/tasks/metricbeat_setup.yml +++ b/elk_metrics_6x/roles/elastic_metricbeat/tasks/metricbeat_setup.yml @@ -13,6 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +- name: Refresh local facts + setup: + filter: ansible_local + gather_subset: "!all" + tags: + - always + - name: Load templates shell: >- metricbeat setup @@ -34,5 +41,20 @@ retries: 5 delay: 5 run_once: true + when: + - ((ansible_local['elastic']['setup']['metricbeat_loaded_templates'] is undefined) or + (not (ansible_local['elastic']['setup']['metricbeat_loaded_templates'] | bool))) or + (elk_package_state | default('present')) == "latest" + tags: + - setup + +- name: Set template fact + ini_file: + dest: "/etc/ansible/facts.d/elastic.fact" + section: "setup" + option: metricbeat_loaded_templates + value: true + when: + - templates is changed tags: - setup diff --git a/elk_metrics_6x/roles/elastic_packetbeat/tasks/packetbeat_setup.yml b/elk_metrics_6x/roles/elastic_packetbeat/tasks/packetbeat_setup.yml index 9ebbbc01..21d875db 100644 --- a/elk_metrics_6x/roles/elastic_packetbeat/tasks/packetbeat_setup.yml +++ b/elk_metrics_6x/roles/elastic_packetbeat/tasks/packetbeat_setup.yml @@ -13,6 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +- name: Refresh local facts + setup: + filter: ansible_local + gather_subset: "!all" + tags: + - always + - name: Load templates shell: >- packetbeat setup @@ -34,5 +41,20 @@ retries: 5 delay: 5 run_once: true + when: + - ((ansible_local['elastic']['setup']['packetbeat_loaded_templates'] is undefined) or + (not (ansible_local['elastic']['setup']['packetbeat_loaded_templates'] | bool))) or + (elk_package_state | default('present')) == "latest" + tags: + - setup + +- name: Set template fact + ini_file: + dest: "/etc/ansible/facts.d/elastic.fact" + section: "setup" + option: packetbeat_loaded_templates + value: true + when: + - templates is changed tags: - setup