Table of Contents

About

The template module is an Action Plugin module.

Process

It

  • constructs a file in a temporary location on the controller using variables from the playbook environment or from the user
  • transfers the temporary file to a temporary file on the remote system
  • invokes the copy module which operates on the remote system to move the file into its final location, sets file permissions, and so on.

Example

Template action

  - name: " User - Create the conf variable file"
    become: yes
    become_user: '{{ user_login_user }}'
    template:
      src: './user/user/user_conf.sh'
      dest: '/home/{{ user_login_user }}/{{ user_login_user }}_conf.sh'
      owner: '{{ user_login_user }}'
      group: '{{ user_login_user }}'
      mode: 0770
    when: "'dev' in group_names or 'tst' in group_names" # only for the dev/test environment

Template language

{% if not registry_enabled %}
    enabled = no
{% elif registry_enabled %}
    enabled = yes
{% endif %}