How can I detect if an Ansible playbook is executed by ansible-pull rather than ansible-playbook?

HOW TO -️ October 18, 2021

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

Answer

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.

Initializing...