running an ansible local task in a remote playbook

Question:

I’m trying to get this task to run locally (on the machine that is running the playbook) :

I tried plenty of variations with no success

all other tasks are meant to run on the target host, which is why running the whole playbook local is not an option

update:

I have followed bkan’s suggestion (bellow), and got a bit further, but

now the git command gets launched but not correctly (see error below).

note that this command runs perfectly as a “shell” but unfortunately there is no local_shell equivalent of local_action …

Answer:

The format for local_action is:

In your example, Ansible thinks you are trying to use the git module and throws an error because you don’t have the correct arguments for the git module. Here is how it should look:

Source: http://docs.ansible.com/playbooks_delegation.html#delegation

Leave a Reply