Question about template module

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

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.

Thanks Matt!! That is the answer I was looking for.

–John