The Ansible master playbook of the Kolla project is big and consists of a lot of playbooks. The fact gathering before each call of a playbook requires time. The required time depends on the size of the environment and is possibly not negligible.
Fact Caching , introduced in Ansible 1.8, helps avoid the side effects of excessive coffee consumption while waiting for the execution of actions. Ansible ships with two cache plugins: JSON and Redis. The following example highlights the Redis configuration.
Configuring Fact Caching
To set up Redis fact caching, proceed as follows on the Kolla deployment host.
- Start a Redis container :
$ dockerrun -d --nameredis -p 6379:6379 redis
- Install the Python client for Redis :
- Add the following code to the Ansible configuration file , e.g.
[defaults] gathering = smart fact_caching = redis fact_caching_timeout = 3600 fact_caching_connection = 127.0.0.1:6379:0
Testing Fact Caching
Use the following playbook for a quick test:
--- - hosts: all tasks: - debug: var=ansible_memtotal_mb - hosts: all tasks: - debug: var=ansible_memtotal_mb - hosts: all tasks: - debug: var=ansible_memtotal_mb - hosts: all tasks: - debug: var=ansible_memtotal_mb
Save the playbook to
testing.yml and run it with the inventory file of the Kolla environment. The execution time should be fairly short, once the facts have been initially cached prior to the first run.
$ ansible-playbook -i KOLLA-INVENTORY-FILEtesting.yml