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


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 use ansible templates locally to create some generic files.
But how would i take ansible to execute something locally?

I read something with local_action but i guess i did not get this right.

This is for the webbserver…but how do i take this and create some files locally?


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

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:

and then in your playbook:

Leave a Reply