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

后端 未结 3 2180
南旧
南旧 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:37

    Ansible has a local_action directive to support these scenarios which avoids the localhost and/or ansible_connection workarounds and is covered in the Delegation docs.

    To modify your original example to use local_action:

    - name: create some file
        local_action: template src=~/workspace/ansible_templates/somefile_template.j2 dest=/etc/somefile/apps-available/someproject.ini
    

    which looks cleaner.

提交回复
热议问题