Created
May 15, 2024 10:25
-
-
Save moreati/8c88021135e9fef03e0e7296ca697252 to your computer and use it in GitHub Desktop.
Different ways to execute Ansible tasks on the controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- hosts: targets | |
gather_facts: false | |
vars: | |
ansible_python_interpreter: python3 | |
tasks: | |
- command: echo hello | |
delegate_to: localhost | |
- command: echo hello | |
connection: local | |
- local_action: command echo hello |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TIL In addition to
delegate_to
andlocal_action
there is alsoconnection: local
to execute Ansible playbook on the controller, rather than the usual targets. It comes with its own set of caveats and quirks https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_delegation.html#local-playbooks