Templates - Create, but do NOT update

26 views
Skip to first unread message

Akos Vandra

unread,
Nov 5, 2014, 11:44:07 PM11/5/14
to ansible-project
Hello,

This might be a wierd feature request at first, but would you accept a PR to add an option to the template module to create but do NOT update the generated file?

I find myself needing this when generating secrets.
I do want to generate my secret file if it does not exists (and it needs to be generated to a form dictated by a template), but I do not want to change its contents which is usually generated by a PRNG.

Regards,
  Akos Vandra

James Martin

unread,
Nov 5, 2014, 11:48:58 PM11/5/14
to ansible...@googlegroups.com
You could stat the file using the stat module to see if it exists and register it's result, then run your template task conditionally, only if the file does not exist.

James Cammarata

unread,
Nov 7, 2014, 10:43:44 AM11/7/14
to ansible...@googlegroups.com
Hi Akos,

The template module (being part of the file module family), does support the use of `force=no`, meaning the file will not be replaced if it already exists. This is not documented on that modules page, which we will get updated.

Thanks!

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAHHcNoeB3pGR8W77gPoFk6wExKSAH8F%2Bym1YdCHsx2ocS9GUMA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages