diff --git a/scripts/run-validation b/scripts/run-validation index 0bf410d83..3bf01e641 100755 --- a/scripts/run-validation +++ b/scripts/run-validation @@ -30,6 +30,14 @@ export ANSIBLE_RETRY_FILES_ENABLED=False # Add `-E` to the sudo flags to preserve the shell environment. The `-H -S -n` # options are Ansible's default values. export ANSIBLE_SUDO_FLAGS="-H -S -n -E" +# Use a fact cache to improve performance +# The defaults from tripleo_common/actions/ansible.py cannot be used +# beause they will clash with the 'mistral' user owning the fact cache +# path. +export ANSIBLE_GATHERING=smart +export ANSIBLE_CACHE_PLUGIN=jsonfile +export ANSIBLE_CACHE_PLUGIN_CONNECTION=~/ansible_fact_cache +export ANSIBLE_GATHER_TIMEOUT=7200 # 7200s = 2h export ANSIBLE_PRIVATE_KEY_FILE=$IDENTITY_FILE diff --git a/tripleo_common/actions/ansible.py b/tripleo_common/actions/ansible.py index 4655db177..8fcd96972 100644 --- a/tripleo_common/actions/ansible.py +++ b/tripleo_common/actions/ansible.py @@ -46,6 +46,15 @@ def write_default_ansible_cfg(work_dir, config.set('defaults', 'timeout', '30') config.set('defaults', 'gather_timeout', '30') + # Setup fact cache to improve playbook execution speed + config.set('defaults', 'gathering', 'smart') + config.set('defaults', 'fact_caching', 'jsonfile') + config.set('defaults', 'fact_caching_connection', + '/var/tmp/ansible_fact_cache') + + # Expire facts in the fact cache after 7200s (2h) + config.set('defaults', 'fact_caching_timeout', '7200') + # mistral user has no home dir set, so no place to save a known hosts file config.set('ssh_connection', 'ssh_args', '-o UserKnownHostsFile=/dev/null '