summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSloane Hertel <19572925+s-hertel@users.noreply.github.com>2024-11-06 17:40:15 +0100
committerGitHub <noreply@github.com>2024-11-06 17:40:15 +0100
commit157ef04b1e92105167e23b3bc0ab1432c0ff30f3 (patch)
tree49ffab9dda32db4e05ebbe36e83c7a157722d589
parentupdate ansible-galaxy resolvelib requirement to >= 0.5.3, < 2.0.0 (#84218) (diff)
downloadansible-157ef04b1e92105167e23b3bc0ab1432c0ff30f3.tar.xz
ansible-157ef04b1e92105167e23b3bc0ab1432c0ff30f3.zip
Add --flush-cache option to ansible-pull (#84211)
-rw-r--r--changelogs/fragments/84149-add-flush-cache-for-adhoc-commands.yml3
-rwxr-xr-xlib/ansible/cli/pull.py3
-rw-r--r--test/integration/targets/ansible-pull/pull-integration-test/gather_facts.yml2
-rw-r--r--test/integration/targets/ansible-pull/pull-integration-test/test_empty_facts.yml5
-rwxr-xr-xtest/integration/targets/ansible-pull/runme.sh6
5 files changed, 18 insertions, 1 deletions
diff --git a/changelogs/fragments/84149-add-flush-cache-for-adhoc-commands.yml b/changelogs/fragments/84149-add-flush-cache-for-adhoc-commands.yml
index 9f407a9a0d..854d2628b6 100644
--- a/changelogs/fragments/84149-add-flush-cache-for-adhoc-commands.yml
+++ b/changelogs/fragments/84149-add-flush-cache-for-adhoc-commands.yml
@@ -1,2 +1,3 @@
minor_changes:
- - ansible cli - add --flush-cache option for ad-hoc commands (https://github.com/ansible/ansible/issues/83749).
+- >
+ ansible, ansible-console, ansible-pull - add --flush-cache option (https://github.com/ansible/ansible/issues/83749).
diff --git a/lib/ansible/cli/pull.py b/lib/ansible/cli/pull.py
index 212d63872e..ee24c9ff9a 100755
--- a/lib/ansible/cli/pull.py
+++ b/lib/ansible/cli/pull.py
@@ -298,6 +298,9 @@ class PullCLI(CLI):
if context.CLIARGS['diff']:
cmd += ' -D'
+ if context.CLIARGS['flush_cache']:
+ cmd += ' --flush-cache'
+
os.chdir(context.CLIARGS['dest'])
# redo inventory options as new files might exist now
diff --git a/test/integration/targets/ansible-pull/pull-integration-test/gather_facts.yml b/test/integration/targets/ansible-pull/pull-integration-test/gather_facts.yml
new file mode 100644
index 0000000000..25305703c7
--- /dev/null
+++ b/test/integration/targets/ansible-pull/pull-integration-test/gather_facts.yml
@@ -0,0 +1,2 @@
+- hosts: localhost
+ gather_facts: true
diff --git a/test/integration/targets/ansible-pull/pull-integration-test/test_empty_facts.yml b/test/integration/targets/ansible-pull/pull-integration-test/test_empty_facts.yml
new file mode 100644
index 0000000000..ab7559854b
--- /dev/null
+++ b/test/integration/targets/ansible-pull/pull-integration-test/test_empty_facts.yml
@@ -0,0 +1,5 @@
+- hosts: localhost
+ gather_facts: false
+ tasks:
+ - assert:
+ that: ansible_facts == {}
diff --git a/test/integration/targets/ansible-pull/runme.sh b/test/integration/targets/ansible-pull/runme.sh
index b591b283dc..fd97c707f0 100755
--- a/test/integration/targets/ansible-pull/runme.sh
+++ b/test/integration/targets/ansible-pull/runme.sh
@@ -91,3 +91,9 @@ ANSIBLE_CONFIG='' ansible-pull -d "${pull_dir}" -U "${repo_dir}" conn_secret.yml
# fail if we try do delete /var/tmp
ANSIBLE_CONFIG='' ansible-pull -d var/tmp -U "${repo_dir}" --purge "$@"
+
+# test flushing the fact cache
+export ANSIBLE_CACHE_PLUGIN=jsonfile ANSIBLE_CACHE_PLUGIN_CONNECTION=./
+ansible-pull -d "${pull_dir}" -U "${repo_dir}" "$@" gather_facts.yml
+ansible-pull -d "${pull_dir}" -U "${repo_dir}" --flush-cache "$@" test_empty_facts.yml
+unset ANSIBLE_CACHE_PLUGIN ANSIBLE_CACHE_PLUGIN_CONNECTION