theforeman / theforeman.foreman / 0.8.1 / module / foreman_job_template Manage Job Templates in Foreman Authors: Manuel Bonk (@manuelbonk) ATIX AG, Matthias Dellweg (@mdellweg) ATIX AG preview | supported by communitytheforeman.foreman.foreman_job_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 Remote Execution Job Templates
- name: "Create a Job Template inline" foreman_job_template: username: "admin" password: "changeme" server_url: "https://foreman.example.com" name: A New Job Template state: present template: | <%# name: A Job Template %> rm -rf <%= input("toDelete") %> template_inputs: - name: toDelete input_type: user locations: - Gallifrey organizations: - TARDIS INC
- name: "Create a Job Template from a file" foreman_job_template: username: "admin" password: "changeme" server_url: "https://foreman.example.com" name: a new job template file_name: timeywimey_template.erb template_inputs: - name: a new template input input_type: user state: present locations: - Gallifrey organizations: - TARDIS INC
- name: "remove a job template's template inputs" foreman_job_template: username: "admin" password: "changeme" server_url: "https://foreman.example.com" name: a new job template template_inputs: [] state: present locations: - Gallifrey organizations: - TARDIS INC
- name: "Delete a Job Template" foreman_job_template: username: "admin" password: "changeme" server_url: "https://foreman.example.com" name: timeywimey state: absent
- name: "Create a Job Template from a file and modify with parameter(s)" foreman_job_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 Job templates foreman_job_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 your Job Templates foreman_job_template: server_url: "https://foreman.example.com" username: "admin" password: "changeme" state: present layout: '{{ lookup("file", item.src) }}' with_filetree: '/path/to/job/templates' when: item.state == 'file'
# with name set to "*" bulk actions can be performed - name: "Delete *ALL* Job Templates" local_action: module: foreman_job_template username: "admin" password: "admin" server_url: "https://foreman.example.com" name: "*" state: absent
- name: "Assign all Job Templates to the same organization(s)" local_action: module: foreman_job_template username: "admin" password: "admin" server_url: "https://foreman.example.com" name: "*" state: present organizations: - DALEK INC - sky.net - Doc Brown's garage
name: description: - 'The name a template should be assigned with in Foreman. 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 Job Templates. ' 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: default: false description: - Determines whether the template shall be locked type: bool snippet: default: false description: - Determines whether the template shall be a snippet type: bool password: description: Password of the user accessing the Foreman server required: true type: str template: description: - 'The content of the Job Template, either this or file_name is required as a source for the Job Template "content". ' 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 layout is required as a source for the Job Template "content". ' 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 job_category: description: - The category the template should be assigend to type: str audit_comment: description: - Content of the audit comment field type: str organizations: description: List of organizations the entity should be assigned to elements: str type: list provider_type: description: - Determines via which provider the template shall be executed required: false type: str validate_certs: aliases: - verify_ssl default: true description: Whether or not to verify the TLS certificates of the Foreman server type: bool template_inputs: description: - The template inputs used in the Job Template elements: dict suboptions: advanced: default: false description: - Template Input is advanced type: bool description: description: - description of the Template Input type: str fact_name: description: - Fact name, used when input type is fact type: str input_type: choices: - user - fact - variable - puppet_parameter description: - input type required: true type: str name: description: - name of the Template Input required: true type: str options: description: - Template values for user inputs. Must be an array of any type. elements: raw type: list puppet_class_name: description: - Puppet class name, used when input type is puppet_parameter type: str puppet_parameter_name: description: - Puppet parameter name, used when input type is puppet_parameter type: str required: description: - Is the input required type: bool resource_type: description: - Type of the resource type: str value_type: choices: - plain - search - date description: - Type of the value type: str variable_name: description: - Variable name, used when input type is variable type: str type: list description_format: description: - description of the job template. Template inputs can be referenced. type: str