running an ansible local task in a remote playbook

前端 未结 1 1860
小鲜肉
小鲜肉 2021-02-18 18:30

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

- name: get the local repo\'s branch name
  local_action: git branch          


        
1条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-18 18:49

    The format for local_action is:

    local_action:  
    

    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:

    local_action: shell git branch | awk '/^\*/{print $2}'
    

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

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