Ansible local_action directive

If you want to provide multiple parameters to the local action it will look something like this

local_action: 
  module: command
  _raw_params: "which nginx"
register: check_nginx
failed_when: no
changed_when: no

Yes, local_action is an alternative way of doing delegate_to: localhost.

These actions will be executed on local machine (Ansible control host), but still being in context of remote host in terms of variables. So you can something like this:

local_action: command ping -c 1 {{ inventory_hostname }}

which will ping every host in your play, but ping will be initiated from Ansible control host.

Tags:

Ansible