running an ansible local task in a remote playbook


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


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 …


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:


Leave a Reply