theforeman.foreman.subnet 模块 – 管理子网

注意

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

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

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

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

theforeman.foreman 1.0.0 中的新增功能

概要

  • 创建、更新和删除子网

别名:foreman_subnet

要求

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

  • ipaddress

  • requests

参数

参数

注释

bmc_proxy

字符串

在 theforeman.foreman 2.1.0 中添加

此子网的 BMC 智能代理

boot_mode

字符串

此子网中的主机使用的启动模式

选项

  • "DHCP" ← (默认)

  • "静态"

cidr

整数

CIDR 前缀长度;如果 _network_type=IPv4_ 且未提供 _mask_,则为必需

description

字符串

子网描述

dhcp_proxy

字符串

此子网的 DHCP 智能代理

discovery_proxy

字符串

此子网的发现智能代理

仅当安装了发现插件时,此选项才可用。

dns_primary

字符串

此子网的主 DNS 服务器

dns_proxy

字符串

此子网的反向 DNS 智能代理

dns_secondary

字符串

此子网的辅助 DNS 服务器

domains

列表 / 元素=字符串

应分配给子网的 DNS 域名列表

externalipam_group

字符串

在 theforeman.foreman 1.5.0 中添加

此子网的外部 IPAM 组。

仅当 _ipam=External IPAM_ 时才相关。

externalipam_proxy

字符串

此子网的外部 IPAM 代理。

仅当 _ipam=External IPAM_ 时才相关。

from_ip

字符串

主机 IP 分配池的第一个 IP 地址

gateway

字符串

子网网关 IP 地址

httpboot_proxy

字符串

此子网的 HTTP Boot 智能代理

ipam

字符串

此子网的 IPAM 模式

选项

  • "DHCP" ← (默认)

  • "内部 数据库"

  • "随机 数据库"

  • "EUI-64"

  • "外部 IPAM"

  • "无"

locations

列表 / 元素=字符串

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

mask

字符串

子网掩码。如果 _network_type=IPv4_ 且未提供 _cidr_ 前缀长度,则为必需

mtu

整数

MTU

name

字符串 / 必需

子网名称

network

字符串 / 必需

子网 IP 地址

network_type

字符串

子网类型

选项

  • "IPv4" ← (默认)

  • "IPv6"

organizations

列表 / 元素=字符串

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

parameters

列表 / 元素=字典

子网特定的主机参数

name

字符串 / 必需

参数名称

parameter_type

字符串

参数类型

选项

  • "string" ← (默认)

  • "布尔"

  • "整数"

  • "实数"

  • "数组"

  • "哈希"

  • "yaml"

  • "json"

value

任意 / 必需

参数的值

password

字符串 / 必需

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

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

remote_execution_proxies

列表 / 元素=字符串

此子网的远程执行智能代理

仅当安装了 remote_execution 插件时,此选项才可用。

由于插件中的错误,当与 _remote_execution < 4.1.0_ 一起使用时,这将始终报告 _changed=true_。

server_url

字符串 / 必需

Foreman 服务器的 URL。

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

state

字符串

实体的状态

选项

  • "present" ← (默认)

  • "absent"

template_proxy

字符串

此子网的模板智能代理

tftp_proxy

字符串

此子网的 TFTP 智能代理

to_ip

字符串

主机 IP 分配池的最后一个 IP 地址

updated_name

字符串

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

username

字符串 / 必需

访问 Foreman 服务器的用户名。

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

validate_certs

布尔值

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

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

选项

  • false

  • true ← (默认)

vlanid

整数

VLAN ID

属性

属性

支持

描述

check_mode

支持:完全支持

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

diff_mode

支持:完全支持

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

示例

- name: My subnet
  theforeman.foreman.subnet:
    name: "My subnet"
    description: "My description"
    network: "192.168.0.0"
    mask: "255.255.255.192"
    gateway: "192.168.0.1"
    from_ip: "192.168.0.2"
    to_ip: "192.168.0.42"
    boot_mode: "Static"
    dhcp_proxy: "smart-proxy1.foo.example.com"
    tftp_proxy: "smart-proxy1.foo.example.com"
    dns_proxy: "smart-proxy2.foo.example.com"
    template_proxy: "smart-proxy2.foo.example.com"
    vlanid: 452
    mtu: 9000
    domains:
      - "foo.example.com"
      - "bar.example.com"
    organizations:
      - "Example Org"
    locations:
      - "Toulouse"
    server_url: "https://foreman.example.com"
    username: "admin"
    password: "changeme"
    state: present

返回值

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

描述

entity

字典

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

返回:成功

subnets

列表 / 元素=字典

子网列表。

返回:成功

作者

  • Baptiste Agasse (@bagasse)