0

I am looking for a when condition which is fullfilled when the playbook is executed by ansible-pull.

1
  • I'm affraid you can't since ansible-pull actually runs ansible-playbook internally with no particular option once SCM checkout is done (run with -vvv to see the steps). If you use a specific directory on all your servers to clone your playbook repos from ansible-pull, you can eventually set a condition on the playbook_dir variable. This is way far from bulletproof though. Aug 14 at 21:12
1

I found two approaches to test if a playbook is applied via ansible-pull:

  1. Check for ansible_connection == "local". However this doesnt work in all places as local connections might also used regularily by your playbook.
  2. Pass an extra variable to the invocation: ansible-pull --extra-vars "ansible_pull=true"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.