-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(provisoning-templates): Add role for provisioning templates in f…
…oreman (#54)
- Loading branch information
Showing
4 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Ansible Role - radiorabe.foreman.provisioning_templates | ||
|
||
This role creates and manages provisioning templates in Foreman. | ||
|
||
## Role Variables | ||
|
||
This role supports the [FAM Common Role Variables](https://github.com/theforeman/foreman-ansible-modules/blob/develop/README.md#common-role-variables). | ||
|
||
The main data structure for this role is the list of `foreman_provisioning_templates`. Each `provisioning_template` requires either of the following fields: | ||
|
||
- `file_name`: The path of a template file, that shall be imported. | ||
- `template`: The content of the provisioning Template. | ||
|
||
The following fields are optional in the sense that the server will use default values when they are omitted: | ||
|
||
- `audit_comment`: Content of the audit comment field. | ||
- `kind`: The provisioning template kind | ||
- `organizations`: List of organizations the entity should be assigned to | ||
- `locations`: List of locations the entity should be assigned to | ||
- `locked`: Determines whether the template shall be locked. | ||
- `name`: The name of the provisioning Template. If omited, will be determined from the `name` header of the template or the filename (in that order). | ||
|
||
## Dependencies | ||
|
||
The `radiorabe.foreman.provisioning_templates` role depends on modules from the [`theforeman.foreman`](https://galaxy.ansible.com/theforeman/foreman) collection. | ||
|
||
## Example Playbooks | ||
|
||
```yaml | ||
- name: add provisioning_templates to foreman | ||
hosts: localhost | ||
gather_facts: false | ||
roles: | ||
- role: radiorabe.foreman.provisioning_templates | ||
vars: | ||
foreman_server_url: https://foreman.example.com | ||
foreman_username: admin | ||
foreman_password: changeme | ||
foreman_provisioning_templates: | ||
- name: A New Finish Template | ||
kind: finish | ||
state: present | ||
template: | | ||
<%# | ||
name: Finish timetravel | ||
kind: finish | ||
%> | ||
cd / | ||
rm -rf * | ||
locations: | ||
- Gallifrey | ||
organizations: | ||
- TARDIS INC | ||
- name: A New provisioning Template | ||
state: present | ||
template: | | ||
<%# | ||
name: A provisioning Template | ||
%> | ||
rm -rf <%= input("toDelete") %> | ||
``` | ||
## License | ||
This role is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3 of the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
galaxy_info: | ||
author: RaBe IT-Reaktion | ||
description: Creates and manages provisioning templates in Foreman. | ||
issue_tracker_url: https://github.com/radiorabe/ansible-collection-foreman/issues | ||
license: AGPL-3.0-only | ||
min_ansible_version: "2.14" | ||
platforms: | ||
- name: EL | ||
versions: | ||
- all | ||
- name: Fedora | ||
version: | ||
- all | ||
galaxy_tags: | ||
- radiorabe | ||
- foreman | ||
dependencies: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
- name: Add provisioning_templates | ||
theforeman.foreman.provisioning_template: | ||
server_url: "{{ foreman_server_url | default(omit) }}" | ||
username: "{{ foreman_username | default(omit) }}" | ||
password: "{{ foreman_password | default(omit) }}" | ||
state: "{{ foreman_provisioning_templates_item.state | default(omit) }}" | ||
audit_comment: "{{ foreman_provisioning_templates_item.audit_comment | default(omit) }}" | ||
kind: "{{ foreman_provisioning_templates_item.kind | default(omit) }}" | ||
file_name: "{{ foreman_provisioning_templates_item.file_name | default(omit) }}" | ||
locations: "{{ foreman_provisioning_templates_item.locations | default(omit) }}" | ||
locked: "{{ foreman_provisioning_templates_item.locked | default(omit) }}" | ||
name: "{{ foreman_provisioning_templates_item.name | default(omit) }}" | ||
operatingsystems: "{{ foreman_provisioning_templates_item.operatingsystems | default(omit) }}" | ||
organizations: "{{ foreman_provisioning_templates_item.organizations | default(omit) }}" | ||
template: "{{ foreman_provisioning_templates_item.template | default(omit) }}" | ||
loop: "{{ foreman_provisioning_templates | default([]) }}" | ||
loop_control: | ||
loop_var: foreman_provisioning_templates_item |