Ansible - Run tasks on the control node
by
Jeremy Canfield |
Updated: January 07 2022
| Ansible articles
By default, certain tasks will be run on the control node (that's your Ansible server) or on your managed nodes (the target systems). For example:
- Lookup is run on the control node
- Modules are run on your managed nodes
There are different ways to modify this behavior. The following can be used to invoke a module on the control node (that's your Ansible server).
- local_action to run specific tasks on the control node
- delegate_to parameter to run specific tasks on the control node
- connection parameter or --connection command line option to run all tasks in a playbook or specific roles on the control node
Or, it you can set -hosts: localhost in your playbook to run the playbook against the control node.
---
- hosts: localhost
tasks:
- debug:
msg: Hello World
...
Did you find this article helpful?
If so, consider buying me a coffee over at