| 1 |
|
| 2 |
from __future__ import absolute_import, division, print_function |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
__metaclass__ = type |
| 7 |
|
| 8 |
ANSIBLE_METADATA = {'status': ['preview'], |
| 9 |
'supported_by': 'community', |
| 10 |
'metadata_version': '1.1'} |
| 11 |
|
| 12 |
DOCUMENTATION = ''' |
| 13 |
--- |
| 14 |
module: fmgr_switchcontroller_fortilinksettings |
| 15 |
short_description: Configure integrated FortiLink settings for FortiSwitch. |
| 16 |
version_added: "2.2.0" |
| 17 |
extends_documentation_fragment: |
| 18 |
- fortinet.fortimanager.general |
| 19 |
- fortinet.fortimanager.general.full_crud |
| 20 |
options: |
| 21 |
revision_note: |
| 22 |
description: The change note that can be specified when an object is created or updated. |
| 23 |
type: str |
| 24 |
adom: |
| 25 |
description: The parameter (adom) in requested url. |
| 26 |
type: str |
| 27 |
required: true |
| 28 |
switchcontroller_fortilinksettings: |
| 29 |
description: The top level parameters set. |
| 30 |
required: false |
| 31 |
type: dict |
| 32 |
suboptions: |
| 33 |
fortilink: |
| 34 |
type: str |
| 35 |
description: FortiLink interface to which this fortilink-setting belongs. |
| 36 |
inactive_timer: |
| 37 |
aliases: ['inactive-timer'] |
| 38 |
type: int |
| 39 |
description: Time interval |
| 40 |
link_down_flush: |
| 41 |
aliases: ['link-down-flush'] |
| 42 |
type: str |
| 43 |
description: Clear NAC and dynamic devices on switch ports on link down event. |
| 44 |
choices: ['disable', 'enable'] |
| 45 |
nac_ports: |
| 46 |
aliases: ['nac-ports'] |
| 47 |
type: dict |
| 48 |
description: Nac ports. |
| 49 |
suboptions: |
| 50 |
lan_segment: |
| 51 |
aliases: ['lan-segment'] |
| 52 |
type: str |
| 53 |
description: Enable/disable LAN segment feature on the FortiLink interface. |
| 54 |
choices: ['disabled', 'enabled'] |
| 55 |
member_change: |
| 56 |
aliases: ['member-change'] |
| 57 |
type: int |
| 58 |
description: Member change. |
| 59 |
nac_lan_interface: |
| 60 |
aliases: ['nac-lan-interface'] |
| 61 |
type: str |
| 62 |
description: Configure NAC LAN interface. |
| 63 |
nac_segment_vlans: |
| 64 |
aliases: ['nac-segment-vlans'] |
| 65 |
type: raw |
| 66 |
description: (list) Configure NAC segment VLANs. |
| 67 |
onboarding_vlan: |
| 68 |
aliases: ['onboarding-vlan'] |
| 69 |
type: str |
| 70 |
description: Default NAC Onboarding VLAN when NAC devices are discovered. |
| 71 |
parent_key: |
| 72 |
aliases: ['parent-key'] |
| 73 |
type: str |
| 74 |
description: Parent key. |
| 75 |
bounce_nac_port: |
| 76 |
aliases: ['bounce-nac-port'] |
| 77 |
type: str |
| 78 |
description: Enable/disable bouncing |
| 79 |
choices: ['disable', 'enable'] |
| 80 |
name: |
| 81 |
type: str |
| 82 |
description: FortiLink settings name. |
| 83 |
required: true |
| 84 |
access_vlan_mode: |
| 85 |
aliases: ['access-vlan-mode'] |
| 86 |
type: str |
| 87 |
description: Intra VLAN traffic behavior with loss of connection to the FortiGate. |
| 88 |
choices: ['legacy', 'fail-open', 'fail-close'] |
| 89 |
''' |
| 90 |
|
| 91 |
EXAMPLES = ''' |
| 92 |
- name: Example playbook (generated based on argument schema) |
| 93 |
hosts: fortimanagers |
| 94 |
connection: httpapi |
| 95 |
gather_facts: false |
| 96 |
tasks: |
| 97 |
- name: Configure integrated FortiLink settings for FortiSwitch. |
| 98 |
fortinet.fortimanager.fmgr_switchcontroller_fortilinksettings: |
| 99 |
# workspace_locking_adom: <global or your adom name> |
| 100 |
adom: <your own value> |
| 101 |
state: present # <value in [present, absent]> |
| 102 |
switchcontroller_fortilinksettings: |
| 103 |
name: "your value" # Required variable, string |
| 104 |
# fortilink: <string> |
| 105 |
# inactive_timer: <integer> |
| 106 |
# link_down_flush: <value in [disable, enable]> |
| 107 |
# nac_ports: |
| 108 |
# lan_segment: <value in [disabled, enabled]> |
| 109 |
# member_change: <integer> |
| 110 |
# nac_lan_interface: <string> |
| 111 |
# nac_segment_vlans: <list or string> |
| 112 |
# onboarding_vlan: <string> |
| 113 |
# parent_key: <string> |
| 114 |
# bounce_nac_port: <value in [disable, enable]> |
| 115 |
# access_vlan_mode: <value in [legacy, fail-open, fail-close]> |
| 116 |
''' |
| 117 |
|
| 118 |
RETURN = ''' |
| 119 |
meta: |
| 120 |
description: The result of the request. |
| 121 |
type: dict |
| 122 |
returned: always |
| 123 |
contains: |
| 124 |
request_url: |
| 125 |
description: The full url requested. |
| 126 |
returned: always |
| 127 |
type: str |
| 128 |
sample: /sys/login/user |
| 129 |
response_code: |
| 130 |
description: The status of api request. |
| 131 |
returned: always |
| 132 |
type: int |
| 133 |
sample: 0 |
| 134 |
response_data: |
| 135 |
description: The api response. |
| 136 |
type: list |
| 137 |
returned: always |
| 138 |
response_message: |
| 139 |
description: The descriptive message of the api response. |
| 140 |
type: str |
| 141 |
returned: always |
| 142 |
sample: OK. |
| 143 |
system_information: |
| 144 |
description: The information of the target system. |
| 145 |
type: dict |
| 146 |
returned: always |
| 147 |
rc: |
| 148 |
description: The status the request. |
| 149 |
type: int |
| 150 |
returned: always |
| 151 |
sample: 0 |
| 152 |
version_check_warning: |
| 153 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 154 |
type: list |
| 155 |
returned: complex |
| 156 |
''' |
| 157 |
from ansible.module_utils.basic import AnsibleModule |
| 158 |
from ansible.module_utils.connection import Connection |
| 159 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 160 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 161 |
|
| 162 |
|
| 163 |
def main(): |
| 164 |
urls_list = [ |
| 165 |
'/pm/config/adom/{adom}/obj/switch-controller/fortilink-settings', |
| 166 |
'/pm/config/global/obj/switch-controller/fortilink-settings' |
| 167 |
] |
| 168 |
module_arg_spec = { |
| 169 |
'adom': {'required': True, 'type': 'str'}, |
| 170 |
'revision_note': {'type': 'str'}, |
| 171 |
'switchcontroller_fortilinksettings': { |
| 172 |
'type': 'dict', 'v_range': [['7.2.1', '']], |
| 173 |
'options': { |
| 174 |
'fortilink': {'v_range': [['7.2.1', '7.2.3'], ['7.2.6', '7.4.0'], ['7.4.3', '']], 'type': 'str'}, |
| 175 |
'inactive-timer': {'v_range': [['7.2.1', '']], 'type': 'int'}, |
| 176 |
'link-down-flush': {'v_range': [['7.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 177 |
'nac-ports': { |
| 178 |
'v_range': [['7.2.1', '']], |
| 179 |
'type': 'dict', |
| 180 |
'options': { |
| 181 |
'lan-segment': {'v_range': [['7.2.1', '']], 'choices': ['disabled', 'enabled'], 'type': 'str'}, |
| 182 |
'member-change': {'v_range': [['7.2.1', '']], 'type': 'int'}, |
| 183 |
'nac-lan-interface': {'v_range': [['7.2.1', '']], 'type': 'str'}, |
| 184 |
'nac-segment-vlans': {'v_range': [['7.2.1', '']], 'type': 'raw'}, |
| 185 |
'onboarding-vlan': {'v_range': [['7.2.1', '']], 'type': 'str'}, |
| 186 |
'parent-key': {'v_range': [['7.2.1', '']], 'no_log': True, 'type': 'str'}, |
| 187 |
'bounce-nac-port': {'v_range': [['7.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'} |
| 188 |
} |
| 189 |
}, |
| 190 |
'name': {'v_range': [['7.2.1', '']], 'required': True, 'type': 'str'}, |
| 191 |
'access-vlan-mode': {'v_range': [['7.4.1', '']], 'choices': ['legacy', 'fail-open', 'fail-close'], 'type': 'str'} |
| 192 |
} |
| 193 |
} |
| 194 |
} |
| 195 |
|
| 196 |
module_option_spec = get_module_arg_spec('full crud') |
| 197 |
module_arg_spec.update(module_option_spec) |
| 198 |
check_galaxy_version(module_arg_spec) |
| 199 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'switchcontroller_fortilinksettings'), |
| 200 |
supports_check_mode=True) |
| 201 |
if not module._socket_path: |
| 202 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 203 |
connection = Connection(module._socket_path) |
| 204 |
fmgr = NAPIManager('full crud', module_arg_spec, urls_list, |
| 205 |
'name', 'data', module, connection) |
| 206 |
fmgr.process_crud() |
| 207 |
module.exit_json(meta=module.params) |
| 208 |
|
| 209 |
|
| 210 |
if __name__ == '__main__': |
| 211 |
main() |