fortinet.fortimanager.fmgr_system_dhcp_server 模块 – 配置 DHCP 服务器。

注意

此模块是 fortinet.fortimanager 集合(版本 2.8.2)的一部分。

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

要安装它,请使用:ansible-galaxy collection install fortinet.fortimanager

要在 playbook 中使用它,请指定:fortinet.fortimanager.fmgr_system_dhcp_server

fortinet.fortimanager 2.0.0 中的新增功能

概要

  • 此模块能够配置 FortiManager 设备。

  • 示例包括所有参数和值,在使用前需要根据数据源进行调整。

参数

参数

注释

access_token

字符串

无需使用用户名和密码即可访问 FortiManager 的令牌。

adom

字符串 / 必需

请求 URL 中的参数 (adom)。

bypass_validation

布尔值

仅当模块架构与 FortiManager API 结构不同时设置为 True,模块将继续执行而不验证参数。

选项

  • false ← (默认)

  • true

enable_log

布尔值

启用/禁用任务日志记录。

选项

  • false ← (默认)

  • true

forticloud_access_token

字符串

使用 FortiCloud API 访问令牌对 Ansible 客户端进行身份验证。

proposed_method

字符串

底层 Json RPC 请求的重写方法。

选项

  • "update"

  • "set"

  • "add"

rc_failed

列表 / 元素=整数

将覆盖失败条件的 rc 代码列表。

rc_succeeded

列表 / 元素=整数

将覆盖成功条件的 rc 代码列表。

state

字符串 / 必需

创建、更新或删除对象的指令。

选项

  • "present"

  • "absent"

system_dhcp_server

字典

顶级参数集。

auto_configuration

别名:auto-configuration

字符串

启用/禁用自动配置。

选项

  • "disable"

  • "enable"

auto_managed_status

别名:auto-managed-status

字符串

一旦从 FortiIPAM 为此接口分配了 IP 地址,则启用/禁用此 DHCP 服务器的使用。

选项

  • "disable"

  • "enable"

conflicted_ip_timeout

别名:conflicted-ip-timeout

整数

在冲突的 IP 地址从 DHCP 范围中删除后,等待多少秒才能重新使用。

ddns_auth

别名:ddns-auth

字符串

DDNS 身份验证模式。

选项

  • "disable"

  • "tsig"

ddns_key

别名:ddns-key

任意

(列表或字符串)DDNS 更新密钥

ddns_keyname

别名:ddns-keyname

字符串

DDNS 更新密钥名称。

ddns_server_ip

别名:ddns-server-ip

字符串

DDNS 服务器 IP。

ddns_ttl

别名:ddns-ttl

整数

TTL。

ddns_update

别名:ddns-update

字符串

启用/禁用 DHCP 的 DDNS 更新。

选项

  • "disable"

  • "enable"

ddns_update_override

别名:ddns-update-override

字符串

启用/禁用 DHCP 的 DDNS 更新覆盖。

选项

  • "disable"

  • "enable"

ddns_zone

别名:ddns-zone

字符串

您的域名区域

default_gateway

别名:default-gateway

字符串

DHCP 服务器分配的默认网关 IP 地址。

dhcp_settings_from_fortiipam

别名:dhcp-settings-from-fortiipam

字符串

启用/禁用从 FortiIPAM 填充 DHCP 服务器设置。

选项

  • "disable"

  • "enable"

dns_server1

别名:dns-server1

字符串

DNS 服务器 1。

dns_server2

别名:dns-server2

字符串

DNS 服务器 2。

dns_server3

别名:dns-server3

字符串

DNS 服务器 3。

dns_server4

别名:dns-server4

字符串

DNS 服务器 4。

dns_service

别名:dns-service

字符串

用于为 DHCP 客户端分配 DNS 服务器的选项。

选项

  • "default"

  • "specify"

  • "local"

domain

字符串

DHCP 服务器分配给客户端的 IP 地址的域名后缀。

exclude_range

别名:exclude-range

列表 / 元素=字典

排除范围。

end_ip

别名:end-ip

字符串

IP 范围的结束。

id

整数

ID。

lease_time

别名:lease-time

整数

租用时间(秒),0 表示默认租用时间。

start_ip

别名:start-ip

字符串

IP 范围的起始。

uci_match

别名: uci-match

字符串

启用/禁用用户类标识符

选项

  • "disable"

  • "enable"

uci_string

别名: uci-string

任意

(列表) 一个或多个用引号括起来并用空格分隔的 UCI 字符串。

vci_match

别名: vci-match

字符串

启用/禁用供应商类标识符

选项

  • "disable"

  • "enable"

vci_string

别名: vci-string

任意

(列表) 一个或多个用引号括起来并用空格分隔的 VCI 字符串。

filename

字符串

TFTP 服务器上的引导文件名。

forticlient_on_net_status

别名: forticlient-on-net-status

字符串

为此 DHCP 服务器启用/禁用 FortiClient-On-Net 服务。

选项

  • "disable"

  • "enable"

id

整数 / 必需

ID。

interface

字符串

DHCP 服务器可以将 IP 配置分配给连接到此接口的客户端。

ip_mode

别名: ip-mode

字符串

用于分配客户端 IP 的方法。

选项

  • "range"

  • "usrgrp"

ip_range

别名: ip-range

列表 / 元素=字典

IP 范围。

end_ip

别名:end-ip

字符串

IP 范围的结束。

id

整数

ID。

lease_time

别名:lease-time

整数

租用时间(秒),0 表示默认租用时间。

start_ip

别名:start-ip

字符串

IP 范围的起始。

uci_match

别名: uci-match

字符串

启用/禁用用户类标识符

选项

  • "disable"

  • "enable"

uci_string

别名: uci-string

任意

(列表) 一个或多个用引号括起来并用空格分隔的 UCI 字符串。

vci_match

别名: vci-match

字符串

启用/禁用供应商类标识符

选项

  • "disable"

  • "enable"

vci_string

别名: vci-string

任意

(列表) 一个或多个用引号括起来并用空格分隔的 VCI 字符串。

ipsec_lease_hold

别名: ipsec-lease-hold

整数

IPsec DHCP 租约在隧道关闭后过期的时间(秒)

lease_time

别名:lease-time

整数

租约时间(秒),0 表示无限期。

mac_acl_default_action

别名: mac-acl-default-action

字符串

MAC 访问控制默认操作

选项

  • "assign"

  • "block"

netmask

字符串

DHCP 服务器分配的网络掩码。

next_server

别名: next-server

字符串

服务器的 IP 地址

ntp_server1

别名: ntp-server1

字符串

NTP 服务器 1。

ntp_server2

别名: ntp-server2

字符串

NTP 服务器 2。

ntp_server3

别名: ntp-server3

字符串

NTP 服务器 3。

ntp_service

别名: ntp-service

字符串

用于分配网络时间协议的选项

选项

  • "default"

  • "specify"

  • "local"

options

列表 / 元素=字典

选项。

code

整数

DHCP 选项代码。

id

整数

ID。

ip

任意

(列表) DHCP 选项 IP。

type

字符串

DHCP 选项类型。

选项

  • "hex"

  • "string"

  • "ip"

  • "fqdn"

uci_match

别名: uci-match

字符串

启用/禁用用户类标识符

选项

  • "disable"

  • "enable"

uci_string

别名: uci-string

任意

(列表) 一个或多个用引号括起来并用空格分隔的 UCI 字符串。

value

字符串

DHCP 选项值。

vci_match

别名: vci-match

字符串

启用/禁用供应商类标识符

选项

  • "disable"

  • "enable"

vci_string

别名: vci-string

任意

(列表) 一个或多个用引号括起来并用空格分隔的 VCI 字符串。

relay_agent

别名: relay-agent

字符串

中继代理 IP。

reserved_address

别名: reserved-address

列表 / 元素=字典

保留地址。

action

字符串

DHCP 服务器使用保留的 MAC 地址配置客户端的选项。

选项

  • "assign"

  • "block"

  • "reserved"

circuit_id

别名: circuit-id

字符串

将获得保留 IP 地址的客户端的选项 82 电路 ID。

circuit_id_type

别名: circuit-id-type

字符串

DHCP 选项类型。

选项

  • "hex"

  • "string"

description

字符串

描述。

id

整数

ID。

ip

字符串

要为 MAC 地址保留的 IP 地址。

mac

字符串

将获得保留 IP 地址的客户端的 MAC 地址。

remote_id

别名: remote-id

字符串

将获得保留 IP 地址的客户端的选项 82 远程 ID。

remote_id_type

别名: remote-id-type

字符串

DHCP 选项类型。

选项

  • "hex"

  • "string"

type

字符串

DHCP 保留地址类型。

选项

  • "mac"

  • "option82"

server_type

别名: server-type

字符串

DHCP 服务器可以是普通的 DHCP 服务器或 IPsec DHCP 服务器。

选项

  • "regular"

  • "ipsec"

shared_subnet

别名: shared-subnet

字符串

启用/禁用共享子网。

选项

  • "disable"

  • "enable"

status

字符串

启用/禁用此 DHCP 配置。

选项

  • "disable"

  • "enable"

tftp_server

别名: tftp-server

任意

(列表) 一个或多个 TFTP 服务器的主机名或 IP 地址,用引号括起来,并用空格分隔。

timezone

字符串

选择要分配给 DHCP 客户端的时区。

选项

  • "00"

  • "01"

  • "02"

  • "03"

  • "04"

  • "05"

  • "06"

  • "07"

  • "08"

  • "09"

  • "10"

  • "11"

  • "12"

  • "13"

  • "14"

  • "15"

  • "16"

  • "17"

  • "18"

  • "19"

  • "20"

  • "21"

  • "22"

  • "23"

  • "24"

  • "25"

  • "26"

  • "27"

  • "28"

  • "29"

  • "30"

  • "31"

  • "32"

  • "33"

  • "34"

  • "35"

  • "36"

  • "37"

  • "38"

  • "39"

  • "40"

  • "41"

  • "42"

  • "43"

  • "44"

  • "45"

  • "46"

  • "47"

  • "48"

  • "49"

  • "50"

  • "51"

  • "52"

  • "53"

  • "54"

  • "55"

  • "56"

  • "57"

  • "58"

  • "59"

  • "60"

  • "61"

  • "62"

  • "63"

  • "64"

  • "65"

  • "66"

  • "67"

  • "68"

  • "69"

  • "70"

  • "71"

  • "72"

  • "73"

  • "74"

  • "75"

  • "76"

  • "77"

  • "78"

  • "79"

  • "80"

  • "81"

  • "82"

  • "83"

  • "84"

  • "85"

  • "86"

  • "87"

timezone_option

别名: timezone-option

字符串

DHCP 服务器设置客户端时区的选项。

选项

  • "disable"

  • "default"

  • "specify"

vci_match

别名: vci-match

字符串

启用/禁用供应商类标识符

选项

  • "disable"

  • "enable"

vci_string

别名: vci-string

任意

(列表) 一个或多个用引号括起来并用空格分隔的 VCI 字符串。

wifi_ac1

别名: wifi-ac1

字符串

WiFi 接入控制器 1 IP 地址

wifi_ac2

别名: wifi-ac2

字符串

WiFi 接入控制器 2 IP 地址

wifi_ac3

别名: wifi-ac3

字符串

WiFi 接入控制器 3 IP 地址

wifi_ac_service

别名: wifi-ac-service

字符串

用于将 WiFi 接入控制器分配给 DHCP 客户端的选项

选项

  • "specify"

  • "local"

wins_server1

别名: wins-server1

字符串

WINS 服务器 1。

wins_server2

别名: wins-server2

字符串

WINS 服务器 2。

workspace_locking_adom

字符串

在工作区模式下运行的 FortiManager 的锁定 ADOM,值可以是 global 和其他包括 root 的值。

workspace_locking_timeout

整数

等待其他用户释放工作区锁定的最长时间(秒)。

默认值: 300

注释

注意

  • 从 2.4.0 版本开始,所有输入参数都使用下划线命名约定 (snake_case) 命名。请将诸如 “var-name” 的参数更改为 “var_name”。旧的参数名称仍然可用,但您将收到弃用警告。您可以通过在 ansible.cfg 中设置 deprecation_warnings=False 来忽略此警告。

  • 此 FortiManager 模块支持在工作区锁定模式下运行,顶层参数 workspace_locking_adom 和 workspace_locking_timeout 有助于完成这项工作。

  • 要创建或更新对象,请使用 state present 指令。

  • 要删除对象,请使用 state absent 指令。

  • 通常,当返回非零 rc 时,运行一个模块可能会失败。您还可以使用参数 rc_failed 和 rc_succeeded 覆盖失败或成功的条件

示例

- name: Example playbook
  hosts: fortimanagers
  connection: httpapi
  vars:
    ansible_httpapi_use_ssl: true
    ansible_httpapi_validate_certs: false
    ansible_httpapi_port: 443
  tasks:
    - name: Configure DHCP servers.
      fortinet.fortimanager.fmgr_system_dhcp_server:
        bypass_validation: false
        adom: ansible
        state: present
        system_dhcp_server:
          auto-configuration: enable # <value in [disable, enable]>
          default-gateway: "222.222.222.1"
          filename: ansible-file
          id: 1
          interface: any
          ip-mode: range # <value in [range, usrgrp]>
          ip-range:
            - end-ip: 222.222.222.22
              id: 1
              start-ip: 222.222.222.2
          netmask: 255.255.255.0
          server-type: regular # <value in [regular, ipsec]>
          status: disable # <value in [disable, enable]>

- name: Gathering fortimanager facts
  hosts: fortimanagers
  gather_facts: false
  connection: httpapi
  vars:
    ansible_httpapi_use_ssl: true
    ansible_httpapi_validate_certs: false
    ansible_httpapi_port: 443
  tasks:
    - name: Retrieve all the DHCP servers
      fortinet.fortimanager.fmgr_fact:
        facts:
          selector: "system_dhcp_server"
          params:
            adom: "ansible"
            server: "your_value"

返回值

通用返回值已在此处文档中说明,以下是此模块特有的字段

描述

meta

字典

请求的结果。

返回: 始终

request_url

字符串

请求的完整 URL。

返回: 始终

示例: "/sys/login/user"

response_code

整数

API 请求的状态。

返回: 始终

示例: 0

response_data

列表 / 元素=字符串

API 响应。

返回: 始终

response_message

字符串

API 响应的描述性消息。

返回: 始终

示例: "OK."

system_information

字典

目标系统的信息。

返回: 始终

rc

整数

请求的状态。

返回: 始终

示例: 0

version_check_warning

列表 / 元素=字符串

如果 playbook 中使用的参数不受当前 FortiManager 版本支持,则会发出警告。

返回: 复杂类型

作者

  • Xinwei Du (@dux-fortinet)

  • Xing Li (@lix-fortinet)

  • Jie Xue (@JieX19)

  • Link Zheng (@chillancezen)

  • Frank Shen (@fshen01)

  • Hongbin Lu (@fgtdev-hblu)