Question about template module

18 views
Skip to first unread message

John Petro

unread,
Nov 10, 2021, 9:36:24 AM11/10/21
to ansible...@googlegroups.com
Good morning!!

I have a quick question about how the template module works under the hood, that I wasn't able to find any information on, and was asked about by a coworker.   

So, let's say I have a role where I created a config file from a template.  If I run that role a second time, the result comes back having not making any changes, which is what I expect.   So the question I have is when I run a playbook against that role multiple times, how does ansible check the value to determine if a change needs to be made or not.

--john

Matt Martz

unread,
Nov 10, 2021, 9:42:36 AM11/10/21
to ansible...@googlegroups.com
The template is always generated locally where ansible is executed from.  Then we call the `copy` action internally, which will call the `stat` module to get the checksum of the remote file and determine if it exists.  If the local checksum and remote checksum matches, the file is not copied to the remote.  Afterwards we call the `file` action/module, and potentially modify permissions/ownership/mode on the destination file.

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAPAjob_ikZ60_ijHj9hA%3DLoGVc-7Yy-tzh1m8Dfkm1YHSSX_yQ%40mail.gmail.com.


--
Matt Martz
@sivel
sivel.net

John Petro

unread,
Nov 10, 2021, 1:15:03 PM11/10/21
to ansible...@googlegroups.com
Thanks Matt!!   That is the answer I was looking for. 

--John

Reply all
Reply to author
Forward
0 new messages