mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
9687879840
* Replace InventoryFileCacheModule with a better developer-interface Use new interface for inventory plugins with backwards compatibility Auto-update the backing cache-plugin if the cache has changed after parsing the inventory plugin * Update CacheModules to use the config system and add a deprecation warning if they are being imported directly rather than using cache_loader * Fix foreman inventory caching * Add tests * Add integration test to check that fact caching works normally with cache plugins using ansible.constants and inventory caching provides a helpful error for non-compatible cache plugins * Add some developer documentation for inventory and cache plugins * Add user documentation for inventory caching * Add deprecation docs * Apply suggestions from docs review * Add changelog
44 lines
1.2 KiB
Bash
Executable file
44 lines
1.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
[[ -n "$DEBUG" || -n "$ANSIBLE_DEBUG" ]] && set -x
|
|
|
|
set -euo pipefail
|
|
|
|
export ANSIBLE_CONFIG=ansible.cfg
|
|
export FOREMAN_HOST="${FOREMAN_HOST:-localhost}"
|
|
export FOREMAN_PORT="${FOREMAN_PORT:-8080}"
|
|
FOREMAN_CONFIG=test-config.foreman.yaml
|
|
|
|
# Set inventory caching environment variables to populate a jsonfile cache
|
|
export ANSIBLE_INVENTORY_CACHE=True
|
|
export ANSIBLE_INVENTORY_CACHE_PLUGIN=jsonfile
|
|
export ANSIBLE_INVENTORY_CACHE_CONNECTION=./foreman_cache
|
|
|
|
# flag for checking whether cleanup has already fired
|
|
_is_clean=
|
|
|
|
function _cleanup() {
|
|
[[ -n "$_is_clean" ]] && return # don't double-clean
|
|
echo Cleanup: removing $FOREMAN_CONFIG...
|
|
rm -vf "$FOREMAN_CONFIG"
|
|
unset ANSIBLE_CONFIG
|
|
unset FOREMAN_HOST
|
|
unset FOREMAN_PORT
|
|
unset FOREMAN_CONFIG
|
|
_is_clean=1
|
|
}
|
|
trap _cleanup INT TERM EXIT
|
|
|
|
cat > "$FOREMAN_CONFIG" <<FOREMAN_YAML
|
|
plugin: foreman
|
|
url: http://${FOREMAN_HOST}:${FOREMAN_PORT}
|
|
user: ansible-tester
|
|
password: secure
|
|
validate_certs: False
|
|
FOREMAN_YAML
|
|
|
|
ansible-playbook test_foreman_inventory.yml --connection=local "$@"
|
|
ansible-playbook inspect_cache.yml --connection=local "$@"
|
|
|
|
# remove inventory cache
|
|
rm -r ./foreman_cache
|