diff --git a/elk_metrics_7x/installJournalbeat.yml b/elk_metrics_7x/installJournalbeat.yml index 2cae6799..a8b6b150 100644 --- a/elk_metrics_7x/installJournalbeat.yml +++ b/elk_metrics_7x/installJournalbeat.yml @@ -63,7 +63,7 @@ meta: end_play when: - not (journal_dir.stat.exists | bool) or - (ansible_service_mgr != 'systemd') + (ansible_facts['service_mgr'] != 'systemd') roles: - role: elastic_journalbeat @@ -94,7 +94,7 @@ meta: end_play when: - not (journal_dir.stat.exists | bool) or - (ansible_service_mgr != 'systemd') + (ansible_facts['service_mgr'] != 'systemd') roles: - role: elastic_rollup diff --git a/elk_metrics_7x/installMonitorStack.yml b/elk_metrics_7x/installMonitorStack.yml index ca4320a2..d7fd9307 100644 --- a/elk_metrics_7x/installMonitorStack.yml +++ b/elk_metrics_7x/installMonitorStack.yml @@ -27,7 +27,7 @@ union(groups['memcached_all'] | default([])) | union(groups['memcached_all'] | default([])) ) - - ansible_service_mgr == 'systemd' + - ansible_facts['service_mgr'] == 'systemd' tags: - always @@ -154,7 +154,7 @@ post_tasks: - name: Find clouds config stat: - path: "{{ ansible_env.HOME }}/.config/openstack/clouds.yaml" + path: "{{ ansible_facts['env']['HOME'] }}/.config/openstack/clouds.yaml" register: clouds_config - name: Find openstack release @@ -174,9 +174,9 @@ block: - name: Ensure disto packages are installed package: - name: "{{ monitorstack_distro_packages[(ansible_distribution | lower)] }}" + name: "{{ monitorstack_distro_packages[(ansible_facts['distribution'] | lower)] }}" state: "{{ monitorstack_package_state | default('present') }}" - update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}" + update_cache: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('yes', omit) }}" - name: Refresh local facts setup: @@ -218,7 +218,7 @@ - name: Copy the clouds config into monitorstack copy: - src: "{{ ansible_env.HOME }}/.config/openstack/clouds.yaml" + src: "{{ ansible_facts['env']['HOME'] }}/.config/openstack/clouds.yaml" dest: "/var/lib/monitorstack/.config/openstack/clouds.yaml" remote_src: yes when: diff --git a/elk_metrics_7x/roles/elastic_apm_server/tasks/main.yml b/elk_metrics_7x/roles/elastic_apm_server/tasks/main.yml index 199d4a16..30525d38 100644 --- a/elk_metrics_7x/roles/elastic_apm_server/tasks/main.yml +++ b/elk_metrics_7x/roles/elastic_apm_server/tasks/main.yml @@ -14,14 +14,18 @@ # limitations under the License. - name: Gather variables for each operating system - include_vars: "{{ item }}" - with_first_found: - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_distribution | lower }}.yml" - - "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yml" - - "{{ ansible_os_family | lower }}.yml" + include_vars: "{{ lookup('first_found', params) }}" + vars: + params: + files: + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_version'].split('.')[0] }}.yml" + - "{{ ansible_facts['os_family'] | lower }}.yml" + paths: + - "{{ role_path }}/vars" tags: - always @@ -29,7 +33,7 @@ package: name: "{{ apm_server_distro_packages }}" state: "{{ elk_package_state | default('present') }}" - update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}" + update_cache: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('yes', omit) }}" register: _package_task until: _package_task is success retries: 3 diff --git a/elk_metrics_7x/roles/elastic_auditbeat/tasks/main.yml b/elk_metrics_7x/roles/elastic_auditbeat/tasks/main.yml index 8693435d..9bac792f 100644 --- a/elk_metrics_7x/roles/elastic_auditbeat/tasks/main.yml +++ b/elk_metrics_7x/roles/elastic_auditbeat/tasks/main.yml @@ -14,14 +14,18 @@ # limitations under the License. - name: Gather variables for each operating system - include_vars: "{{ item }}" - with_first_found: - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_distribution | lower }}.yml" - - "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yml" - - "{{ ansible_os_family | lower }}.yml" + include_vars: "{{ lookup('first_found', params) }}" + vars: + params: + files: + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_version'].split('.')[0] }}.yml" + - "{{ ansible_facts['os_family'] | lower }}.yml" + paths: + - "{{ role_path }}/vars" tags: - always @@ -31,13 +35,13 @@ - auditbeat containerised: true when: - - ansible_virtualization_type in ["systemd-nspawn", "lxc", "lxd", "podman", "docker", "systemd_container", "container"] + - ansible_facts['virtualization_type'] in ["systemd-nspawn", "lxc", "lxd", "podman", "docker", "systemd_container", "container"] - name: Ensure beat is installed package: name: "{{ auditbeat_distro_packages }}" state: "{{ elk_package_state | default('present') }}" - update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}" + update_cache: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('yes', omit) }}" register: _package_task until: _package_task is success retries: 3 diff --git a/elk_metrics_7x/roles/elastic_auditbeat/templates/auditbeat.yml.j2 b/elk_metrics_7x/roles/elastic_auditbeat/templates/auditbeat.yml.j2 index 101994c1..dc3f5347 100644 --- a/elk_metrics_7x/roles/elastic_auditbeat/templates/auditbeat.yml.j2 +++ b/elk_metrics_7x/roles/elastic_auditbeat/templates/auditbeat.yml.j2 @@ -34,7 +34,7 @@ auditbeat.modules: # The auditd module collects events from the audit framework in the Linux # kernel. You need to specify audit rules for the events that you want to audit. - module: auditd -{% if ansible_kernel is version('4.4', '>=') %} +{% if ansible_facts['kernel'] is version('4.4', '>=') %} socket_type: {{ (apply_security_hardening | default(true) | bool) | ternary('multicast', 'unicast') }} {% endif %} resolve_ids: true @@ -678,7 +678,7 @@ name: {{ elastic_hostname }} #kerberos.realm: ELASTIC # ------------------------------ Logstash Output ------------------------------- -{{ elk_macros.output_logstash(inventory_hostname, logstash_data_hosts, ansible_processor_count) }} +{{ elk_macros.output_logstash(inventory_hostname, logstash_data_hosts, ansible_facts['processor_count']) }} # -------------------------------- Kafka Output -------------------------------- #output.kafka: @@ -1155,7 +1155,7 @@ setup.ilm.policy_file: "{{ ilm_policy_file_location }}/{{ ilm_policy_filename }} {{ elk_macros.beat_logging('auditbeat', auditbeat_log_level) }} # ============================= X-Pack Monitoring ============================== -{{ elk_macros.xpack_monitoring_elasticsearch('auditbeat', inventory_hostname, elasticsearch_data_hosts, ansible_processor_count, beats_system_username, elastic_cluster_uuid) }} +{{ elk_macros.xpack_monitoring_elasticsearch('auditbeat', inventory_hostname, elasticsearch_data_hosts, ansible_facts['processor_count'], beats_system_username, elastic_cluster_uuid) }} # =============================== HTTP Endpoint ================================ diff --git a/elk_metrics_7x/roles/elastic_data_hosts/defaults/main.yml b/elk_metrics_7x/roles/elastic_data_hosts/defaults/main.yml index 1a1db482..9fa934b2 100644 --- a/elk_metrics_7x/roles/elastic_data_hosts/defaults/main.yml +++ b/elk_metrics_7x/roles/elastic_data_hosts/defaults/main.yml @@ -14,7 +14,7 @@ # limitations under the License. # This interface is used to determine cluster recovery speed. -elastic_data_interface: "{{ ansible_default_ipv4['alias'] }}" +elastic_data_interface: "{{ ansible_facts['default_ipv4']['alias'] }}" # A list of interfaces/ports of the elasticsearch data nodes # to override the default of ansible_host:elastic_port diff --git a/elk_metrics_7x/roles/elastic_data_hosts/vars/data-node-variables.yml b/elk_metrics_7x/roles/elastic_data_hosts/vars/data-node-variables.yml index c3e8d1c4..c052ad42 100644 --- a/elk_metrics_7x/roles/elastic_data_hosts/vars/data-node-variables.yml +++ b/elk_metrics_7x/roles/elastic_data_hosts/vars/data-node-variables.yml @@ -99,11 +99,11 @@ _elasticsearch_discovery_seed_hosts: >- }} elasticsearch_interface_speed: |- - {% set default_interface_fact = hostvars[inventory_hostname]['ansible_' + (elastic_data_interface | replace('-', '_'))] %} + {% set default_interface_fact = hostvars[inventory_hostname]['ansible_facts'][elastic_data_interface | replace('-', '_')] %} {% set speeds = [] %} {% if default_interface_fact['type'] == 'bridge' %} {% for interface in default_interface_fact['interfaces'] %} - {% set interface_fact = hostvars[inventory_hostname]['ansible_' + (interface | replace('-', '_'))] %} + {% set interface_fact = hostvars[inventory_hostname]['ansible_facts'][interface | replace('-', '_')] %} {% if 'speed' in interface_fact %} {% set speed = (interface_fact['speed'] | default(1000)) | string %} {% if speed == "-1" %} @@ -158,9 +158,9 @@ logstash_data_node_details: >- master_node: "{{ (inventory_hostname in master_nodes) | ternary(true, false) }}" data_node: "{{ (inventory_hostname in data_nodes) | ternary(true, false) }}" -elastic_processors_floor: "{{ ((ansible_processor_count | int) - 1) }}" +elastic_processors_floor: "{{ ((ansible_facts['processor_count'] | int) - 1) }}" elastic_processors_floor_set: "{{ ((elastic_processors_floor | int) > 0) | ternary(elastic_processors_floor, 1) }}" -elastic_thread_pool_size: "{{ ((ansible_processor_count | int) >= 24) | ternary(23, elastic_processors_floor_set) }}" +elastic_thread_pool_size: "{{ ((ansible_facts['processor_count'] | int) >= 24) | ternary(23, elastic_processors_floor_set) }}" # Set a data node facts. The data nodes, in the case of elasticsearch are also # ingest nodes. diff --git a/elk_metrics_7x/roles/elastic_dependencies/defaults/main.yml b/elk_metrics_7x/roles/elastic_dependencies/defaults/main.yml index 9adacfbb..ef9431b3 100644 --- a/elk_metrics_7x/roles/elastic_dependencies/defaults/main.yml +++ b/elk_metrics_7x/roles/elastic_dependencies/defaults/main.yml @@ -21,7 +21,7 @@ #elastic_shared_fs_repos: # - fstype: nfs4 # src: ":/esbackup" -# opts: clientaddr="{{ ansible_eth1['ipv4']['address'] }}" +# opts: clientaddr="{{ ansible_facts['eth1']['ipv4']['address'] }}" # path: "/elastic-backup" # state: mounted diff --git a/elk_metrics_7x/roles/elastic_dependencies/tasks/main.yml b/elk_metrics_7x/roles/elastic_dependencies/tasks/main.yml index 1b041e48..f3aa5ad7 100644 --- a/elk_metrics_7x/roles/elastic_dependencies/tasks/main.yml +++ b/elk_metrics_7x/roles/elastic_dependencies/tasks/main.yml @@ -38,14 +38,18 @@ include_vars: "vars_{{ service_name }}.yml" - name: Gather variables for each operating system - include_vars: "{{ item }}" - with_first_found: - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_distribution | lower }}.yml" - - "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yml" - - "{{ ansible_os_family | lower }}.yml" + include_vars: "{{ lookup('first_found', params) }}" + vars: + params: + files: + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_version'].split('.')[0] }}.yml" + - "{{ ansible_facts['os_family'] | lower }}.yml" + paths: + - "{{ role_path }}/vars" tags: - always @@ -186,8 +190,8 @@ package: name: "{{ elastic_distro_packages }}" state: "{{ elk_package_state | default('present') }}" - install_recommends: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}" - update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}" + install_recommends: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('yes', omit) }}" + update_cache: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('yes', omit) }}" register: _package_task until: _package_task is success retries: 3 @@ -208,7 +212,7 @@ name: java path: "{{ java_alternatives.stdout.strip() }}" when: - - (ansible_os_family | lower) == 'debian' + - (ansible_facts['os_family'] | lower) == 'debian' - name: Ensure service directories exists file: @@ -229,7 +233,7 @@ lineinfile: path: /etc/hosts regexp: '^{{ item }}' - line: '{{ item }} {{ ansible_hostname }} {{ ansible_fqdn }}' + line: '{{ item }} {{ ansible_facts["hostname"] }} {{ ansible_facts["fqdn"] }}' owner: root group: root mode: 0644 diff --git a/elk_metrics_7x/roles/elastic_filebeat/tasks/main.yml b/elk_metrics_7x/roles/elastic_filebeat/tasks/main.yml index 9ca63ce1..c15f9d54 100644 --- a/elk_metrics_7x/roles/elastic_filebeat/tasks/main.yml +++ b/elk_metrics_7x/roles/elastic_filebeat/tasks/main.yml @@ -14,14 +14,18 @@ # limitations under the License. - name: Gather variables for each operating system - include_vars: "{{ item }}" - with_first_found: - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_distribution | lower }}.yml" - - "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yml" - - "{{ ansible_os_family | lower }}.yml" + include_vars: "{{ lookup('first_found', params) }}" + vars: + params: + files: + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_version'].split('.')[0] }}.yml" + - "{{ ansible_facts['os_family'] | lower }}.yml" + paths: + - "{{ role_path }}/vars" tags: - always @@ -29,7 +33,7 @@ package: name: "{{ filebeat_distro_packages }}" state: "{{ elk_package_state | default('present') }}" - update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}" + update_cache: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('yes', omit) }}" register: _package_task until: _package_task is success retries: 3 @@ -63,11 +67,11 @@ - name: Set dicovery facts to enable Filebeat modules set_fact: - elasticsearch_enabled: "{{ ((ansible_facts.services['elasticsearch.service'] | default({}) )['state'] | default('')) == 'running' }}" - logstash_enabled: "{{ ((ansible_facts.services['logstash.service'] | default({}) )['state'] | default('')) == 'running' }}" - kibana_enabled: "{{ ((ansible_facts.services['kibana.service'] | default({}) )['state'] | default('')) == 'running' }}" - haproxy_enabled: "{{ ((ansible_facts.services['haproxy.service'] | default({}) )['state'] | default('')) == 'running' }}" - nginx_enabled: "{{ ((ansible_facts.services['nginx.service'] | default({}) )['state'] | default('')) == 'running' }}" + elasticsearch_enabled: "{{ ((ansible_facts.services['elasticsearch.service'] | default({}))['state'] | default('')) == 'running' }}" + logstash_enabled: "{{ ((ansible_facts.services['logstash.service'] | default({}))['state'] | default('')) == 'running' }}" + kibana_enabled: "{{ ((ansible_facts.services['kibana.service'] | default({}))['state'] | default('')) == 'running' }}" + haproxy_enabled: "{{ ((ansible_facts.services['haproxy.service'] | default({}))['state'] | default('')) == 'running' }}" + nginx_enabled: "{{ ((ansible_facts.services['nginx.service'] | default({}))['state'] | default('')) == 'running' }}" - name: Drop Filebeat conf file template: diff --git a/elk_metrics_7x/roles/elastic_filebeat/templates/filebeat.yml.j2 b/elk_metrics_7x/roles/elastic_filebeat/templates/filebeat.yml.j2 index 545123b6..8d9fef4c 100644 --- a/elk_metrics_7x/roles/elastic_filebeat/templates/filebeat.yml.j2 +++ b/elk_metrics_7x/roles/elastic_filebeat/templates/filebeat.yml.j2 @@ -1571,7 +1571,7 @@ name: {{ elastic_hostname }} #kerberos.realm: ELASTIC # ------------------------------ Logstash Output ------------------------------- -{{ elk_macros.output_logstash(inventory_hostname, logstash_data_hosts, ansible_processor_count) }} +{{ elk_macros.output_logstash(inventory_hostname, logstash_data_hosts, ansible_facts['processor_count']) }} # -------------------------------- Kafka Output -------------------------------- #output.kafka: @@ -2048,7 +2048,7 @@ setup.ilm.policy_file: "{{ ilm_policy_file_location }}/{{ ilm_policy_filename }} {{ elk_macros.beat_logging('filebeat', filebeat_log_level) }} # ============================= X-Pack Monitoring ============================== -{{ elk_macros.xpack_monitoring_elasticsearch('filebeat', inventory_hostname, elasticsearch_data_hosts, ansible_processor_count, beats_system_username, elastic_cluster_uuid) }} +{{ elk_macros.xpack_monitoring_elasticsearch('filebeat', inventory_hostname, elasticsearch_data_hosts, ansible_facts['processor_count'], beats_system_username, elastic_cluster_uuid) }} # =============================== HTTP Endpoint ================================ diff --git a/elk_metrics_7x/roles/elastic_heartbeat/tasks/main.yml b/elk_metrics_7x/roles/elastic_heartbeat/tasks/main.yml index 7a5e068b..56e773fa 100644 --- a/elk_metrics_7x/roles/elastic_heartbeat/tasks/main.yml +++ b/elk_metrics_7x/roles/elastic_heartbeat/tasks/main.yml @@ -14,14 +14,18 @@ # limitations under the License. - name: Gather variables for each operating system - include_vars: "{{ item }}" - with_first_found: - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_distribution | lower }}.yml" - - "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yml" - - "{{ ansible_os_family | lower }}.yml" + include_vars: "{{ lookup('first_found', params) }}" + vars: + params: + files: + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_version'].split('.')[0] }}.yml" + - "{{ ansible_facts['os_family'] | lower }}.yml" + paths: + - "{{ role_path }}/vars" tags: - always @@ -29,7 +33,7 @@ package: name: "{{ heartbeat_distro_packages }}" state: "{{ elk_package_state | default('present') }}" - update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}" + update_cache: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('yes', omit) }}" register: _package_task until: _package_task is success retries: 3 diff --git a/elk_metrics_7x/roles/elastic_heartbeat/templates/heartbeat.yml.j2 b/elk_metrics_7x/roles/elastic_heartbeat/templates/heartbeat.yml.j2 index 41483cb3..6a9f1b1e 100644 --- a/elk_metrics_7x/roles/elastic_heartbeat/templates/heartbeat.yml.j2 +++ b/elk_metrics_7x/roles/elastic_heartbeat/templates/heartbeat.yml.j2 @@ -805,7 +805,7 @@ name: {{ elastic_hostname }} #kerberos.realm: ELASTIC # ------------------------------ Logstash Output ------------------------------- -{{ elk_macros.output_logstash(inventory_hostname, logstash_data_hosts, ansible_processor_count) }} +{{ elk_macros.output_logstash(inventory_hostname, logstash_data_hosts, ansible_facts['processor_count']) }} # -------------------------------- Kafka Output -------------------------------- #output.kafka: @@ -1282,7 +1282,7 @@ setup.ilm.policy_file: "{{ ilm_policy_file_location }}/{{ ilm_policy_filename }} {{ elk_macros.beat_logging('heartbeat', heartbeat_log_level) }} # ============================= X-Pack Monitoring ============================== -{{ elk_macros.xpack_monitoring_elasticsearch('heartbeat', inventory_hostname, elasticsearch_data_hosts, ansible_processor_count, beats_system_username, elastic_cluster_uuid) }} +{{ elk_macros.xpack_monitoring_elasticsearch('heartbeat', inventory_hostname, elasticsearch_data_hosts, ansible_facts['processor_count'], beats_system_username, elastic_cluster_uuid) }} # =============================== HTTP Endpoint ================================ diff --git a/elk_metrics_7x/roles/elastic_journalbeat/tasks/main.yml b/elk_metrics_7x/roles/elastic_journalbeat/tasks/main.yml index 7aaa06a0..09f4e97e 100644 --- a/elk_metrics_7x/roles/elastic_journalbeat/tasks/main.yml +++ b/elk_metrics_7x/roles/elastic_journalbeat/tasks/main.yml @@ -14,14 +14,18 @@ # limitations under the License. - name: Gather variables for each operating system - include_vars: "{{ item }}" - with_first_found: - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_distribution | lower }}.yml" - - "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yml" - - "{{ ansible_os_family | lower }}.yml" + include_vars: "{{ lookup('first_found', params) }}" + vars: + params: + files: + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_version'].split('.')[0] }}.yml" + - "{{ ansible_facts['os_family'] | lower }}.yml" + paths: + - "{{ role_path }}/vars" tags: - always @@ -37,7 +41,7 @@ package: name: "{{ journalbeat_distro_packages }}" state: "{{ elk_package_state | default('present') }}" - update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}" + update_cache: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('yes', omit) }}" register: _package_task until: _package_task is success retries: 3 diff --git a/elk_metrics_7x/roles/elastic_journalbeat/templates/journalbeat.yml.j2 b/elk_metrics_7x/roles/elastic_journalbeat/templates/journalbeat.yml.j2 index 91671bb2..a1c31c81 100644 --- a/elk_metrics_7x/roles/elastic_journalbeat/templates/journalbeat.yml.j2 +++ b/elk_metrics_7x/roles/elastic_journalbeat/templates/journalbeat.yml.j2 @@ -542,7 +542,7 @@ queue: #kerberos.realm: ELASTIC # ------------------------------ Logstash Output ------------------------------- -{{ elk_macros.output_logstash(inventory_hostname, logstash_data_hosts, ansible_processor_count, 'journalbeat') }} +{{ elk_macros.output_logstash(inventory_hostname, logstash_data_hosts, ansible_facts['processor_count'], 'journalbeat') }} # -------------------------------- Kafka Output -------------------------------- #output.kafka: @@ -1019,7 +1019,7 @@ setup.ilm.policy_file: "{{ ilm_policy_file_location }}/{{ ilm_policy_filename }} {{ elk_macros.beat_logging('journalbeat', journalbeat_log_level) }} # ============================= X-Pack Monitoring ============================== -{{ elk_macros.xpack_monitoring_elasticsearch('journalbeat', inventory_hostname, elasticsearch_data_hosts, ansible_processor_count, beats_system_username, elastic_cluster_uuid) }} +{{ elk_macros.xpack_monitoring_elasticsearch('journalbeat', inventory_hostname, elasticsearch_data_hosts, ansible_facts['processor_count'], beats_system_username, elastic_cluster_uuid) }} # =============================== HTTP Endpoint ================================ diff --git a/elk_metrics_7x/roles/elastic_kibana/defaults/main.yml b/elk_metrics_7x/roles/elastic_kibana/defaults/main.yml index 8e90a4d0..ab410d70 100644 --- a/elk_metrics_7x/roles/elastic_kibana/defaults/main.yml +++ b/elk_metrics_7x/roles/elastic_kibana/defaults/main.yml @@ -21,8 +21,8 @@ kibana_port: 5601 kibana_username: admin kibana_password: admin kibana_nginx_port: 81 -kibana_server_name: "{{ ansible_hostname }}" -kibana_index_on_elasticsearch: "http://{{ hostvars[groups['elastic'][0]]['ansible_host'] }}:{{ elastic_port}}/.kibana" +kibana_server_name: "{{ ansible_facts['hostname'] }}" +kibana_index_on_elasticsearch: "http://{{ hostvars[groups['elastic'][0]]['ansible_host'] }}:{{ elastic_port }}/.kibana" kibana_elastic_request_timeout: 1800000 # If unset, the protocol and port default to http and elastic_port diff --git a/elk_metrics_7x/roles/elastic_kibana/tasks/main.yml b/elk_metrics_7x/roles/elastic_kibana/tasks/main.yml index 727237b4..86b75d09 100644 --- a/elk_metrics_7x/roles/elastic_kibana/tasks/main.yml +++ b/elk_metrics_7x/roles/elastic_kibana/tasks/main.yml @@ -14,14 +14,18 @@ # limitations under the License. - name: Gather variables for each operating system - include_vars: "{{ item }}" - with_first_found: - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_distribution | lower }}.yml" - - "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yml" - - "{{ ansible_os_family | lower }}.yml" + include_vars: "{{ lookup('first_found', params) }}" + vars: + params: + files: + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_version'].split('.')[0] }}.yml" + - "{{ ansible_facts['os_family'] | lower }}.yml" + paths: + - "{{ role_path }}/vars" tags: - always @@ -29,7 +33,7 @@ package: name: "{{ kibana_distro_packages }}" state: "{{ elk_package_state | default('present') }}" - update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}" + update_cache: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('yes', omit) }}" register: _package_task until: _package_task is success retries: 3 diff --git a/elk_metrics_7x/roles/elastic_logstash/tasks/main.yml b/elk_metrics_7x/roles/elastic_logstash/tasks/main.yml index 2bb341de..2c447e2d 100644 --- a/elk_metrics_7x/roles/elastic_logstash/tasks/main.yml +++ b/elk_metrics_7x/roles/elastic_logstash/tasks/main.yml @@ -14,14 +14,18 @@ # limitations under the License. - name: Gather variables for each operating system - include_vars: "{{ item }}" - with_first_found: - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_distribution | lower }}.yml" - - "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yml" - - "{{ ansible_os_family | lower }}.yml" + include_vars: "{{ lookup('first_found', params) }}" + vars: + params: + files: + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_version'].split('.')[0] }}.yml" + - "{{ ansible_facts['os_family'] | lower }}.yml" + paths: + - "{{ role_path }}/vars" tags: - always @@ -48,7 +52,7 @@ package: name: "{{ logstash_distro_packages }}" state: "{{ elk_package_state | default('present') }}" - update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}" + update_cache: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('yes', omit) }}" register: _package_task until: _package_task is success retries: 3 @@ -115,7 +119,7 @@ - name: Set device info fact set_fact: - _logstash_device_info: "{{ ansible_devices[_logstash_device] }}" + _logstash_device_info: "{{ ansible_facts['devices'][_logstash_device] }}" - name: Set persisted queue fact set_fact: diff --git a/elk_metrics_7x/roles/elastic_logstash/templates/logstash.yml.j2 b/elk_metrics_7x/roles/elastic_logstash/templates/logstash.yml.j2 index 5fc5b542..c8259519 100644 --- a/elk_metrics_7x/roles/elastic_logstash/templates/logstash.yml.j2 +++ b/elk_metrics_7x/roles/elastic_logstash/templates/logstash.yml.j2 @@ -38,9 +38,9 @@ path.data: /var/lib/logstash # # This defaults to the number of the host's CPU cores. # -{% set _d_processors = ((ansible_processor_count | int) * 3) %} +{% set _d_processors = ((ansible_facts['processor_count'] | int) * 3) %} {% set _processors = ((_d_processors | int) > 0) | ternary(_d_processors, 2) %} -{% set _t_processors = (_processors | int) + (ansible_processor_count | int) %} +{% set _t_processors = (_processors | int) + (ansible_facts['processor_count'] | int) %} {% set processors = ((_t_processors | int) > 64) | ternary(64, _t_processors) %} pipeline.workers: {{ processors | int }} # diff --git a/elk_metrics_7x/roles/elastic_metricbeat/tasks/main.yml b/elk_metrics_7x/roles/elastic_metricbeat/tasks/main.yml index 8fcb6aff..27930d01 100644 --- a/elk_metrics_7x/roles/elastic_metricbeat/tasks/main.yml +++ b/elk_metrics_7x/roles/elastic_metricbeat/tasks/main.yml @@ -14,14 +14,18 @@ # limitations under the License. - name: Gather variables for each operating system - include_vars: "{{ item }}" - with_first_found: - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_distribution | lower }}.yml" - - "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yml" - - "{{ ansible_os_family | lower }}.yml" + include_vars: "{{ lookup('first_found', params) }}" + vars: + params: + files: + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_version'].split('.')[0] }}.yml" + - "{{ ansible_facts['os_family'] | lower }}.yml" + paths: + - "{{ role_path }}/vars" tags: - always @@ -38,7 +42,7 @@ package: name: "{{ metricbeat_distro_packages }}" state: "{{ elk_package_state | default('present') }}" - update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}" + update_cache: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('yes', omit) }}" register: _package_task until: _package_task is success retries: 3 @@ -72,7 +76,7 @@ {% set _ = ceph_stats.insert(loop.index, (mon + ":5000")) %} {% endfor %} {% else %} - {% set ceph_stats = [ ansible_hostname + ":5000" ] %} + {% set ceph_stats = [ansible_facts['hostname'] + ":5000"] %} {% endif %} {{ ceph_stats }} diff --git a/elk_metrics_7x/roles/elastic_metricbeat/templates/metricbeat.yml.j2 b/elk_metrics_7x/roles/elastic_metricbeat/templates/metricbeat.yml.j2 index 27e713cc..32496e13 100644 --- a/elk_metrics_7x/roles/elastic_metricbeat/templates/metricbeat.yml.j2 +++ b/elk_metrics_7x/roles/elastic_metricbeat/templates/metricbeat.yml.j2 @@ -58,8 +58,8 @@ metricbeat.max_start_delay: 10s #========================== Modules configuration ============================= {% set metric_sets = ['network', 'process', 'process_summary', 'uptime', 'service'] %} {% if physical_host is defined and physical_host != inventory_hostname %} -{% set host_mount_devices = (hostvars[physical_host]['ansible_mounts'] | map(attribute='device') | list) %} -{% set container_mount_devices = (ansible_mounts | map(attribute='device') | list) %} +{% set host_mount_devices = (hostvars[physical_host][ansible_facts['mounts']] | map(attribute='device') | list) %} +{% set container_mount_devices = (ansible_facts['mounts'] | map(attribute='device') | list) %} {% if (((container_mount_devices | difference(host_mount_devices)) | length) > 0) | bool %} {% set _ = metric_sets.extend(['filesystem', 'fsstat']) %} {% endif %} @@ -126,7 +126,7 @@ metricbeat.modules: process.cmdline.cache.enabled: true # Enable collection of cgroup metrics from processes on Linux. - process.cgroups.enabled: {{ ansible_service_mgr == 'systemd' }} + process.cgroups.enabled: {{ ansible_facts['service_mgr'] == 'systemd' }} # A list of regular expressions used to whitelist environment variables # reported with the process metricset's events. Defaults to empty. @@ -620,7 +620,7 @@ metricbeat.modules: - module: memcached metricsets: ["stats"] period: 30s - hosts: ["{{ ansible_hostname }}:11211"] + hosts: ["{{ ansible_facts['hostname'] }}:11211"] enabled: true {% endif %} @@ -690,7 +690,7 @@ metricbeat.modules: # or another DSN format supported by . # The username and password can either be set in the DSN or using the username # and password config options. Those specified in the DSN take precedence. - hosts: ["{{ galera_root_user }}:{{ galera_root_password }}@tcp({{ ansible_hostname }}:3306)/"] + hosts: ["{{ galera_root_user }}:{{ galera_root_password }}@tcp({{ ansible_facts['hostname'] }}:3306)/"] # Username of hosts. Empty by default. username: {{ galera_root_user }} @@ -1438,7 +1438,7 @@ name: {{ elastic_hostname }} #kerberos.realm: ELASTIC # ------------------------------ Logstash Output ------------------------------- -{{ elk_macros.output_logstash(inventory_hostname, logstash_data_hosts, ansible_processor_count) }} +{{ elk_macros.output_logstash(inventory_hostname, logstash_data_hosts, ansible_facts['processor_count']) }} # -------------------------------- Kafka Output -------------------------------- #output.kafka: # Boolean flag to enable or disable the output module. @@ -1916,7 +1916,7 @@ setup.ilm.policy_file: "{{ ilm_policy_file_location }}/{{ ilm_policy_filename }} {{ elk_macros.beat_logging('metricbeat', metricbeat_log_level) }} # ============================= X-Pack Monitoring ============================== -{{ elk_macros.xpack_monitoring_elasticsearch('metricbeat', inventory_hostname, elasticsearch_data_hosts, ansible_processor_count, beats_system_username, elastic_cluster_uuid) }} +{{ elk_macros.xpack_monitoring_elasticsearch('metricbeat', inventory_hostname, elasticsearch_data_hosts, ansible_facts['processor_count'], beats_system_username, elastic_cluster_uuid) }} # =============================== HTTP Endpoint ================================ diff --git a/elk_metrics_7x/roles/elastic_packetbeat/tasks/main.yml b/elk_metrics_7x/roles/elastic_packetbeat/tasks/main.yml index 3dff6bc3..3d762501 100644 --- a/elk_metrics_7x/roles/elastic_packetbeat/tasks/main.yml +++ b/elk_metrics_7x/roles/elastic_packetbeat/tasks/main.yml @@ -14,22 +14,25 @@ # limitations under the License. - name: Gather variables for each operating system - include_vars: "{{ item }}" - with_first_found: - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_distribution | lower }}.yml" - - "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yml" - - "{{ ansible_os_family | lower }}.yml" + include_vars: "{{ lookup('first_found', params) }}" + vars: + params: + files: + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_version'].split('.')[0] }}.yml" + - "{{ ansible_facts['os_family'] | lower }}.yml" + paths: + - "{{ role_path }}/vars" tags: - always - - name: Ensure beat is installed package: name: "{{ packetbeat_distro_packages }}" state: "{{ elk_package_state | default('present') }}" - update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}" + update_cache: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('yes', omit) }}" register: _package_task until: _package_task is success retries: 3 diff --git a/elk_metrics_7x/roles/elastic_packetbeat/templates/packetbeat.yml.j2 b/elk_metrics_7x/roles/elastic_packetbeat/templates/packetbeat.yml.j2 index 06a6c29d..2f8bb70a 100644 --- a/elk_metrics_7x/roles/elastic_packetbeat/templates/packetbeat.yml.j2 +++ b/elk_metrics_7x/roles/elastic_packetbeat/templates/packetbeat.yml.j2 @@ -1101,7 +1101,7 @@ name: {{ elastic_hostname }} #kerberos.realm: ELASTIC # ------------------------------ Logstash Output ------------------------------- -{{ elk_macros.output_logstash(inventory_hostname, logstash_data_hosts, ansible_processor_count) }} +{{ elk_macros.output_logstash(inventory_hostname, logstash_data_hosts, ansible_facts['processor_count']) }} # -------------------------------- Kafka Output -------------------------------- #output.kafka: @@ -1578,7 +1578,7 @@ setup.ilm.policy_file: "{{ ilm_policy_file_location }}/{{ ilm_policy_filename }} {{ elk_macros.beat_logging('packetbeat', packetbeat_log_level) }} # ============================= X-Pack Monitoring ============================== -{{ elk_macros.xpack_monitoring_elasticsearch('packetbeat', inventory_hostname, elasticsearch_data_hosts, ansible_processor_count, beats_system_username, elastic_cluster_uuid) }} +{{ elk_macros.xpack_monitoring_elasticsearch('packetbeat', inventory_hostname, elasticsearch_data_hosts, ansible_facts['processor_count'], beats_system_username, elastic_cluster_uuid) }} # =============================== HTTP Endpoint ================================ diff --git a/elk_metrics_7x/roles/elastic_repositories/tasks/main.yml b/elk_metrics_7x/roles/elastic_repositories/tasks/main.yml index b5eee5d5..15a1af62 100644 --- a/elk_metrics_7x/roles/elastic_repositories/tasks/main.yml +++ b/elk_metrics_7x/roles/elastic_repositories/tasks/main.yml @@ -14,14 +14,18 @@ # limitations under the License. - name: Gather variables for each operating system - include_vars: "{{ item }}" - with_first_found: - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_distribution | lower }}.yml" - - "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yml" - - "{{ ansible_os_family | lower }}.yml" + include_vars: "{{ lookup('first_found', params) }}" + vars: + params: + files: + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_version'].split('.')[0] }}.yml" + - "{{ ansible_facts['os_family'] | lower }}.yml" + paths: + - "{{ role_path }}/vars" tags: - always @@ -29,7 +33,7 @@ package: name: "{{ elastic_repo_distro_packages }}" state: present - update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}" + update_cache: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('yes', omit) }}" register: _apt_task until: _apt_task is success retries: 3 @@ -37,4 +41,4 @@ tags: - package_install -- include_tasks: "elastic_{{ ansible_pkg_mgr }}_repos.yml" +- include_tasks: "elastic_{{ ansible_facts['pkg_mgr'] }}_repos.yml" diff --git a/elk_metrics_7x/roles/elasticsearch/tasks/main.yml b/elk_metrics_7x/roles/elasticsearch/tasks/main.yml index 5152d7cf..2cc13ef3 100644 --- a/elk_metrics_7x/roles/elasticsearch/tasks/main.yml +++ b/elk_metrics_7x/roles/elasticsearch/tasks/main.yml @@ -14,14 +14,18 @@ # limitations under the License. - name: Gather variables for each operating system - include_vars: "{{ item }}" - with_first_found: - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_distribution | lower }}.yml" - - "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yml" - - "{{ ansible_os_family | lower }}.yml" + include_vars: "{{ lookup('first_found', params) }}" + vars: + params: + files: + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_version'].split('.')[0] }}.yml" + - "{{ ansible_facts['os_family'] | lower }}.yml" + paths: + - "{{ role_path }}/vars" tags: - always @@ -34,7 +38,7 @@ package: name: "{{ elasticsearch_distro_packages }}" state: "{{ elk_package_state | default('present') }}" - update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}" + update_cache: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('yes', omit) }}" register: _package_task until: _package_task is success retries: 3 diff --git a/elk_metrics_7x/roles/elasticsearch/vars/vars_kibana.yml b/elk_metrics_7x/roles/elasticsearch/vars/vars_kibana.yml index f76d67cc..b1381ead 100644 --- a/elk_metrics_7x/roles/elasticsearch/vars/vars_kibana.yml +++ b/elk_metrics_7x/roles/elasticsearch/vars/vars_kibana.yml @@ -21,6 +21,6 @@ elastic_coordination_node: true # This variable is redefined because kibana runs elasticsearch but only in a # load balancer capacity. -elastic_processors_half: "{{ ((ansible_processor_count | int) // 2) }}" +elastic_processors_half: "{{ ((ansible_facts['processor_count'] | int) // 2) }}" elastic_processors_half_set: "{{ ((elastic_processors_half | int) > 0) | ternary(elastic_processors_half, 1) }}" elastic_thread_pool_size: "{{ ((elastic_processors_half_set | int) > 4) | ternary(4, elastic_processors_half_set) }}" diff --git a/elk_metrics_7x/setupKibanaDashboard.yml b/elk_metrics_7x/setupKibanaDashboard.yml index 0848695e..65d5c887 100644 --- a/elk_metrics_7x/setupKibanaDashboard.yml +++ b/elk_metrics_7x/setupKibanaDashboard.yml @@ -30,7 +30,7 @@ - name: Add nodejs 6.x source shell: "curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -" when: - - ansible_pkg_mgr == 'apt' + - ansible_facts['pkg_mgr'] == 'apt' - ossec_nodejs_repo is not defined - name: Manual nodejs installation @@ -54,14 +54,14 @@ retries: 3 delay: 2 when: - - ansible_pkg_mgr == 'apt' + - ansible_facts['pkg_mgr'] == 'apt' - ossec_nodejs_repo is defined - name: Install nodejs package: - name: "{{ distro_packages[ansible_pkg_mgr] }}" + name: "{{ distro_packages[ansible_facts['pkg_mgr']] }}" state: "{{ elk_package_state | default('present') }}" - update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}" + update_cache: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('yes', omit) }}" register: _pkg_task until: _pkg_task is success retries: 3 diff --git a/elk_metrics_7x/tests/_container-setup.yml b/elk_metrics_7x/tests/_container-setup.yml index a1b724c7..44ce254e 100644 --- a/elk_metrics_7x/tests/_container-setup.yml +++ b/elk_metrics_7x/tests/_container-setup.yml @@ -31,7 +31,7 @@ pre_tasks: - name: Ensure root ssh key user: - name: "{{ ansible_env.USER | default('root') }}" + name: "{{ ansible_facts['env']['USER'] | default('root') }}" generate_ssh_key: "yes" ssh_key_bits: 2048 ssh_key_file: ".ssh/id_rsa" @@ -47,7 +47,7 @@ - name: Ensure public ssh key is in authorized_keys authorized_key: - user: "{{ ansible_env.USER | default('root') }}" + user: "{{ ansible_facts['env']['USER'] | default('root') }}" key: "{{ nspawn_container_ssh_key }}" manage_dir: no diff --git a/elk_metrics_7x/tests/_key-setup.yml b/elk_metrics_7x/tests/_key-setup.yml index 8376ed35..f50896ba 100644 --- a/elk_metrics_7x/tests/_key-setup.yml +++ b/elk_metrics_7x/tests/_key-setup.yml @@ -20,7 +20,7 @@ tasks: - name: Ensure root ssh key user: - name: "{{ ansible_env.USER | default('root') }}" + name: "{{ ansible_facts['env']['USER'] | default('root') }}" generate_ssh_key: "yes" ssh_key_bits: 2048 ssh_key_file: ".ssh/id_rsa" @@ -36,6 +36,6 @@ - name: Ensure public ssh key is in authorized_keys authorized_key: - user: "{{ ansible_env.USER | default('root') }}" + user: "{{ ansible_facts['env']['USER'] | default('root') }}" key: "{{ nspawn_container_ssh_key }}" manage_dir: no diff --git a/elk_metrics_7x/tests/functional.yml b/elk_metrics_7x/tests/functional.yml index 730bef83..886b29bb 100644 --- a/elk_metrics_7x/tests/functional.yml +++ b/elk_metrics_7x/tests/functional.yml @@ -88,7 +88,7 @@ apt: update_cache: yes when: - - ansible_pkg_mgr == 'apt' + - ansible_facts['pkg_mgr'] == 'apt' tasks: - name: Run embedded ansible installation @@ -135,7 +135,7 @@ args: chdir: "src/{{ current_test_repo }}/elk_metrics_7x/tests" when: - - ansible_service_mgr != 'systemd' or + - ansible_facts['service_mgr'] != 'systemd' or not (container_inventory | bool) - name: Run environment setup @@ -147,14 +147,14 @@ args: chdir: "src/{{ current_test_repo }}/elk_metrics_7x/tests" when: - - ansible_service_mgr == 'systemd' + - ansible_facts['service_mgr'] == 'systemd' - container_inventory | bool - name: Wait 15 seconds command: "sleep 15" changed_when: false when: - - ansible_service_mgr == 'systemd' + - ansible_facts['service_mgr'] == 'systemd' - name: Run functional test become: yes diff --git a/elk_metrics_7x/tests/inventory/test-container-inventory.yml b/elk_metrics_7x/tests/inventory/test-container-inventory.yml index a9b56295..35b36cfa 100644 --- a/elk_metrics_7x/tests/inventory/test-container-inventory.yml +++ b/elk_metrics_7x/tests/inventory/test-container-inventory.yml @@ -15,7 +15,7 @@ hosts: management_address: address: "172.29.236.1" netmask: "255.255.255.0" - bridge: "{{ hostvars[physical_host]['ansible_default_ipv4']['alias'] }}" + bridge: "{{ hostvars[physical_host]['ansible_facts']['default_ipv4']['alias'] }}" all_containers: @@ -26,7 +26,7 @@ all_containers: management_address: address: "{{ ansible_host }}" netmask: "255.255.255.0" - bridge: "{{ hostvars[physical_host]['ansible_default_ipv4']['alias'] }}" + bridge: "{{ hostvars[physical_host]['ansible_facts']['default_ipv4']['alias'] }}" # CI nodes havee limited resources, locking the memory is impossible. elastic_memory_lock: false diff --git a/elk_metrics_7x/tests/post-run.yml b/elk_metrics_7x/tests/post-run.yml index 2d38425c..b8b3ed5c 100644 --- a/elk_metrics_7x/tests/post-run.yml +++ b/elk_metrics_7x/tests/post-run.yml @@ -32,7 +32,7 @@ RUN_ARA: "true" # Some Zuul environments (such as OpenStack CI) use html based ara reports ARA_REPORT_TYPE: "{{ ara_report_type | default('database') }}" - WORKING_DIR: "{{ ansible_user_dir }}/src/opendev.org/openstack/openstack-ansible-ops/" + WORKING_DIR: "{{ ansible_facts['user_dir'] }}/src/opendev.org/openstack/openstack-ansible-ops/" LOGGING_DIR: "/tmp/elk-metrics-7x-logs" - name: Copy logs back to the executor diff --git a/elk_metrics_7x/tests/run-setup.yml b/elk_metrics_7x/tests/run-setup.yml index d60eb8b3..096b9ebf 100644 --- a/elk_metrics_7x/tests/run-setup.yml +++ b/elk_metrics_7x/tests/run-setup.yml @@ -23,7 +23,7 @@ canonical_name: "openstack-ansible-ops" short_name: "ops" executor: - log_root: "{{ ansible_env.HOME }}/elk-test-logs" + log_root: "{{ ansible_facts['env']['HOME'] }}/elk-test-logs" when: - zuul is not defined diff --git a/elk_metrics_7x/vars/variables.yml b/elk_metrics_7x/vars/variables.yml index 9e01942a..a189eb32 100644 --- a/elk_metrics_7x/vars/variables.yml +++ b/elk_metrics_7x/vars/variables.yml @@ -1,9 +1,9 @@ --- -elastic_memory_lower_limit: "{{ (((ansible_memtotal_mb | int) * 0.15) // 1) | int }}" -elastic_memory_upper_limit: "{{ (((ansible_memtotal_mb | int) * 0.35) // 1) | int }}" +elastic_memory_lower_limit: "{{ (((ansible_facts['memtotal_mb'] | int) * 0.15) // 1) | int }}" +elastic_memory_upper_limit: "{{ (((ansible_facts['memtotal_mb'] | int) * 0.35) // 1) | int }}" # Option to set persistent queue storage in gigabytes -q_storage: "{{ (ansible_processor_count | int) * (ansible_processor_threads_per_core | int) * 2 }}" +q_storage: "{{ (ansible_facts['processor_count'] | int) * (ansible_facts['processor_threads_per_core'] | int) * 2 }}" apm_port: 8200 elastic_port: 9200