Allow ELK7 roles to run with disabled ANSIBLE_INJECT_FACT_VARS

Enabling ANSIBLE_INJECT_FACT_VARS does result in a performance
regression as each variable loaded to runtime slows down task
execution.

We disable ANSIBLE_INJECT_FACT_VARS in OSA by default for a while,
so ELK role should also be able to run with this setting disabled.

Change-Id: Ibffc09cdb4f9289ddad38211ccb0265642b4321f
This commit is contained in:
Dmitriy Rabotyagov 2024-11-10 12:48:57 +01:00
parent d596f5d2b3
commit 1d52793ec6
34 changed files with 223 additions and 176 deletions

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -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

View File

@ -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 ================================

View File

@ -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

View File

@ -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.

View File

@ -21,7 +21,7 @@
#elastic_shared_fs_repos:
# - fstype: nfs4
# src: "<nfs-server-ip>:/esbackup"
# opts: clientaddr="{{ ansible_eth1['ipv4']['address'] }}"
# opts: clientaddr="{{ ansible_facts['eth1']['ipv4']['address'] }}"
# path: "/elastic-backup"
# state: mounted

View File

@ -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

View File

@ -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:

View File

@ -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 ================================

View File

@ -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

View File

@ -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 ================================

View File

@ -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

View File

@ -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 ================================

View File

@ -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

View File

@ -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

View File

@ -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:

View File

@ -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 }}
#

View File

@ -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 }}

View File

@ -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 <https://github.com/Go-SQL-Driver/MySQL/>.
# 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 ================================

View File

@ -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

View File

@ -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 ================================

View File

@ -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"

View File

@ -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

View File

@ -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) }}"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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