Ansible Module template: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=External= * http://docs.ansible.com/ansible/latest/template_module.html =Internal= * Ansible Concepts =Example= <syntaxhighlight lang='yaml...")
 
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
=External=
=External=


* http://docs.ansible.com/ansible/latest/template_module.html
* https://docs.ansible.com/ansible/latest/collections/ansible/builtin/template_module.html


=Internal=
=Internal=
* [[Ansible_Concepts#template|Ansible Concepts]]
* [[Ansible_Concepts#template|Ansible Concepts]]
=Overview=


=Example=
=Example=
Line 22: Line 22:


Note that <role>/templates subdirectories will be automatically scanned so only the file name can be specified.
Note that <role>/templates subdirectories will be automatically scanned so only the file name can be specified.
=Parameters=
==<tt>force</tt>==
Determine whether the file is transferred if the destination already exists. Options: "yes": replace the remote file when contents are different than the source. "no": The file will only be transferred if the destination does not exist. Default "yes".

Latest revision as of 20:12, 8 July 2021

External

Internal

Overview

Example

- name: Copy .envrc script
  template:
    src: envrc.j2
    dest: "{{ ansible_env.SOME_DIR }}/.envrc"
    mode: "u=rw,g=r,o=r"

The files can be placed in:

  • <role>/templates

Note that <role>/templates subdirectories will be automatically scanned so only the file name can be specified.

Parameters

force

Determine whether the file is transferred if the destination already exists. Options: "yes": replace the remote file when contents are different than the source. "no": The file will only be transferred if the destination does not exist. Default "yes".