Skip to content

Commit eba702c

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Make setup module arguments configurable" into stable/wallaby
2 parents 52e3d44 + feb274b commit eba702c

File tree

5 files changed

+87
-2
lines changed

5 files changed

+87
-2
lines changed

ansible/gather-facts.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@
55
- name: Gather facts for all hosts
66
hosts: all
77
serial: '{{ kolla_serial|default("0") }}'
8-
gather_facts: true
8+
gather_facts: false
99
tasks:
10+
- name: Gather facts
11+
setup:
12+
filter: "{{ kolla_ansible_setup_filter }}"
13+
gather_subset: "{{ kolla_ansible_setup_gather_subset }}"
14+
when:
15+
- not ansible_facts
16+
1017
- name: Group hosts to determine when using --limit
1118
group_by:
1219
key: "all_using_limit_{{ (ansible_play_batch | length) != (groups['all'] | length) }}"
@@ -32,10 +39,12 @@
3239
tasks:
3340
- name: Gather facts
3441
setup:
42+
filter: "{{ kolla_ansible_setup_filter }}"
43+
gather_subset: "{{ kolla_ansible_setup_gather_subset }}"
3544
delegate_facts: True
3645
delegate_to: "{{ item }}"
3746
with_items: "{{ delegate_hosts }}"
3847
# We gathered facts for all hosts in the batch during the first play.
3948
when:
40-
- not hostvars[item].ansible_facts.module_setup | default(false)
49+
- not hostvars[item].ansible_facts
4150
tags: always

ansible/group_vars/all.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,21 @@ node_config_directory: "/etc/kolla"
2020
config_owner_user: "root"
2121
config_owner_group: "root"
2222

23+
###################
24+
# Ansible options
25+
###################
26+
27+
# This variable is used as the "filter" argument for the setup module. For
28+
# instance, if one wants to remove/ignore all Neutron interface facts:
29+
# kolla_ansible_setup_filter: "ansible_[!qt]*"
30+
# By default, we do not provide a filter.
31+
kolla_ansible_setup_filter: "{{ omit }}"
32+
33+
# This variable is used as the "gather_subset" argument for the setup module.
34+
# For instance, if one wants to avoid collecting facts via facter:
35+
# kolla_ansible_setup_gather_subset: "all,!facter"
36+
# By default, we do not provide a gather subset.
37+
kolla_ansible_setup_gather_subset: "{{ omit }}"
2338

2439
###################
2540
# Kolla options

doc/source/user/ansible-tuning.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,40 @@ disable fact variable injection.
8383
8484
[defaults]
8585
inject_facts_as_vars = False
86+
87+
Fact filtering
88+
--------------
89+
90+
Ansible facts filtering can be used to speed up Ansible. Environments with
91+
many network interfaces on the network and compute nodes can experience very
92+
slow processing with Kolla Ansible. This happens due to the processing of the
93+
large per-interface facts with each task. To avoid storing certain facts, we
94+
can use the ``kolla_ansible_setup_filter`` variable, which is used as the
95+
``filter`` argument to the ``setup`` module. For example, to avoid collecting
96+
facts for virtual interfaces beginning with q or t:
97+
98+
.. code-block:: yaml
99+
100+
kolla_ansible_setup_filter: "ansible_[!qt]*"
101+
102+
This causes Ansible to collect but not store facts matching that pattern, which
103+
includes the virtual interface facts. Currently we are not referencing other
104+
facts matching the pattern within Kolla Ansible. Note that including the
105+
``ansible_`` prefix causes meta facts ``module_setup`` and ``gather_subset`` to
106+
be filtered, but this seems to be the only way to get a good match on the
107+
interface facts.
108+
109+
The exact improvement will vary, but has been reported to be as large as 18x on
110+
systems with many virtual interfaces.
111+
112+
Fact gathering subsets
113+
----------------------
114+
115+
It is also possible to configure which subsets of facts are gathered, via
116+
``kolla_ansible_setup_gather_subset``, which is used as the ``gather_subset``
117+
argument to the ``setup`` module. For example, if one wants to avoid collecting
118+
facts via facter:
119+
120+
.. code-block:: yaml
121+
122+
kolla_ansible_setup_gather_subset: "all,!facter"

etc/kolla/globals.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@
55
# commented parameters are shown here, To override the default value uncomment
66
# the parameter and change its value.
77

8+
###################
9+
# Ansible options
10+
###################
11+
12+
# This variable is used as the "filter" argument for the setup module. For
13+
# instance, if one wants to remove/ignore all Neutron interface facts:
14+
# kolla_ansible_setup_filter: "ansible_[!qt]*"
15+
# By default, we do not provide a filter.
16+
#kolla_ansible_setup_filter: "{{ omit }}"
17+
18+
# This variable is used as the "gather_subset" argument for the setup module.
19+
# For instance, if one wants to avoid collecting facts via facter:
20+
# kolla_ansible_setup_gather_subset: "all,!facter"
21+
# By default, we do not provide a gather subset.
22+
#kolla_ansible_setup_gather_subset: "{{ omit }}"
23+
824
###############
925
# Kolla options
1026
###############
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
features:
3+
- |
4+
Adds support for configuring the ``filter`` and ``gather_subset`` arguments
5+
for the ``setup`` module via ``kolla_ansible_setup_filter`` and
6+
``kolla_ansible_setup_gather_subset`` respectively. These can be used to
7+
reduce the number of facts, which can have a significant effect on
8+
performance of Ansible.

0 commit comments

Comments
 (0)