Ansible local_action directive

后端 未结 2 992
清酒与你
清酒与你 2021-02-19 02:12

I\'m quite new to Ansible and have a simple question for my understanding of local_action directive.

Would that mean that the command is fully executed loca

相关标签:
2条回答
  • 2021-02-19 03:05

    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
    
    0 讨论(0)
  • 2021-02-19 03:14

    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.

    0 讨论(0)
提交回复
热议问题