How to keep templated files around following a run in check mode?

43 views
Skip to first unread message

Adam DeConinck

unread,
Jul 26, 2016, 6:06:17 PM7/26/16
to ansible...@googlegroups.com
Hi all,

The template module supports the --check and --diff options so you can see what changes would be made to a file without actually making the live change. For example, if I use a simple template to insert "hello world" in a file, I might get output that looks like:


TASK [template] ****************************************************************
changed: [localhost]
--- before
+++ after: dynamically generated
@@ -0,0 +1 @@
+hello world


However, while Ansible is clearly generating the templated version of the file, I can't find a way to keep around the templated version of the file after the fact. We'd very much like to be able to save the templated file for later inspection, without having to install the result on a live system. (This is useful for such things as debugging very complex templates; feeding a file into a sanity checker for the given service; etc.)

I tried using ANSIBLE_KEEP_REMOTE_FILES, but this just keeps a python script that presumably includes the template in its ZIPDATA, rather than saving a cleartext version of the templated file.

Can anyone suggest a way to save these templated files? I'd be happy to hear that I'm just overlooking some obvious option or flag. ;)

Thanks,
Adam

Brian Coca

unread,
Jun 2, 2017, 11:46:14 AM6/2/17
to Ansible Project
The template file itself would not be in the remote files dir if you
only used checkmode,it gets generated locally and ONLY copied to the
target if needed. Check the tmp directories used on your ansible
controller.


----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages