fmgd_vpn_ipsec_phase2 – Configure VPN autokey tunnel.

Added in version 1.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 v7.x.

Requirements

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

  • ansible-core>=2.16.0

FortiManager Version Compatibility

Supported Version Ranges: v7.2.6 -> v7.2.12, v7.4.3 -> latest

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
  • device - The parameter in requested url type: str required: true
  • vdom - The parameter in requested url type: str required: true
  • vpn_ipsec_phase2 - Configure VPN autokey tunnel. type: dict
    • add_route (Alias name: add-route) Enable/disable automatic route addition. type: str choices: [disable, enable, phase1] more...
    • auto_negotiate (Alias name: auto-negotiate) Enable/disable ipsec sa auto-negotiation. type: str choices: [disable, enable] more...
    • comments Comment. type: str more...
    • dhcp_ipsec (Alias name: dhcp-ipsec) Enable/disable dhcp-ipsec. type: str choices: [disable, enable] more...
    • dhgrp Phase2 dh group. type: list choices: [1, 2, 5, 14, 15, 16, 17, 18, 19, 20, 21, 27, 28, 29, 30, 31, 32] more...
    • diffserv Enable/disable applying dscp value to the ipsec tunnel outer ip header. type: str choices: [disable, enable] more...
    • diffservcode Dscp value to be applied to the ipsec tunnel outer ip header. type: str more...
    • dst_addr_type (Alias name: dst-addr-type) Remote proxy id type. type: str choices: [subnet, range, ip, name] more...
    • dst_end_ip (Alias name: dst-end-ip) Remote proxy id ipv4 end. type: str more...
    • dst_end_ip6 (Alias name: dst-end-ip6) Remote proxy id ipv6 end. type: str more...
    • dst_name (Alias name: dst-name) Remote proxy id name. type: list more...
    • dst_name6 (Alias name: dst-name6) Remote proxy id name. type: list more...
    • dst_port (Alias name: dst-port) Quick mode destination port (1 - 65535 or 0 for all). type: int more...
    • dst_start_ip (Alias name: dst-start-ip) Remote proxy id ipv4 start. type: str more...
    • dst_start_ip6 (Alias name: dst-start-ip6) Remote proxy id ipv6 start. type: str more...
    • dst_subnet (Alias name: dst-subnet) Remote proxy id ipv4 subnet. type: list more...
    • dst_subnet6 (Alias name: dst-subnet6) Remote proxy id ipv6 subnet. type: str more...
    • encapsulation Esp encapsulation mode. type: str choices: [tunnel-mode, transport-mode] more...
    • inbound_dscp_copy (Alias name: inbound-dscp-copy) Enable/disable copying of the dscp in the esp header to the inner ip header. type: str choices: [disable, enable, phase1] more...
    • initiator_ts_narrow (Alias name: initiator-ts-narrow) Enable/disable traffic selector narrowing for ikev2 initiator. type: str choices: [disable, enable] more...
    • ipv4_df (Alias name: ipv4-df) Enable/disable setting and resetting of ipv4 dont fragment bit. type: str choices: [disable, enable] more...
    • keepalive Enable/disable keep alive. type: str choices: [disable, enable] more...
    • keylife_type (Alias name: keylife-type) Keylife type. type: str choices: [seconds, kbs, both] more...
    • keylifekbs Phase2 key life in number of kilobytes of traffic (5120 - 4294967295). type: int more...
    • keylifeseconds Phase2 key life in time in seconds (120 - 172800). type: int more...
    • l2tp Enable/disable l2tp over ipsec. type: str choices: [disable, enable] more...
    • name Ipsec tunnel name. type: str more...
    • pfs Enable/disable pfs feature. type: str choices: [disable, enable] more...
    • phase1name Phase 1 determines the options required for phase 2. type: list more...
    • proposal Phase2 proposal. type: str choices: [null-md5, null-sha1, des-null, 3des-null, des-md5, des-sha1, 3des-md5, 3des-sha1, aes128-md5, aes128-sha1, aes192-md5, aes192-sha1, aes256-md5, aes256-sha1, aes128-null, aes192-null, aes256-null, null-sha256, des-sha256, 3des-sha256, aes128-sha256, aes192-sha256, aes256-sha256, des-sha384, des-sha512, 3des-sha384, 3des-sha512, aes128-sha384, aes128-sha512, aes192-sha384, aes192-sha512, aes256-sha384, aes256-sha512, null-sha384, null-sha512, aria128-null, aria128-md5, aria128-sha1, aria128-sha256, aria128-sha384, aria128-sha512, aria192-null, aria192-md5, aria192-sha1, aria192-sha256, aria192-sha384, aria192-sha512, aria256-null, aria256-md5, aria256-sha1, aria256-sha256, aria256-sha384, aria256-sha512, seed-null, seed-md5, seed-sha1, seed-sha256, seed-sha384, seed-sha512, aes128gcm, aes256gcm, chacha20poly1305] more...
    • protocol Quick mode protocol selector (1 - 255 or 0 for all). type: int more...
    • replay Enable/disable replay detection. type: str choices: [disable, enable] more...
    • route_overlap (Alias name: route-overlap) Action for overlapping routes. type: str choices: [use-old, use-new, allow] more...
    • selector_match (Alias name: selector-match) Match type to use when comparing selectors. type: str choices: [auto, subset, exact] more...
    • single_source (Alias name: single-source) Enable/disable single source ip restriction. type: str choices: [disable, enable] more...
    • src_addr_type (Alias name: src-addr-type) Local proxy id type. type: str choices: [subnet, range, ip, name] more...
    • src_end_ip (Alias name: src-end-ip) Local proxy id end. type: str more...
    • src_end_ip6 (Alias name: src-end-ip6) Local proxy id ipv6 end. type: str more...
    • src_name (Alias name: src-name) Local proxy id name. type: list more...
    • src_name6 (Alias name: src-name6) Local proxy id name. type: list more...
    • src_port (Alias name: src-port) Quick mode source port (1 - 65535 or 0 for all). type: int more...
    • src_start_ip (Alias name: src-start-ip) Local proxy id start. type: str more...
    • src_start_ip6 (Alias name: src-start-ip6) Local proxy id ipv6 start. type: str more...
    • src_subnet (Alias name: src-subnet) Local proxy id subnet. type: list more...
    • src_subnet6 (Alias name: src-subnet6) Local proxy id ipv6 subnet. type: str more...
    • use_natip (Alias name: use-natip) Enable to use the fortigate public ip as the source selector when outbound nat is used. type: str choices: [disable, enable] more...
    • addke1 Phase2 addke1 group. type: list choices: [0, 1080, 1081, 1082, 1083, 1084, 1085, 1089, 1090, 1091, 1092, 1093, 1094, 35, 36, 37] more...
    • addke2 Phase2 addke2 group. type: list choices: [0, 1080, 1081, 1082, 1083, 1084, 1085, 1089, 1090, 1091, 1092, 1093, 1094, 35, 36, 37] more...
    • addke3 Phase2 addke3 group. type: list choices: [0, 1080, 1081, 1082, 1083, 1084, 1085, 1089, 1090, 1091, 1092, 1093, 1094, 35, 36, 37] more...
    • addke4 Phase2 addke4 group. type: list choices: [0, 1080, 1081, 1082, 1083, 1084, 1085, 1089, 1090, 1091, 1092, 1093, 1094, 35, 36, 37] more...
    • addke5 Phase2 addke5 group. type: list choices: [0, 1080, 1081, 1082, 1083, 1084, 1085, 1089, 1090, 1091, 1092, 1093, 1094, 35, 36, 37] more...
    • addke6 Phase2 addke6 group. type: list choices: [0, 1080, 1081, 1082, 1083, 1084, 1085, 1089, 1090, 1091, 1092, 1093, 1094, 35, 36, 37] more...
    • addke7 Phase2 addke7 group. type: list choices: [0, 1080, 1081, 1082, 1083, 1084, 1085, 1089, 1090, 1091, 1092, 1093, 1094, 35, 36, 37] 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: Example playbook (generated based on argument schema)
  hosts: fortimanagers
  connection: httpapi
  gather_facts: false
  vars:
    ansible_httpapi_use_ssl: true
    ansible_httpapi_validate_certs: false
    ansible_httpapi_port: 443
  tasks:
    - name: Configure VPN autokey tunnel.
      fortinet.fmgdevice.fmgd_vpn_ipsec_phase2:
        # bypass_validation: false
        # workspace_locking_adom: <global or your adom name>
        # workspace_locking_timeout: 300
        # rc_succeeded: [0, -2, -3, ...]
        # rc_failed: [-2, -3, ...]
        device: <your own value>
        vdom: <your own value>
        state: present # <value in [present, absent]>
        vpn_ipsec_phase2:
          name: "your value" # Required variable, string
          # add_route: <value in [disable, enable, phase1]>
          # auto_negotiate: <value in [disable, enable]>
          # comments: <string>
          # dhcp_ipsec: <value in [disable, enable]>
          # dhgrp:
          #   - "1"
          #   - "2"
          #   - "5"
          #   - "14"
          #   - "15"
          #   - "16"
          #   - "17"
          #   - "18"
          #   - "19"
          #   - "20"
          #   - "21"
          #   - "27"
          #   - "28"
          #   - "29"
          #   - "30"
          #   - "31"
          #   - "32"
          # diffserv: <value in [disable, enable]>
          # diffservcode: <string>
          # dst_addr_type: <value in [subnet, range, ip, ...]>
          # dst_end_ip: <string>
          # dst_end_ip6: <string>
          # dst_name: <list or string>
          # dst_name6: <list or string>
          # dst_port: <integer>
          # dst_start_ip: <string>
          # dst_start_ip6: <string>
          # dst_subnet: <list or string>
          # dst_subnet6: <string>
          # encapsulation: <value in [tunnel-mode, transport-mode]>
          # inbound_dscp_copy: <value in [disable, enable, phase1]>
          # initiator_ts_narrow: <value in [disable, enable]>
          # ipv4_df: <value in [disable, enable]>
          # keepalive: <value in [disable, enable]>
          # keylife_type: <value in [seconds, kbs, both]>
          # keylifekbs: <integer>
          # keylifeseconds: <integer>
          # l2tp: <value in [disable, enable]>
          # pfs: <value in [disable, enable]>
          # phase1name: <list or string>
          # proposal: <value in [null-md5, null-sha1, des-null, ...]>
          # protocol: <integer>
          # replay: <value in [disable, enable]>
          # route_overlap: <value in [use-old, use-new, allow]>
          # selector_match: <value in [auto, subset, exact]>
          # single_source: <value in [disable, enable]>
          # src_addr_type: <value in [subnet, range, ip, ...]>
          # src_end_ip: <string>
          # src_end_ip6: <string>
          # src_name: <list or string>
          # src_name6: <list or string>
          # src_port: <integer>
          # src_start_ip: <string>
          # src_start_ip6: <string>
          # src_subnet: <list or string>
          # src_subnet6: <string>
          # use_natip: <value in [disable, enable]>
          # addke1:
          #   - "0"
          #   - "1080"
          #   - "1081"
          #   - "1082"
          #   - "1083"
          #   - "1084"
          #   - "1085"
          #   - "1089"
          #   - "1090"
          #   - "1091"
          #   - "1092"
          #   - "1093"
          #   - "1094"
          #   - "35"
          #   - "36"
          #   - "37"
          # addke2:
          #   - "0"
          #   - "1080"
          #   - "1081"
          #   - "1082"
          #   - "1083"
          #   - "1084"
          #   - "1085"
          #   - "1089"
          #   - "1090"
          #   - "1091"
          #   - "1092"
          #   - "1093"
          #   - "1094"
          #   - "35"
          #   - "36"
          #   - "37"
          # addke3:
          #   - "0"
          #   - "1080"
          #   - "1081"
          #   - "1082"
          #   - "1083"
          #   - "1084"
          #   - "1085"
          #   - "1089"
          #   - "1090"
          #   - "1091"
          #   - "1092"
          #   - "1093"
          #   - "1094"
          #   - "35"
          #   - "36"
          #   - "37"
          # addke4:
          #   - "0"
          #   - "1080"
          #   - "1081"
          #   - "1082"
          #   - "1083"
          #   - "1084"
          #   - "1085"
          #   - "1089"
          #   - "1090"
          #   - "1091"
          #   - "1092"
          #   - "1093"
          #   - "1094"
          #   - "35"
          #   - "36"
          #   - "37"
          # addke5:
          #   - "0"
          #   - "1080"
          #   - "1081"
          #   - "1082"
          #   - "1083"
          #   - "1084"
          #   - "1085"
          #   - "1089"
          #   - "1090"
          #   - "1091"
          #   - "1092"
          #   - "1093"
          #   - "1094"
          #   - "35"
          #   - "36"
          #   - "37"
          # addke6:
          #   - "0"
          #   - "1080"
          #   - "1081"
          #   - "1082"
          #   - "1083"
          #   - "1084"
          #   - "1085"
          #   - "1089"
          #   - "1090"
          #   - "1091"
          #   - "1092"
          #   - "1093"
          #   - "1094"
          #   - "35"
          #   - "36"
          #   - "37"
          # addke7:
          #   - "0"
          #   - "1080"
          #   - "1081"
          #   - "1082"
          #   - "1083"
          #   - "1084"
          #   - "1085"
          #   - "1089"
          #   - "1090"
          #   - "1091"
          #   - "1092"
          #   - "1093"
          #   - "1094"
          #   - "35"
          #   - "36"
          #   - "37"

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 sample: 0
  • version_check_warning - Warning if the parameters used in the playbook are not supported by the current FortiManager version. returned: if at least one parameter not supported by the current FortiManager version type: list

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)