theforeman / theforeman.foreman / 0.8.1 / module / foreman_provisioning_template Manage Provisioning Template in Foreman Authors: Bernhard Hopfenmueller (@Fobhep) ATIX AG, Matthias Dellweg (@mdellweg) ATIX AG preview | supported by communitytheforeman.foreman.foreman_provisioning_template (0.8.1) — module
Install with ansible-galaxy collection install theforeman.foreman:==0.8.1
collections: - name: theforeman.foreman version: 0.8.1
Manage Foreman Provisioning Template
# Keep in mind, that in this case, the inline parameters will be overwritten - name: "Create a Provisioning Template inline" foreman_provisioning_template: username: "admin" password: "changeme" server_url: "https://foreman.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" foreman_provisioning_template: username: "admin" password: "changeme" server_url: "https://foreman.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" foreman_provisioning_template: username: "admin" password: "changeme" server_url: "https://foreman.example.com" name: timeywimey_template template: | <%# dummy: %> state: absent
- name: "Create a Provisioning Template from a file and modify with parameter" foreman_provisioning_template: username: "admin" password: "changeme" server_url: "https://foreman.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" foreman_provisioning_template: username: "admin" password: "changeme" server_url: "https://foreman.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 foreman_provisioning_template: server_url: "https://foreman.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" local_action: module: foreman_provisioning_template username: "admin" password: "admin" server_url: "https://foreman.example.com" name: "*" state: absent
- name: "Assign all provisioning templates to the same organization(s)" local_action: module: foreman_provisioning_template username: "admin" password: "admin" server_url: "https://foreman.example.com" name: "*" state: present organizations: - DALEK INC - sky.net - Doc Brown's garage
kind: choices: - finish - iPXE - job_template - POAP - provision - ptable - PXELinux - PXEGrub - PXEGrub2 - script - snippet - user_data - ZTP description: - The provisioning template kind required: false type: str name: description: - 'The name a template should be assigned with in Foreman. A name must be provided. Possible sources are, ordererd by preference: The "name" parameter, config header (inline or in a file), basename of a file. The special name "*" (only possible as parameter) is used to perform bulk actions (modify, delete) on all existing templates. ' required: false type: str state: choices: - present - present_with_defaults - absent default: present description: - State of the entity in Foreman - C(present_with_defaults) will ensure the entity exists, but won't update existing ones type: str locked: description: - Determines whether the template shall be locked required: false type: bool password: description: Password of the user accessing the Foreman server required: true type: str template: description: - 'The content of the provisioning template, either this or file_name is required as a source for the Provisioning Template "content". ' required: false type: str username: description: Username accessing the Foreman server required: true type: str file_name: description: - 'The path of a template file, that shall be imported. Either this or template is required as a source for the Provisioning Template "content". ' required: false type: path locations: description: List of locations the entity should be assigned to elements: str type: list server_url: description: URL of the Foreman server required: true type: str updated_name: description: New provisioning template name. When this parameter is set, the module will not be idempotent. type: str audit_comment: description: - Content of the audit comment field required: false type: str organizations: description: List of organizations the entity should be assigned to elements: str type: list validate_certs: aliases: - verify_ssl default: true description: Whether or not to verify the TLS certificates of the Foreman server type: bool operatingsystems: description: The Operatingsystems the template shall be assigned to elements: str required: false type: list