How to create a file locally with ansible templates on the development machine

后端 未结 3 2181
南旧
南旧 2021-02-18 14:18

I\'m starting out with ansible and I\'m looking for a way to create a boilerplate project on the server and on the local environment with ansible playbooks.

I want to us

3条回答
  •  我在风中等你
    2021-02-18 14:41

    If you cannot do/allow localhost SSH, you can split the playbook on local actions and remote actions.

    The connection: local says to not use SSH for a playbook, as shown here: http://docs.ansible.com/ansible/playbooks_delegation.html#local-playbooks

    Example:

    # myplaybook.yml
    
    - hosts: remote_machines
      tasks:
      - debug: msg="do stuff in the remote machines"
    
    - hosts: 127.0.0.1
      connection: local
      tasks:
      - debug: msg="ran in local ansible machine"
    
    - hosts: remote_machines
      tasks:
      - debug: msg="do more stuff in remote machines"
    

提交回复
热议问题