theforeman.foreman.partition_table 模块 – 管理分区表模板

注意

此模块是 theforeman.foreman 集合(版本 4.2.0)的一部分。

如果您正在使用 ansible 包,则可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install theforeman.foreman。您需要更多要求才能使用此模块,请参阅 要求 了解详细信息。

要在 playbook 中使用它,请指定:theforeman.foreman.partition_table

theforeman.foreman 1.0.0 中的新增功能

概要

  • 管理分区表模板

别名:foreman_ptable

要求

在执行此模块的主机上需要以下要求。

  • requests

参数

参数

注释

file_name

路径

要导入的模板文件的路径。

此项或 layout 是作为分区模板“内容”的源所必需的。

layout

字符串

分区表模板的内容

此项或 file_name 是作为分区模板“内容”的源所必需的。

locations

列表 / 元素=字符串

应将实体分配到的位置列表

locked

布尔值

确定是否应锁定模板

选择

  • false

  • true

name

字符串

分区表的名称。

如果省略,将从模板的 name 标头或文件名(按此顺序)确定。

特殊值“*”可用于对所有现有分区表执行批量操作(修改、删除)。

organizations

列表 / 元素=字符串

应将实体分配到的组织列表

os_family

字符串

应为模板分配的操作系统系列。

选择

  • "AIX"

  • "Altlinux"

  • "Archlinux"

  • "Coreos"

  • "Debian"

  • "Fcos"

  • "Freebsd"

  • "Gentoo"

  • "Junos"

  • "NXOS"

  • "Rancheros"

  • "Redhat"

  • "Rhcos"

  • "Solaris"

  • "Suse"

  • "VRP"

  • "Windows"

  • "Xenserver"

password

字符串 / 必需

访问 Foreman 服务器的用户的密码。

如果未在任务中指定该值,则将使用环境变量 FOREMAN_PASSWORD 的值。

server_url

字符串 / 必需

Foreman 服务器的 URL。

如果未在任务中指定该值,则将使用环境变量 FOREMAN_SERVER_URL 的值。

state

字符串

实体的状态

present_with_defaults 将确保实体存在,但不会更新现有实体

选择

  • "present" ← (默认)

  • "present_with_defaults"

  • "absent"

updated_name

字符串

模板的新名称。设置此参数后,模块将不是幂等的。

username

字符串 / 必需

访问 Foreman 服务器的用户名。

如果未在任务中指定该值,则将使用环境变量 FOREMAN_USERNAME 的值。

validate_certs

布尔值

是否验证 Foreman 服务器的 TLS 证书。

如果未在任务中指定该值,则将使用环境变量 FOREMAN_VALIDATE_CERTS 的值。

选择

  • false

  • true ← (默认)

属性

属性

支持

描述

check_mode

支持: 完全

可以在 check_mode 中运行,并返回已更改的状态预测,而无需修改实体

diff_mode

支持: 完全

在 diff 模式下,将返回有关已更改的内容(或可能需要在 check_mode 中更改的内容)的详细信息

示例

# Keep in mind, that in this case, the inline parameters will be overwritten
- name: "Create a Partition Table inline"
  theforeman.foreman.partition_table:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    name: A New Partition Template
    state: present
    layout: |
      <%#
        name: A Partition Template
      %>
        zerombr
        clearpart --all --initlabel
        autopart
    locations:
      - Gallifrey
    organizations:
      - TARDIS INC

- name: "Create a Partition Template from a file"
  theforeman.foreman.partition_table:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    file_name: timeywimey_template.erb
    state: present
    locations:
      - Gallifrey
    organizations:
      - TARDIS INC

- name: "Delete a Partition Template"
  theforeman.foreman.partition_table:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    name: timeywimey
    layout: |
      <%#
          dummy:
      %>
    state: absent

- name: "Create a Partition Template from a file and modify with parameter(s)"
  theforeman.foreman.partition_table:
    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 partition templates"
  theforeman.foreman.partition_table:
    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 Ptable Community Templates
  theforeman.foreman.partition_table:
    server_url: "https://foreman.example.com"
    username: "admin"
    password: "changeme"
    state: present
    layout: '{{ lookup("file", item.src) }}'
  with_filetree: '/path/to/partition/tables'
  when: item.state == 'file'


# with name set to "*" bulk actions can be performed
- name: "Delete *ALL* partition tables"
  theforeman.foreman.partition_table:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    name: "*"
    state: absent

- name: "Assign all partition tables to the same organization(s)"
  theforeman.foreman.partition_table:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    name: "*"
    state: present
    organizations:
      - DALEK INC
      - sky.net
      - Doc Brown's garage

返回值

常用返回值在 此处 中记录,以下是此模块特有的字段

描述

entity

字典

受影响实体的最终状态,按其类型分组。

已返回:成功

ptables

列表 / 元素=字典

分区表列表。

已返回:成功

作者

  • Bernhard Hopfenmueller (@Fobhep) ATIX AG

  • Matthias Dellweg (@mdellweg) ATIX AG