Skip to content
Snippets Groups Projects
Commit a43b815b authored by Zuul's avatar Zuul Committed by Gerrit Code Review
Browse files

Merge "Make setup module arguments configurable"

parents 37601e2b 15f2fdcd
No related branches found
No related tags found
No related merge requests found
...@@ -5,8 +5,15 @@ ...@@ -5,8 +5,15 @@
- name: Gather facts for all hosts - name: Gather facts for all hosts
hosts: all hosts: all
serial: '{{ kolla_serial|default("0") }}' serial: '{{ kolla_serial|default("0") }}'
gather_facts: true gather_facts: false
tasks: tasks:
- name: Gather facts
setup:
filter: "{{ kolla_ansible_setup_filter }}"
gather_subset: "{{ kolla_ansible_setup_gather_subset }}"
when:
- not ansible_facts
- name: Group hosts to determine when using --limit - name: Group hosts to determine when using --limit
group_by: group_by:
key: "all_using_limit_{{ (ansible_play_batch | length) != (groups['all'] | length) }}" key: "all_using_limit_{{ (ansible_play_batch | length) != (groups['all'] | length) }}"
...@@ -32,10 +39,12 @@ ...@@ -32,10 +39,12 @@
tasks: tasks:
- name: Gather facts - name: Gather facts
setup: setup:
filter: "{{ kolla_ansible_setup_filter }}"
gather_subset: "{{ kolla_ansible_setup_gather_subset }}"
delegate_facts: True delegate_facts: True
delegate_to: "{{ item }}" delegate_to: "{{ item }}"
with_items: "{{ delegate_hosts }}" with_items: "{{ delegate_hosts }}"
# We gathered facts for all hosts in the batch during the first play. # We gathered facts for all hosts in the batch during the first play.
when: when:
- not hostvars[item].ansible_facts.module_setup | default(false) - not hostvars[item].ansible_facts
tags: always tags: always
...@@ -20,6 +20,21 @@ node_config_directory: "/etc/kolla" ...@@ -20,6 +20,21 @@ node_config_directory: "/etc/kolla"
config_owner_user: "root" config_owner_user: "root"
config_owner_group: "root" config_owner_group: "root"
###################
# Ansible options
###################
# This variable is used as the "filter" argument for the setup module. For
# instance, if one wants to remove/ignore all Neutron interface facts:
# kolla_ansible_setup_filter: "ansible_[!qt]*"
# By default, we do not provide a filter.
kolla_ansible_setup_filter: "{{ omit }}"
# This variable is used as the "gather_subset" argument for the setup module.
# For instance, if one wants to avoid collecting facts via facter:
# kolla_ansible_setup_gather_subset: "all,!facter"
# By default, we do not provide a gather subset.
kolla_ansible_setup_gather_subset: "{{ omit }}"
################### ###################
# Kolla options # Kolla options
......
...@@ -83,3 +83,40 @@ disable fact variable injection. ...@@ -83,3 +83,40 @@ disable fact variable injection.
[defaults] [defaults]
inject_facts_as_vars = False inject_facts_as_vars = False
Fact filtering
--------------
Ansible facts filtering can be used to speed up Ansible. Environments with
many network interfaces on the network and compute nodes can experience very
slow processing with Kolla Ansible. This happens due to the processing of the
large per-interface facts with each task. To avoid storing certain facts, we
can use the ``kolla_ansible_setup_filter`` variable, which is used as the
``filter`` argument to the ``setup`` module. For example, to avoid collecting
facts for virtual interfaces beginning with q or t:
.. code-block:: yaml
kolla_ansible_setup_filter: "ansible_[!qt]*"
This causes Ansible to collect but not store facts matching that pattern, which
includes the virtual interface facts. Currently we are not referencing other
facts matching the pattern within Kolla Ansible. Note that including the
``ansible_`` prefix causes meta facts ``module_setup`` and ``gather_subset`` to
be filtered, but this seems to be the only way to get a good match on the
interface facts.
The exact improvement will vary, but has been reported to be as large as 18x on
systems with many virtual interfaces.
Fact gathering subsets
----------------------
It is also possible to configure which subsets of facts are gathered, via
``kolla_ansible_setup_gather_subset``, which is used as the ``gather_subset``
argument to the ``setup`` module. For example, if one wants to avoid collecting
facts via facter:
.. code-block:: yaml
kolla_ansible_setup_gather_subset: "all,!facter"
...@@ -5,6 +5,22 @@ ...@@ -5,6 +5,22 @@
# commented parameters are shown here, To override the default value uncomment # commented parameters are shown here, To override the default value uncomment
# the parameter and change its value. # the parameter and change its value.
###################
# Ansible options
###################
# This variable is used as the "filter" argument for the setup module. For
# instance, if one wants to remove/ignore all Neutron interface facts:
# kolla_ansible_setup_filter: "ansible_[!qt]*"
# By default, we do not provide a filter.
#kolla_ansible_setup_filter: "{{ omit }}"
# This variable is used as the "gather_subset" argument for the setup module.
# For instance, if one wants to avoid collecting facts via facter:
# kolla_ansible_setup_gather_subset: "all,!facter"
# By default, we do not provide a gather subset.
#kolla_ansible_setup_gather_subset: "{{ omit }}"
############### ###############
# Kolla options # Kolla options
############### ###############
......
---
features:
- |
Adds support for configuring the ``filter`` and ``gather_subset`` arguments
for the ``setup`` module via ``kolla_ansible_setup_filter`` and
``kolla_ansible_setup_gather_subset`` respectively. These can be used to
reduce the number of facts, which can have a significant effect on
performance of Ansible.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment