fortiswitch_system_dhcp_server – Configure DHCP servers in Fortinet’s FortiSwitch

New in version 1.0.0.

Synopsis

  • This module is able to configure a FortiSwitch 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 v7.0.0

Requirements

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

  • ansible>=2.11

FortiSW Version Compatibility


v7.0.0 v7.0.1 v7.0.2 v7.0.3
fortiswitch_system_dhcp_server yes yes yes yes

Parameters

  • enable_log - Enable/Disable logging for task. type: bool required: false default: False
  • member_path - Member attribute path to operate on. type: str
  • member_state - Add or delete a member under specified attribute path. type: str choices: present, absent
  • state - Indicates whether to create or remove the object. type: str required: true choices: present, absent
  • system_dhcp_server - Configure DHCP servers. type: dict
    • 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
    • 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 member_path: exclude_range:id
      • 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
    • 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 member_path: ip_range:id
      • end_ip - End of IP range. type: str
      • id - ID. type: int required: true
      • start_ip - Start of IP range. type: str
    • lease_time - Lease time in seconds, 0 means unlimited. type: int
    • 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 member_path: options:id
      • 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, fqdn
      • value - DHCP option value. type: str
    • reserved_address - Options for the DHCP server to assign IP settings to specific MAC addresses. type: list member_path: reserved_address:id
      • action - Options for the DHCP server to configure the client with the reserved MAC address. type: str choices: assign, block, reserved
      • circuit_id - Option 82 circuit-ID of the client that will get the reserved IP address. type: str
      • circuit_id_type - DHCP option type. type: str choices: hex, string
      • 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
      • remote_id - Option 82 remote-ID of the client that will get the reserved IP address. type: str
      • remote_id_type - DHCP option type. type: str choices: hex, string
      • type - DHCP reserved-address type. type: str choices: mac, option82
    • server_type - DHCP server can be a normal DHCP server or an IPsec DHCP server. type: str choices: regular
    • 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, 87, 16, 17, 18, 19, 20, 75, 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

Examples

- hosts: fortiswitch01
  collections:
    - fortinet.fortiswitch
  connection: httpapi
  vars:
   ansible_httpapi_use_ssl: yes
   ansible_httpapi_validate_certs: no
   ansible_httpapi_port: 443
  tasks:
  - name: Configure DHCP servers.
    fortiswitch_system_dhcp_server:
      state: "present"
      system_dhcp_server:
        auto_configuration: "disable"
        conflicted_ip_timeout: "4"
        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:  "13"
            start_ip: "<your_own_value>"
        filename: "<your_own_value>"
        id:  "16"
        interface: "<your_own_value> (source system.interface.name)"
        ip_mode: "range"
        ip_range:
         -
            end_ip: "<your_own_value>"
            id:  "21"
            start_ip: "<your_own_value>"
        lease_time: "23"
        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: "31"
            id:  "32"
            ip: "<your_own_value>"
            type: "hex"
            value: "<your_own_value>"
        reserved_address:
         -
            action: "assign"
            circuit_id: "<your_own_value>"
            circuit_id_type: "hex"
            description: "<your_own_value>"
            id:  "41"
            ip: "<your_own_value>"
            mac: "<your_own_value>"
            remote_id: "<your_own_value>"
            remote_id_type: "hex"
            type: "mac"
        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 fortiSwitch image returned: always type: str sample: 1547
  • http_method - Last method used to provision the content into FortiSwitch returned: always type: str sample: PUT
  • http_status - Last result given by FortiSwitch on last operation applied returned: always type: str sample: 200
  • mkey - Master key (id) used in the last call to FortiSwitch 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
  • serial - Serial number of the unit returned: always type: str sample: FS1D243Z13000122
  • status - Indication of the operation's result returned: always type: str sample: success
  • version - Version of the FortiSwitch returned: always type: str sample: v7.0.0

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)

Hint

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