FreeKB - Ansible local_action parameter
Ansible - local_action parameter

The local_action parameter can be used to run a task on the control node (that's your Ansible server). Some (but not all) modules will also accept the connection parameter, delegate_to parameter, or hostvars magic variable to run the task on the control node. 

In this example, the file module is used to remove a file on the control node.

- name: "remove foo.txt on control node"
    module: "file"
    path: "/tmp/foo.txt"
    state: "absent"


Running this task should produce the following.

TASK [remove foo.txt on control node] 
changed: [ -> localhost]


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter 410a1 in the box below so that we can be sure you are a human.


Web design by yours truely - me, myself, and I   |   |