theforeman.foreman.host 模块 – 主机管理
注意
此模块是 theforeman.foreman 集合 (版本 4.2.0) 的一部分。
如果您使用的是 ansible 软件包,则可能已安装此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用:ansible-galaxy collection install theforeman.foreman。您需要其他要求才能使用此模块,有关详细信息,请参见 要求。
要在剧本中使用它,请指定:theforeman.foreman.host。
theforeman.foreman 1.0.0 中的新增功能
概要
- 创建、更新和删除主机 
别名:foreman_host
要求
以下要求是在执行此模块的主机上需要的。
- requests 
参数
| 参数 | 注释 | 
|---|---|
| 用于部署的激活密钥。 逗号分隔列表。 仅适用于 Katello 安装。 | |
| 架构名称 | |
| 是否为主机设置构建上下文 选项 
 | |
| 关于主机的注释。 | |
| 其他计算资源特定属性。 设置此参数时,模块将不是幂等的。 如果在此处提供一个 *cluster* 并且设置了 *compute_resource*,则会自动查找集群 ID。 | |
| 计算配置文件名称 | |
| 计算资源名称 | |
| 配置组列表 | |
| 内容来源(具有内容的智能代理)名称。 仅适用于 Katello 安装。 | |
| 内容视图。 仅适用于 Katello 安装。 | |
| 域名 | |
| 在报告中包含此主机 选项 
 | |
| Puppet 环境名称 | |
| 相关主机组的标题 例如:父主机组 *foo* 中的子主机组 *bar* 的标题为 *foo/bar*。 | |
| 当 *provision_method=image* 时要使用的镜像。 *compute_resource* 参数是查找正确镜像所必需的。 | |
| 其他接口特定属性。 | |
| 已连接接口的标识符,例如 [‘eth1’,‘eth2’]。 对于绑定接口,这些是从属接口。 仅适用于绑定和桥接接口。 | |
| 此接口所属接口的标识符,例如 eth1。 仅适用于虚拟接口。 | |
| 空格分隔的选项,例如 miimon=100。 仅适用于绑定接口。 | |
| 接口的其他计算资源特定属性。 设置此参数时,模块将不是幂等的。 如果在此处提供一个 *network* 并且设置了 *compute_resource*,则会自动查找网络 ID。 在 oVirt/RHV 上,主机 *compute_attributes* 中需要 *cluster* 才能使查找正常工作。 | |
| 域名 托管主机上的主接口需要此参数。 | |
| 是否应将此接口用于远程执行? 每个托管主机都应该有一个远程执行接口。 选项 
 | |
| 设备标识符,例如 eth0 或 eth1.1 您需要设置 *identifier*、*name* 或 *mac* 之一才能更新现有接口并使执行幂等。 | |
| 接口的 IPv4 地址 | |
| 接口的 IPv6 地址 | |
| 接口的 MAC 地址。裸机上的托管接口需要此参数。 请包含前导零,并用冒号分隔字节,否则执行将不是幂等的。 示例 EE:BB:01:02:03:04 您需要设置 *identifier*、*name* 或 *mac* 之一才能更新现有接口并使执行幂等。 | |
| 此接口是否应通过 DHCP 和 DNS 智能代理进行管理,以及是否应在配置过程中进行配置? 选项 
 | |
| 接口的绑定模式。 仅适用于绑定接口。 选项 
 | |
| MTU,此属性优先于子网 MTU。 | |
| 接口的 DNS 名称 您需要设置 *identifier*、*name* 或 *mac* 之一才能更新现有接口并使执行幂等。 | |
| BMC 身份验证的密码。 仅适用于 BMC 接口。 | |
| 是否应使用此接口来构建主机的 FQDN? 每个托管主机都需要一个主接口。 选项 
 | |
| 接口提供商,例如 IPMI。 仅适用于 BMC 接口。 选项 
 | |
| 是否应将此接口用于 TFTP 或 PXELinux(或基于镜像的主机的 SSH)? 每个托管主机都需要一个配置接口。 选项 
 | |
| IPv4 子网名称 | |
| IPv6 子网名称 | |
| VLAN 标记,此属性优先于子网 VLAN ID。 仅适用于虚拟接口。 | |
| 接口类型。 选项 
 | |
| BMC 身份验证的用户名。 仅适用于 BMC 接口。 | |
| 别名或 VLAN 设备 选项 
 | |
| 主机的首要接口的 IP 地址。 | |
| Kickstart 资源库名称。 您需要提供此参数才能使用“同步内容”功能。 与 *medium* 互斥。 仅适用于 Katello 安装。 | |
| 生命周期环境。 仅适用于 Katello 安装。 | |
| 相关位置的名称 | |
| 主机的首要接口的 MAC 地址。 请包含前导零,并用冒号分隔字节,否则执行将不是幂等的。 示例 EE:BB:01:02:03:04 | |
| 主机是托管的还是非托管的。 当build=true时强制设置为true。 选项 
 | |
| 介质名称 与kickstart_repository互斥。 | |
| 主机的完全限定域名 | |
| OpenSCAP 代理名称。 仅在安装 OpenSCAP 插件后可用。 | |
| 操作系统按其标题查找,标题构成方式为“<name> <major>.<minor>”。 只要您只有一个同名的操作系统,就可以省略版本部分。 | |
| 相关组织的名称 | |
| 主机的拥有者(用户)。 用户按其 与owner_group互斥。 | |
| 主机的拥有者(用户组)。 与owner互斥。 | |
| 实体域特定的主机参数 | |
| 参数的名称 | |
| 参数的类型 选项 
 | |
| 参数的值 | |
| 访问 Foreman 服务器的用户密码。 如果任务中未指定值,则将使用环境变量 | |
| 用于配置主机的方案。 只有安装了bootdisk插件后,才能使用provision_method=bootdisk。 选项 
 | |
| 分区表名称 | |
| Puppet CA 代理名称 | |
| Puppet 服务器代理名称 | |
| 要包含在此主机组中的 Puppet 类列表。主机组的 Puppet 环境必须存在。 | |
| PXE 引导加载程序 选项 
 | |
| 领域名称 | |
| Root 密码。 将导致实体始终被更新,因为无法检索当前密码。 | |
| Foreman 服务器的 URL。 如果任务中未指定值,则将使用环境变量 | |
| 实体的状态 选项 
 | |
| IPv4 子网名称 | |
| IPv6 子网名称 | |
| 访问 Foreman 服务器的用户名。 如果任务中未指定值,则将使用环境变量 | |
| 是否验证 Foreman 服务器的 TLS 证书。 如果任务中未指定值,则将使用环境变量 选项 
 | 
属性
| 属性 | 支持 | 描述 | 
|---|---|---|
| 支持:完全支持 | 可以在 check_mode 下运行,并在不修改实体的情况下返回更改状态预测。 | |
| 支持:完全支持 | 在差异模式下,将返回有关已更改内容(或在 check_mode 下可能需要更改的内容)的详细信息。 | 
示例
- name: "Create a host"
  theforeman.foreman.host:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    name: "new_host"
    hostgroup: my_hostgroup
    state: present
- name: "Create a host with build context"
  theforeman.foreman.host:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    name: "new_host"
    hostgroup: my_hostgroup
    build: true
    state: present
- name: "Create an unmanaged host"
  theforeman.foreman.host:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    name: "new_host"
    managed: false
    state: present
- name: "Create a VM with 2 CPUs and 4GB RAM"
  theforeman.foreman.host:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    name: "new_host"
    compute_attributes:
      cpus: 2
      memory_mb: 4096
    state: present
- name: "Create a VM and start it after creation"
  theforeman.foreman.host:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    name: "new_host"
    compute_attributes:
      start: "1"
    state: present
- name: "Create a VM on specific ovirt network"
  theforeman.foreman.host:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    name: "new_host"
    interfaces_attributes:
      - type: "interface"
        compute_attributes:
          name: "nic1"
          network: "969efbe6-f9e0-4383-a19a-a7ee65ad5007"
          interface: "virtio"
    state: present
- name: "Create a VM with 2 NICs on specific ovirt networks"
  theforeman.foreman.host:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    name: "new_host"
    interfaces_attributes:
      - type: "interface"
        primary: true
        compute_attributes:
          name: "nic1"
          network: "969efbe6-f9e0-4383-a19a-a7ee65ad5007"
          interface: "virtio"
      - type: "interface"
        name: "new_host_nic2"
        managed: true
        compute_attributes:
          name: "nic2"
          network: "969efbe6-f9e0-4383-a19a-a7ee65ad5008"
          interface: "e1000"
    state: present
- name: "Delete a host"
  theforeman.foreman.host:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    name: "new_host"
    state: absent
返回值
常见返回值已在此处记录,以下是此模块特有的字段
| 键 | 描述 | 
|---|---|
| 按类型分组的受影响实体的最终状态。 返回:成功 | |
| 主机列表。 返回:成功 | 
