fmgr_system_dhcp_server – Configure DHCP servers.

New in version 2.0.0.

Synopsis

  • This module is able to configure a FortiManager device.
  • Examples include all parameters and values need to be adjusted to data sources before usage.
  • Tested with FortiManager v6.x and v7.x.

Requirements

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

  • ansible>=2.9.0

FortiManager Version Compatibility


6.0.0
True
6.2.0 6.2.1 6.2.2 6.2.3 6.2.5 6.2.6 6.2.7 6.2.8 6.2.9 6.2.10
True True True True True True True True True True
6.4.0 6.4.1 6.4.2 6.4.3 6.4.4 6.4.5 6.4.6 6.4.7 6.4.8 6.4.9 6.4.10 6.4.11
True True True True True True True True True True True True
7.0.0 7.0.1 7.0.2 7.0.3 7.0.4 7.0.5 7.0.6 7.0.7
True True True True True True True True
7.2.0 7.2.1 7.2.2
True True True
7.4.0
True

Parameters

  • access_token -The token to access FortiManager without using username and password. type: str required: false
  • bypass_validation - Only set to True when module schema diffs with FortiManager API structure, module continues to execute without validating parameters. type: bool required: false default: False
  • enable_log - Enable/Disable logging for task. type: bool required: false default: False
  • forticloud_access_token - Access token of forticloud managed API users, this option is available with FortiManager later than 6.4.0. type: str required: false
  • proposed_method - The overridden method for the underlying Json RPC request. type: str required: false choices: set, update, add
  • rc_succeeded - The rc codes list with which the conditions to succeed will be overriden. type: list required: false
  • rc_failed - The rc codes list with which the conditions to fail will be overriden. type: list required: false
  • state - The directive to create, update or delete an object type: str required: true choices: present, absent
  • workspace_locking_adom - Acquire the workspace lock if FortiManager is running in workspace mode. type: str required: false choices: global, custom adom including root
  • workspace_locking_timeout - The maximum time in seconds to wait for other users to release workspace lock. type: integer required: false default: 300
  • adom - The parameter in requested url type: str required: true
  • system_dhcp_server - Configure DHCP servers. type: dict
    • auto-configuration - Enable/disable auto configuration. type: str choices: [disable, enable] more...
    • 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 more...
    • ddns-auth - DDNS authentication mode. type: str choices: [disable, tsig] more...
    • ddns-key - DDNS update key (base 64 encoding). type: str more...
    • ddns-keyname - DDNS update key name. type: str more...
    • ddns-server-ip - DDNS server IP. type: str more...
    • ddns-ttl - TTL. type: int more...
    • ddns-update - Enable/disable DDNS update for DHCP. type: str choices: [disable, enable] more...
    • ddns-update-override - Enable/disable DDNS update override for DHCP. type: str choices: [disable, enable] more...
    • ddns-zone - Zone of your domain name (ex. type: str more...
    • default-gateway - Default gateway IP address assigned by the DHCP server. type: str more...
    • dns-server1 - DNS server 1. type: str more...
    • dns-server2 - DNS server 2. type: str more...
    • dns-server3 - DNS server 3. type: str more...
    • dns-service - Options for assigning DNS servers to DHCP clients. type: str choices: [default, specify, local] more...
    • domain - Domain name suffix for the IP addresses that the DHCP server assigns to clients. type: str more...
    • exclude-range - Exclude-Range. type: array more...
      • end-ip - End of IP range. type: str more...
      • id - ID. type: int more...
      • start-ip - Start of IP range. type: str more...
      • vci-match - Enable/disable vendor class identifier (VCI) matching. type: str choices: [disable, enable] more...
      • vci-string - No description for the parameter type: str more...
      • lease-time - Lease time in seconds, 0 means default lease time. type: int more...
      • uci-match - Enable/disable user class identifier (UCI) matching. type: str choices: [disable, enable] more...
      • uci-string - No description for the parameter type: str more...
    • filename - Name of the boot file on the TFTP server. type: str more...
    • forticlient-on-net-status - Enable/disable FortiClient-On-Net service for this DHCP server. type: str choices: [disable, enable] more...
    • id - ID. type: int more...
    • interface - DHCP server can assign IP configurations to clients connected to this interface. type: str more...
    • ip-mode - Method used to assign client IP. type: str choices: [range, usrgrp] more...
    • ip-range - Ip-Range. type: array more...
      • end-ip - End of IP range. type: str more...
      • id - ID. type: int more...
      • start-ip - Start of IP range. type: str more...
      • vci-match - Enable/disable vendor class identifier (VCI) matching. type: str choices: [disable, enable] more...
      • vci-string - No description for the parameter type: str more...
      • lease-time - Lease time in seconds, 0 means default lease time. type: int more...
      • uci-match - Enable/disable user class identifier (UCI) matching. type: str choices: [disable, enable] more...
      • uci-string - No description for the parameter type: str more...
    • ipsec-lease-hold - DHCP over IPsec leases expire this many seconds after tunnel down (0 to disable forced-expiry). type: int more...
    • lease-time - Lease time in seconds, 0 means unlimited. type: int more...
    • mac-acl-default-action - MAC access control default action (allow or block assigning IP settings). type: str choices: [assign, block] more...
    • netmask - Netmask assigned by the DHCP server. type: str more...
    • next-server - IP address of a server (for example, a TFTP sever) that DHCP clients can download a boot file from. type: str more...
    • ntp-server1 - NTP server 1. type: str more...
    • ntp-server2 - NTP server 2. type: str more...
    • ntp-server3 - NTP server 3. type: str more...
    • ntp-service - Options for assigning Network Time Protocol (NTP) servers to DHCP clients. type: str choices: [default, specify, local] more...
    • options - Options. type: array more...
      • code - DHCP option code. type: int more...
      • id - ID. type: int more...
      • ip - DHCP option IPs. type: str more...
      • type - DHCP option type. type: str choices: [hex, string, ip, fqdn] more...
      • value - DHCP option value. type: str more...
      • vci-match - Enable/disable vendor class identifier (VCI) matching. type: str choices: [disable, enable] more...
      • vci-string - No description for the parameter type: str more...
      • uci-match - Enable/disable user class identifier (UCI) matching. type: str choices: [disable, enable] more...
      • uci-string - No description for the parameter type: str more...
    • reserved-address - Reserved-Address. type: array more...
      • action - Options for the DHCP server to configure the client with the reserved MAC address. type: str choices: [assign, block, reserved] more...
      • description - Description. type: str more...
      • id - ID. type: int more...
      • ip - IP address to be reserved for the MAC address. type: str more...
      • mac - MAC address of the client that will get the reserved IP address. type: str more...
      • circuit-id - Option 82 circuit-ID of the client that will get the reserved IP address. type: str more...
      • circuit-id-type - DHCP option type. type: str choices: [hex, string] more...
      • remote-id - Option 82 remote-ID of the client that will get the reserved IP address. type: str more...
      • remote-id-type - DHCP option type. type: str choices: [hex, string] more...
      • type - DHCP reserved-address type. type: str choices: [mac, option82] more...
    • server-type - DHCP server can be a normal DHCP server or an IPsec DHCP server. type: str choices: [regular, ipsec] more...
    • status - Enable/disable this DHCP configuration. type: str choices: [disable, enable] more...
    • tftp-server - One or more hostnames or IP addresses of the TFTP servers in quotes separated by spaces. type: str more...
    • timezone - Select the time zone to be assigned to DHCP clients. type: str choices: [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] more...
    • timezone-option - Options for the DHCP server to set the clients time zone. type: str choices: [disable, default, specify] more...
    • vci-match - Enable/disable vendor class identifier (VCI) matching. type: str choices: [disable, enable] more...
    • vci-string - One or more VCI strings in quotes separated by spaces. type: str more...
    • wifi-ac1 - WiFi Access Controller 1 IP address (DHCP option 138, RFC 5417). type: str more...
    • wifi-ac2 - WiFi Access Controller 2 IP address (DHCP option 138, RFC 5417). type: str more...
    • wifi-ac3 - WiFi Access Controller 3 IP address (DHCP option 138, RFC 5417). type: str more...
    • wins-server1 - WINS server 1. type: str more...
    • wins-server2 - WINS server 2. type: str more...
    • dns-server4 - DNS server 4. type: str more...
    • wifi-ac-service - Options for assigning WiFi Access Controllers to DHCP clients type: str choices: [specify, local] more...
    • auto-managed-status - Enable/disable use of this DHCP server once this interface has been assigned an IP address from FortiIPAM. type: str choices: [disable, enable] more...
    • dhcp-settings-from-fortiipam - Enable/disable populating of DHCP server settings from FortiIPAM. type: str choices: [disable, enable] more...
    • relay-agent - Relay agent IP. type: str more...
    • shared-subnet - Enable/disable shared subnet. type: str choices: [disable, enable] more...

Notes

Note

  • Running in workspace locking mode is supported in this FortiManager module, the top level parameters workspace_locking_adom and workspace_locking_timeout help do the work.
  • To create or update an object, use state: present directive.
  • To delete an object, use state: absent directive
  • Normally, running one module can fail when a non-zero rc is returned. you can also override the conditions to fail or succeed with parameters rc_failed and rc_succeeded

Examples

- name: gathering fortimanager facts
  hosts: fortimanager00
  gather_facts: no
  connection: httpapi
  collections:
    - fortinet.fortimanager
  vars:
    ansible_httpapi_use_ssl: True
    ansible_httpapi_validate_certs: False
    ansible_httpapi_port: 443
  tasks:
   - name: retrieve all the DHCP servers
     fmgr_fact:
       facts:
           selector: 'system_dhcp_server'
           params:
               adom: 'ansible'
               server: 'your_value'
- hosts: fortimanager00
  collections:
    - fortinet.fortimanager
  connection: httpapi
  vars:
     ansible_httpapi_use_ssl: True
     ansible_httpapi_validate_certs: False
     ansible_httpapi_port: 443
  tasks:
   - name: Configure DHCP servers.
     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]>

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:

  • meta - The result of the request.returned: always type: dict
    • request_url - The full url requested. returned: always type: str sample: /sys/login/user
    • response_code - The status of api request. returned: always type: int sample: 0
    • response_data - The data body of the api response. returned: optional type: list or dict
    • response_message - The descriptive message of the api response. returned: always type: str sample: OK
    • system_information - The information of the target system. returned: always type: dict
  • rc - The status the request. returned: always type: int 0
  • version_check_warning - Warning if the parameters used in the playbook are not supported by the current FortiManager version. returned: if at least on parameter mpt supported by the current FortiManager version type: list 0

Status

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

Authors

  • Xinwei Du (@dux-fortinet)
  • Xing Li (@lix-fortinet)
  • Jie Xue (@JieX19)
  • Link Zheng (@chillancezen)
  • Frank Shen (@fshen01)
  • Hongbin Lu (@fgtdev-hblu)

Hint

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