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


i'm starting out ansible , i'm looking way create boilerplate project on server , on local environment ansible playbooks.

i want use ansible templates locally create generic files. how take ansible execute locally?

i read local_action guess did not right.

this webbserver...but how take , create files locally?


- hosts: webservers       remote_user: someuser - name: create file     template: src=~/workspace/ansible_templates/somefile_template.j2 dest=/etc/somefile/apps-available/someproject.ini 

you can delegate tasks param delegate_to host like, example:

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

see playbook delegation in docs.

if playbook should in general run locally , no external hosts involved though, can create group contains localhost , run playbook against group. in inventory:

[local] localhost 

and in playbook:

hosts: local 

Comments