Class: Ansible::Ruby::Modules::Template

Inherits:
Base show all
Includes:
Helpers::FileAttributes
Defined in:
lib/ansible/ruby/modules/generated/files/template.rb,
lib/ansible/ruby/modules/custom/files/template.rb

Overview

Templates are processed by the Jinja2 templating language (U(jinja.pocoo.org/docs/)) - documentation on the template formatting can be found in the Template Designer Documentation (U(jinja.pocoo.org/docs/templates/)). Six additional variables can be used in templates: C(ansible_managed) (configurable via the C(defaults) section of C(ansible.cfg)) contains a string which can be used to describe the template name, host, modification time of the template file and the owner uid. C(template_host) contains the node name of the template’s machine. C(template_uid) is the numeric user id of the owner. C(template_path) is the path of the template. C(template_fullpath) is the absolute path of the template. C(template_run_date) is the date that the template was rendered.

Instance Method Summary collapse

Methods included from Helpers::FileAttributes

included

Methods inherited from Base

#ansible_name, #to_h

Methods inherited from Ansible::Ruby::Models::Base

attr_option, attr_options, attribute, #initialize, remove_existing_validations, #to_h, validates

Constructor Details

This class inherits a constructor from Ansible::Ruby::Models::Base

Instance Method Details

#backup:yes, ...

Returns Create a backup file including the timestamp information so you can get the original file back if you somehow clobbered it incorrectly.

Returns:

  • (:yes, :no, nil)

    Create a backup file including the timestamp information so you can get the original file back if you somehow clobbered it incorrectly.



21
# File 'lib/ansible/ruby/modules/generated/files/template.rb', line 21

attribute :backup

#block_end_stringString?

Returns The string marking the end of a block.

Returns:

  • (String, nil)

    The string marking the end of a block.



33
# File 'lib/ansible/ruby/modules/generated/files/template.rb', line 33

attribute :block_end_string

#block_start_stringString?

Returns The string marking the beginning of a block.

Returns:

  • (String, nil)

    The string marking the beginning of a block.



29
# File 'lib/ansible/ruby/modules/generated/files/template.rb', line 29

attribute :block_start_string

#destString

Returns Location to render the template to on the remote machine.

Returns:

  • (String)

    Location to render the template to on the remote machine.



17
# File 'lib/ansible/ruby/modules/generated/files/template.rb', line 17

attribute :dest

#follow:yes, ...

Returns This flag indicates that filesystem links in the destination, if they exist, should be followed.,Previous to Ansible 2.4, this was hardcoded as C(yes).

Returns:

  • (:yes, :no, nil)

    This flag indicates that filesystem links in the destination, if they exist, should be followed.,Previous to Ansible 2.4, this was hardcoded as C(yes).



57
# File 'lib/ansible/ruby/modules/generated/files/template.rb', line 57

attribute :follow

#force:yes, ...

Returns the default is C(yes), which will replace the remote file when contents are different than the source. If C(no), the file will only be transferred if the destination does not exist.

Returns:

  • (:yes, :no, nil)

    the default is C(yes), which will replace the remote file when contents are different than the source. If C(no), the file will only be transferred if the destination does not exist.



53
# File 'lib/ansible/ruby/modules/generated/files/template.rb', line 53

attribute :force

#lstrip_blocks:yes, ...

Returns If this is set to True leading spaces and tabs are stripped from the start of a line to a block. Setting this option to True requires Jinja2 version >=2.7.

Returns:

  • (:yes, :no, nil)

    If this is set to True leading spaces and tabs are stripped from the start of a line to a block. Setting this option to True requires Jinja2 version >=2.7.



49
# File 'lib/ansible/ruby/modules/generated/files/template.rb', line 49

attribute :lstrip_blocks

#modeInteger, ...

Returns Mode the file or directory should be. For those used to I(/usr/bin/chmod) remember that modes are actually octal numbers. You must either add a leading zero so that Ansible’s YAML parser knows it is an octal number (like C(0644) or C(01777)) or quote it (like C(‘644’) or C(‘1777’)) so Ansible receives a string and can do its own conversion from string into number. Giving Ansible a number without following one of these rules will end up with a decimal number which will have unexpected results. As of version 1.8, the mode may be specified as a symbolic mode (for example, C(u+rwx) or C(u=rw,g=r,o=r)). As of version 2.6, the mode may also be the special string C(preserve). C(preserve) means that the file will be given the same permissions as the source file.

Returns:

  • (Integer, Array<String>, String, nil)

    Mode the file or directory should be. For those used to I(/usr/bin/chmod) remember that modes are actually octal numbers. You must either add a leading zero so that Ansible’s YAML parser knows it is an octal number (like C(0644) or C(01777)) or quote it (like C(‘644’) or C(‘1777’)) so Ansible receives a string and can do its own conversion from string into number. Giving Ansible a number without following one of these rules will end up with a decimal number which will have unexpected results. As of version 1.8, the mode may be specified as a symbolic mode (for example, C(u+rwx) or C(u=rw,g=r,o=r)). As of version 2.6, the mode may also be the special string C(preserve). C(preserve) means that the file will be given the same permissions as the source file.



61
# File 'lib/ansible/ruby/modules/generated/files/template.rb', line 61

attribute :mode

#newline_sequence:"\\n", ...

Returns Specify the newline sequence to use for templating files.

Returns:

  • (:"\\n", :"\\r", :"\\r\\n", nil)

    Specify the newline sequence to use for templating files.



25
# File 'lib/ansible/ruby/modules/generated/files/template.rb', line 25

attribute :newline_sequence

#output_encodingString?

Returns Overrides the encoding used to write the template file defined by C(dest).,It defaults to C(‘utf-8’), but any encoding supported by python can be used.,The source template file must always be encoded using C(‘utf-8’), for homogeneity.

Returns:

  • (String, nil)

    Overrides the encoding used to write the template file defined by C(dest).,It defaults to C(‘utf-8’), but any encoding supported by python can be used.,The source template file must always be encoded using C(‘utf-8’), for homogeneity.



65
# File 'lib/ansible/ruby/modules/generated/files/template.rb', line 65

attribute :output_encoding

#srcString

Returns Path of a Jinja2 formatted template on the Ansible controller. This can be a relative or absolute path.

Returns:

  • (String)

    Path of a Jinja2 formatted template on the Ansible controller. This can be a relative or absolute path.



13
# File 'lib/ansible/ruby/modules/generated/files/template.rb', line 13

attribute :src

#trim_blocks:yes, ...

Returns If this is set to True the first newline after a block is removed (block, not variable tag!).

Returns:

  • (:yes, :no, nil)

    If this is set to True the first newline after a block is removed (block, not variable tag!).



45
# File 'lib/ansible/ruby/modules/generated/files/template.rb', line 45

attribute :trim_blocks

#variable_end_stringString?

Returns The string marking the end of a print statement.

Returns:

  • (String, nil)

    The string marking the end of a print statement.



41
# File 'lib/ansible/ruby/modules/generated/files/template.rb', line 41

attribute :variable_end_string

#variable_start_stringString?

Returns The string marking the beginning of a print statement.

Returns:

  • (String, nil)

    The string marking the beginning of a print statement.



37
# File 'lib/ansible/ruby/modules/generated/files/template.rb', line 37

attribute :variable_start_string