When using this SSH and SCP wrapper, even if BASTION_HOST, BASTION_PORT and BASTION_USER environment variables are defined, the ansible-inventory binary is called and takes 3 seconds each time. With a simple copy module, it can be called multiple times. It's not performant at all. The real Ansible inventory cache, defined by cache in the inventory section of the Ansible configuration, is ignored by the wrapper.
With this commit, there are two new optional environment variables:
BASTION_ANSIBLE_INV_CACHE_FILE: path to the cache file on the filesystem
BASTION_ANSIBLE_INV_CACHE_TIMEOUT: number of seconds before refreshing the cache
If the BASTION_ANSIBLE_INV_CACHE_FILE environment variable is defined, the wrapper will save the inventory content to this file with an updated_at timestamp. The BASTION_ANSIBLE_INV_CACHE_TIMEOUT (default to 60 seconds) is used to remove the file based on the current time and the updated_at information (cache invalidation).
On our infrastructure, with the following playbook:
Hello folks!
When using this SSH and SCP wrapper, even if
BASTION_HOST
,BASTION_PORT
andBASTION_USER
environment variables are defined, theansible-inventory
binary is called and takes 3 seconds each time. With a simplecopy
module, it can be called multiple times. It's not performant at all. The real Ansible inventory cache, defined bycache
in theinventory
section of the Ansible configuration, is ignored by the wrapper.With this commit, there are two new optional environment variables:
BASTION_ANSIBLE_INV_CACHE_FILE
: path to the cache file on the filesystemBASTION_ANSIBLE_INV_CACHE_TIMEOUT
: number of seconds before refreshing the cacheIf the
BASTION_ANSIBLE_INV_CACHE_FILE
environment variable is defined, the wrapper will save the inventory content to this file with anupdated_at
timestamp. TheBASTION_ANSIBLE_INV_CACHE_TIMEOUT
(default to 60 seconds) is used to remove the file based on the current time and theupdated_at
information (cache invalidation).On our infrastructure, with the following playbook:
We have reduced the global execution time:
I wish you to have a nice day