redhat.satellite.provisioning_template module – Manage Provisioning Templates

Note

This module is part of the redhat.satellite collection (version 3.12.0).

To install it, use: ansible-galaxy collection install redhat.satellite. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: redhat.satellite.provisioning_template.

New in redhat.satellite 1.0.0

Synopsis

  • Manage Provisioning Templates

Aliases: foreman_provisioning_template

Requirements

The below requirements are needed on the host that executes this module.

  • requests

Parameters

Parameter

Comments

audit_comment

string

Content of the audit comment field

file_name

path

The path of a template file, that shall be imported.

Either this or template is required as a source for the Provisioning Template “content”.

kind

string

The provisioning template kind

Choices:

  • "Bootdisk"

  • "cloud-init"

  • "finish"

  • "host_init_config"

  • "iPXE"

  • "job_template"

  • "kexec"

  • "POAP"

  • "provision"

  • "PXEGrub"

  • "PXEGrub2"

  • "PXELinux"

  • "registration"

  • "script"

  • "snippet"

  • "user_data"

  • "ZTP"

locations

list / elements=string

List of locations the entity should be assigned to

locked

boolean

Determines whether the template shall be locked

Choices:

  • false

  • true

name

string

The name of the Provisioning Template.

If omited, will be determined from the name header of the template or the filename (in that order).

The special value “*” can be used to perform bulk actions (modify, delete) on all existing templates.

operatingsystems

list / elements=string

List of operating systems the entity should be assigned to.

Operating systems are looked up by their title which is composed as “<name> <major>.<minor>”.

You can omit the version part as long as you only have one operating system by that name.

organizations

list / elements=string

List of organizations the entity should be assigned to

password

string / required

Password of the user accessing the Foreman server.

If the value is not specified in the task, the value of environment variable SATELLITE_PASSWORD will be used instead.

server_url

string / required

URL of the Foreman server.

If the value is not specified in the task, the value of environment variable SATELLITE_SERVER_URL will be used instead.

state

string

State of the entity

present_with_defaults will ensure the entity exists, but won’t update existing ones

Choices:

  • "present" ← (default)

  • "present_with_defaults"

  • "absent"

template

string

The content of the provisioning template.

Either this or file_name is required as a source for the Provisioning Template “content”.

updated_name

string

New provisioning template name. When this parameter is set, the module will not be idempotent.

username

string / required

Username accessing the Foreman server.

If the value is not specified in the task, the value of environment variable SATELLITE_USERNAME will be used instead.

validate_certs

boolean

Whether or not to verify the TLS certificates of the Foreman server.

If the value is not specified in the task, the value of environment variable SATELLITE_VALIDATE_CERTS will be used instead.

Choices:

  • false

  • true ← (default)

Attributes

Attribute

Support

Description

check_mode

Support: full

Can run in check_mode and return changed status prediction without modifying the entity

diff_mode

Support: full

Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode

Examples

# Keep in mind, that in this case, the inline parameters will be overwritten
- name: "Create a Provisioning Template inline"
  redhat.satellite.provisioning_template:
    username: "admin"
    password: "changeme"
    server_url: "https://satellite.example.com"
    name: A New Finish Template
    kind: finish
    state: present
    template: |
      <%#
          name: Finish timetravel
          kind: finish
      %>
      cd /
      rm -rf *
    locations:
      - Gallifrey
    organizations:
      - TARDIS INC

- name: "Create a Provisioning Template from a file"
  redhat.satellite.provisioning_template:
    username: "admin"
    password: "changeme"
    server_url: "https://satellite.example.com"
    file_name: timeywimey_template.erb
    state: present
    locations:
      - Gallifrey
    organizations:
      - TARDIS INC

# Due to the module logic, deleting requires a template dummy,
# either inline or from a file.
- name: "Delete a Provisioning Template"
  redhat.satellite.provisioning_template:
    username: "admin"
    password: "changeme"
    server_url: "https://satellite.example.com"
    name: timeywimey_template
    template: |
      <%#
          dummy:
      %>
    state: absent

- name: "Create a Provisioning Template from a file and modify with parameter"
  redhat.satellite.provisioning_template:
    username: "admin"
    password: "changeme"
    server_url: "https://satellite.example.com"
    file_name: timeywimey_template.erb
    name: Wibbly Wobbly Template
    state: present
    locations:
      - Gallifrey
    organizations:
      - TARDIS INC

# Providing a name in this case wouldn't be very sensible.
# Alternatively make use of with_filetree to parse recursively with filter.
- name: "Parsing a directory of provisioning templates"
  redhat.satellite.provisioning_template:
    username: "admin"
    password: "changeme"
    server_url: "https://satellite.example.com"
    file_name: "{{ item }}"
    state: present
    locations:
      - SKARO
    organizations:
      - DALEK INC
    with_fileglob:
       - "./arsenal_templates/*.erb"

# If the templates are stored locally and the ansible module is executed on a remote host
- name: Ensure latest version of all Provisioning Community Templates
  redhat.satellite.provisioning_template:
    server_url: "https://satellite.example.com"
    username: "admin"
    password: "changeme"
    state: present
    template: '{{ lookup("file", item.src) }}'
  with_filetree: '/path/to/provisioning/templates'
  when: item.state == 'file'


# with name set to "*" bulk actions can be performed
- name: "Delete *ALL* provisioning templates"
  redhat.satellite.provisioning_template:
    username: "admin"
    password: "changeme"
    server_url: "https://satellite.example.com"
    name: "*"
    state: absent

- name: "Assign all provisioning templates to the same organization(s)"
  redhat.satellite.provisioning_template:
    username: "admin"
    password: "changeme"
    server_url: "https://satellite.example.com"
    name: "*"
    state: present
    organizations:
      - DALEK INC
      - sky.net
      - Doc Brown's garage

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

entity

dictionary

Final state of the affected entities grouped by their type.

Returned: success

provisioning_templates

list / elements=dictionary

List of provisioning templates.

Returned: success

Authors

  • Bernhard Hopfenmueller (@Fobhep) ATIX AG

  • Matthias Dellweg (@mdellweg) ATIX AG