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

You can delegate tasks with the param delegate_to to any host you like, for example:

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

See Playbook Delegation in the docs.

If your playbook should in general run locally and no external hosts are involved though, you can simply create a group which contains localhost and then run the playbook against this group. In your inventory:

[local]
localhost   ansible_connection=local

and then in your playbook:

hosts: local

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)