fortios_system_dhcp_server – Configure DHCP servers in Fortinet’s FortiOS and FortiGate.

New in version 2.8.

Synopsis

  • This module is able to configure a FortiGate or FortiOS (FOS) device by allowing the user to set and modify system_dhcp feature and server category. Examples include all parameters and values need to be adjusted to datasources before usage. Tested with FOS v6.0.0

Requirements

The below requirements are needed on the host that executes this module.

  • ansible>=2.9.0

Parameters

  • access_token - Token-based authentication. Generated from GUI of Fortigate. type: str required: False
  • vdom - Virtual domain, among those defined previously. A vdom is a virtual instance of the FortiGate that can be configured and used as a different unit. type: str default: root
  • state - Indicates whether to create or remove the object. This attribute was present already in previous version in a deeper level. It has been moved out to this outer level. type: str required: False choices: present, absent
  • system_dhcp_server - Configure DHCP servers. type: dict
    • state - B(Deprecated) type: str required: False choices: present, absent
    • auto_configuration - Enable/disable auto configuration. type: str choices: disable, enable
    • conflicted_ip_timeout - Time in seconds to wait after a conflicted IP address is removed from the DHCP range before it can be reused. type: int
    • ddns_auth - DDNS authentication mode. type: str choices: disable, tsig
    • ddns_key - DDNS update key (base 64 encoding). type: str
    • ddns_keyname - DDNS update key name. type: str
    • ddns_server_ip - DDNS server IP. type: str
    • ddns_ttl - TTL. type: int
    • ddns_update - Enable/disable DDNS update for DHCP. type: str choices: disable, enable
    • ddns_update_override - Enable/disable DDNS update override for DHCP. type: str choices: disable, enable
    • ddns_zone - Zone of your domain name (ex. DDNS.com). type: str
    • default_gateway - Default gateway IP address assigned by the DHCP server. type: str
    • dns_server1 - DNS server 1. type: str
    • dns_server2 - DNS server 2. type: str
    • dns_server3 - DNS server 3. type: str
    • dns_service - Options for assigning DNS servers to DHCP clients. type: str choices: local, default, specify
    • domain - Domain name suffix for the IP addresses that the DHCP server assigns to clients. type: str
    • exclude_range - Exclude one or more ranges of IP addresses from being assigned to clients. type: list
      • end_ip - End of IP range. type: str
      • id - ID. type: int required: True
      • start_ip - Start of IP range. type: str
    • filename - Name of the boot file on the TFTP server. type: str
    • forticlient_on_net_status - Enable/disable FortiClient-On-Net service for this DHCP server. type: str choices: disable, enable
    • id - ID. type: int required: True
    • interface - DHCP server can assign IP configurations to clients connected to this interface. Source system.interface.name. type: str
    • ip_mode - Method used to assign client IP. type: str choices: range, usrgrp
    • ip_range - DHCP IP range configuration. type: list
      • end_ip - End of IP range. type: str
      • id - ID. type: int required: True
      • start_ip - Start of IP range. type: str
    • ipsec_lease_hold - DHCP over IPsec leases expire this many seconds after tunnel down (0 to disable forced-expiry). type: int
    • lease_time - Lease time in seconds, 0 means unlimited. type: int
    • mac_acl_default_action - MAC access control default action (allow or block assigning IP settings). type: str choices: assign, block
    • netmask - Netmask assigned by the DHCP server. type: str
    • next_server - IP address of a server (for example, a TFTP sever) that DHCP clients can download a boot file from. type: str
    • ntp_server1 - NTP server 1. type: str
    • ntp_server2 - NTP server 2. type: str
    • ntp_server3 - NTP server 3. type: str
    • ntp_service - Options for assigning Network Time Protocol (NTP) servers to DHCP clients. type: str choices: local, default, specify
    • options - DHCP options. type: list
      • code - DHCP option code. type: int
      • id - ID. type: int required: True
      • ip - DHCP option IPs. type: str
      • type - DHCP option type. type: str choices: hex, string, ip
      • value - DHCP option value. type: str
    • reserved_address - Options for the DHCP server to assign IP settings to specific MAC addresses. type: list
      • action - Options for the DHCP server to configure the client with the reserved MAC address. type: str choices: assign, block, reserved
      • description - Description. type: str
      • id - ID. type: int required: True
      • ip - IP address to be reserved for the MAC address. type: str
      • mac - MAC address of the client that will get the reserved IP address. type: str
    • server_type - DHCP server can be a normal DHCP server or an IPsec DHCP server. type: str choices: regular, ipsec
    • status - Enable/disable this DHCP configuration. type: str choices: disable, enable
    • tftp_server - One or more hostnames or IP addresses of the TFTP servers in quotes separated by spaces. type: list
      • tftp_server - TFTP server. type: str
    • timezone - Select the time zone to be assigned to DHCP clients. type: str choices: 1, 2, 3, 4, 5, 81, 6, 7, 08, 09, 10, 11, 12, 13, 74, 14, 77, 15, 16, 17, 18, 19, 20, 75, 87, 21, 22, 23, 24, 80, 79, 25, 26, 27, 28, 78, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 83, 84, 40, 85, 41, 42, 43, 39, 44, 46, 47, 51, 48, 45, 49, 50, 52, 53, 54, 55, 56, 57, 58, 59, 60, 62, 63, 61, 64, 65, 66, 67, 68, 69, 70, 71, 72, 0, 82, 73, 86, 76
    • timezone_option - Options for the DHCP server to set the client"s time zone. type: str choices: disable, default, specify
    • vci_match - Enable/disable vendor class identifier (VCI) matching. When enabled only DHCP requests with a matching VCI are served. type: str choices: disable, enable
    • vci_string - One or more VCI strings in quotes separated by spaces. type: list
      • vci_string - VCI strings. type: str
    • wifi_ac1 - WiFi Access Controller 1 IP address (DHCP option 138, RFC 5417). type: str
    • wifi_ac2 - WiFi Access Controller 2 IP address (DHCP option 138, RFC 5417). type: str
    • wifi_ac3 - WiFi Access Controller 3 IP address (DHCP option 138, RFC 5417). type: str
    • wins_server1 - WINS server 1. type: str
    • wins_server2 - WINS server 2. type: str

Notes

Note

  • Legacy fortiosapi has been deprecated, httpapi is the preferred way to run playbooks

Examples

- hosts: fortigates
  collections:
    - fortinet.fortios
  connection: httpapi
  vars:
   vdom: "root"
   ansible_httpapi_use_ssl: yes
   ansible_httpapi_validate_certs: no
   ansible_httpapi_port: 443
  tasks:
  - name: Configure DHCP servers.
    fortios_system_dhcp_server:
      vdom:  "{{ vdom }}"
      state: "present"
      access_token: "<your_own_value>"
      system_dhcp_server:
        auto_configuration: "disable"
        conflicted_ip_timeout: "4"
        ddns_auth: "disable"
        ddns_key: "<your_own_value>"
        ddns_keyname: "<your_own_value>"
        ddns_server_ip: "<your_own_value>"
        ddns_ttl: "9"
        ddns_update: "disable"
        ddns_update_override: "disable"
        ddns_zone: "<your_own_value>"
        default_gateway: "<your_own_value>"
        dns_server1: "<your_own_value>"
        dns_server2: "<your_own_value>"
        dns_server3: "<your_own_value>"
        dns_service: "local"
        domain: "<your_own_value>"
        exclude_range:
         -
            end_ip: "<your_own_value>"
            id:  "21"
            start_ip: "<your_own_value>"
        filename: "<your_own_value>"
        forticlient_on_net_status: "disable"
        id:  "25"
        interface: "<your_own_value> (source system.interface.name)"
        ip_mode: "range"
        ip_range:
         -
            end_ip: "<your_own_value>"
            id:  "30"
            start_ip: "<your_own_value>"
        ipsec_lease_hold: "32"
        lease_time: "33"
        mac_acl_default_action: "assign"
        netmask: "<your_own_value>"
        next_server: "<your_own_value>"
        ntp_server1: "<your_own_value>"
        ntp_server2: "<your_own_value>"
        ntp_server3: "<your_own_value>"
        ntp_service: "local"
        options:
         -
            code: "42"
            id:  "43"
            ip: "<your_own_value>"
            type: "hex"
            value: "<your_own_value>"
        reserved_address:
         -
            action: "assign"
            description: "<your_own_value>"
            id:  "50"
            ip: "<your_own_value>"
            mac: "<your_own_value>"
        server_type: "regular"
        status: "disable"
        tftp_server:
         -
            tftp_server: "<your_own_value>"
        timezone: "01"
        timezone_option: "disable"
        vci_match: "disable"
        vci_string:
         -
            vci_string: "<your_own_value>"
        wifi_ac1: "<your_own_value>"
        wifi_ac2: "<your_own_value>"
        wifi_ac3: "<your_own_value>"
        wins_server1: "<your_own_value>"
        wins_server2: "<your_own_value>"

Return Values

Common return values are documented: https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values, the following are the fields unique to this module:

  • build - Build number of the fortigate image returned: always type: str sample: 1547
  • http_method - Last method used to provision the content into FortiGate returned: always type: str sample: PUT
  • http_status - Last result given by FortiGate on last operation applied returned: always type: str sample: 200
  • mkey - Master key (id) used in the last call to FortiGate returned: success type: str sample: id
  • name - Name of the table used to fulfill the request returned: always type: str sample: urlfilter
  • path - Path of the table used to fulfill the request returned: always type: str sample: webfilter
  • revision - Internal revision number returned: always type: str sample: 17.0.2.10658
  • serial - Serial number of the unit returned: always type: str sample: FGVMEVYYQT3AB5352
  • status - Indication of the operation's result returned: always type: str sample: success
  • vdom - Virtual domain used returned: always type: str sample: root
  • version - Version of the FortiGate returned: always type: str sample: v5.6.3

Status

  • This module is not guaranteed to have a backwards compatible interface.

Authors

  • Link Zheng (@chillancezen)
  • Jie Xue (@JieX19)
  • Hongbin Lu (@fgtdev-hblu)
  • Frank Shen (@frankshen01)
  • Miguel Angel Munoz (@mamunozgonzalez)
  • Nicolas Thomas (@thomnico)

Hint

If you notice any issues in this documentation, you can create a pull request to improve it.