Ansible - Template module

Card Puncher Data Processing

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 %}





Discover More
Card Puncher Data Processing
Ansible - Action Plugin Module Type

An Action Plugin is a type of module that: set up some values on the controller, (ie create a start state) then invoke an other module on the managed node that does something with these values.
Card Puncher Data Processing
Ansible - Facts (Remote System Env)

Facts are variable that contains environment information from the remote systems (ie current host (inventory_hostname)) ansible_facts contains any facts gathered or cached for the inventory_hostname...
Card Puncher Data Processing
Ansible - Role

Roles is the reusable unit of Ansible. You may think of it as a function. It: helps make playbook content self-contained works well with things like git submodules for sharing content with others....
Card Puncher Data Processing
How to perform File System operations (copy, exists, move, ) in Ansible?

This page shows you how to perform File system operations in Ansible. When looping through files, you can get the...
Data System Architecture
Log - logrotate app

logrotate is an application running as a linux service that allows: automatic rotation, compression removal, and mailing of log files. Each log file may be handled daily, weekly, monthly,...



Share this page:
Follow us:
Task Runner