
By default, Ansible injects a variable for every fact, prefixed with ansible_. This can result in a large number of variables for each host, which at scale can incur a performance penalty. Ansible provides a configuration option [0] that can be set to False to prevent this injection of facts. In this case, facts should be referenced via ansible_facts.<fact>. This change updates all references to Ansible facts within Kayobe from using individual fact variables to using the items in the ansible_facts dictionary. This allows users to disable fact variable injection in their Ansible configuration, which may provide some performance improvement. This change disables fact variable injection in the ansible configuration used in CI, to catch any attempts to use the injected variables. [0] https://docs.ansible.com/ansible/latest/reference_appendices/config.html#inject-facts-as-vars Story: 2007993 Task: 42464 Depends-On: https://review.opendev.org/c/openstack/kolla-ansible/+/791276 Change-Id: I14db53ed6e57d37bbd28dd5819e432e3fe6628b2
2.7 KiB
Ansible
Ansible configuration is described in detail in the Ansible
documentation. It is explained elsewhere in this guide how to
configure Ansible for Kayobe <configuration-kayobe-ansible>
and Kolla Ansible
<configuration-kolla-ansible-ansible>
.
In this section we cover some options for tuning Ansible for performance and scale.
SSH pipelining
SSH pipelining is disabled in Ansible by default, but is generally safe to enable, and provides a reasonable performance improvement.
[ssh_connection]
pipelining = True
Forks
By default Ansible executes tasks using a fairly conservative 5 process forks. This limits the parallelism that allows Ansible to scale. Most Ansible control hosts will be able to handle far more forks than this. You will need to experiment to find out the CPU, memory and IO limits of your machine.
For example, to increase the number of forks to 20:
[defaults]
forks = 20
Fact caching
Note
Fact caching will not work correctly in Kayobe prior to the Ussuri release.
By default, Ansible gathers facts for each host at the beginning of
every play, unless gather_facts
is set to
false
. With a large number of hosts this can result in a
significant amount of time spent gathering facts.
One way to improve this is through Ansible's support for fact
caching. In order to make this work with Kayobe, it is necessary to
change Ansible's gathering
configuration option to smart
. Additionally, it is
necessary to use separate fact caches for Kayobe and Kolla Ansible due
to some of the facts (e.g. ansible_facts.user_uid
and
ansible_facts.python
) differing.
Example
In the following example we configure Kayobe and Kolla Ansible to use fact caching using the jsonfile cache plugin.
[defaults]
gathering = smart
fact_caching = jsonfile
fact_caching_connection = /tmp/kayobe-facts
[defaults]
gathering = smart
fact_caching = jsonfile
fact_caching_connection = /tmp/kolla-ansible-facts
You may also wish to set the expiration timeout for the cache via
[defaults] fact_caching_timeout
.