theforeman.foreman.provisioning_template 模块 – 管理配置模板
注意
此模块是 theforeman.foreman 集合(版本 4.2.0)的一部分。
如果您使用的是 ansible
包,您可能已经安装了此集合。它不包含在 ansible-core
中。要检查是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用: ansible-galaxy collection install theforeman.foreman
。您需要进一步的要求才能使用此模块,请参阅 要求 了解详细信息。
要在 playbook 中使用它,请指定: theforeman.foreman.provisioning_template
。
theforeman.foreman 1.0.0 中的新增功能
概要
管理配置模板
别名:foreman_provisioning_template
要求
执行此模块的主机需要以下要求。
requests
参数
参数 |
注释 |
---|---|
审核注释字段的内容 |
|
要导入的模板文件的路径。 此项或 template 是配置模板“内容”的源的必需项。 |
|
配置模板类型 选择
|
|
应将实体分配到的位置列表 |
|
确定是否应锁定模板 选择
|
|
配置模板的名称。 如果省略,将从模板的 特殊值“*”可用于对所有现有模板执行批量操作(修改、删除)。 |
|
应将实体分配到的操作系统列表。 操作系统按其标题查找,标题的组成方式为“<name> <major>.<minor>”。 只要您只有一个该名称的操作系统,就可以省略版本部分。 |
|
应将实体分配到的组织列表 |
|
访问 Foreman 服务器的用户的密码。 如果未在任务中指定该值,则将改为使用环境变量 |
|
Foreman 服务器的 URL。 如果未在任务中指定该值,则将改为使用环境变量 |
|
实体的状态
选择
|
|
配置模板的内容。 此项或 file_name 是配置模板“内容”的源的必需项。 |
|
新的配置模板名称。设置此参数后,该模块将不具有幂等性。 |
|
访问 Foreman 服务器的用户名。 如果未在任务中指定该值,则将改为使用环境变量 |
|
是否验证 Foreman 服务器的 TLS 证书。 如果未在任务中指定该值,则将改为使用环境变量 选择
|
属性
属性 |
支持 |
描述 |
---|---|---|
支持: 完全 |
可以在 check_mode 中运行,并返回更改状态预测,而无需修改实体 |
|
支持: 完全 |
当处于 diff 模式时,将返回有关已更改(或可能需要在 check_mode 中更改)的内容的详细信息 |
示例
# Keep in mind, that in this case, the inline parameters will be overwritten
- name: "Create a Provisioning Template inline"
theforeman.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"
theforeman.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"
theforeman.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"
theforeman.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"
theforeman.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
theforeman.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"
theforeman.foreman.provisioning_template:
username: "admin"
password: "changeme"
server_url: "https://foreman.example.com"
name: "*"
state: absent
- name: "Assign all provisioning templates to the same organization(s)"
theforeman.foreman.provisioning_template:
username: "admin"
password: "changeme"
server_url: "https://foreman.example.com"
name: "*"
state: present
organizations:
- DALEK INC
- sky.net
- Doc Brown's garage
返回值
常见的返回值已在此处记录,以下是此模块特有的字段
键 |
描述 |
---|---|
受影响实体的最终状态,按其类型分组。 返回: 成功 |
|
配置模板列表。 返回: 成功 |