| 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_nacprofile |
| 15 |
short_description: Configure WiFi network access control |
| 16 |
version_added: "2.1.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 |
nacprofile: |
| 29 |
description: The top level parameters set. |
| 30 |
required: false |
| 31 |
type: dict |
| 32 |
suboptions: |
| 33 |
comment: |
| 34 |
type: str |
| 35 |
description: Comment. |
| 36 |
name: |
| 37 |
type: str |
| 38 |
description: Name. |
| 39 |
required: true |
| 40 |
onboarding_vlan: |
| 41 |
aliases: ['onboarding-vlan'] |
| 42 |
type: str |
| 43 |
description: VLAN interface name. |
| 44 |
''' |
| 45 |
|
| 46 |
EXAMPLES = ''' |
| 47 |
- name: Example playbook (generated based on argument schema) |
| 48 |
hosts: fortimanagers |
| 49 |
connection: httpapi |
| 50 |
gather_facts: false |
| 51 |
tasks: |
| 52 |
- name: Configure WiFi network access control |
| 53 |
fortinet.fortimanager.fmgr_nacprofile: |
| 54 |
# workspace_locking_adom: <global or your adom name> |
| 55 |
adom: <your own value> |
| 56 |
state: present # <value in [present, absent]> |
| 57 |
nacprofile: |
| 58 |
name: "your value" # Required variable, string |
| 59 |
# comment: <string> |
| 60 |
# onboarding_vlan: <string> |
| 61 |
''' |
| 62 |
|
| 63 |
RETURN = ''' |
| 64 |
meta: |
| 65 |
description: The result of the request. |
| 66 |
type: dict |
| 67 |
returned: always |
| 68 |
contains: |
| 69 |
request_url: |
| 70 |
description: The full url requested. |
| 71 |
returned: always |
| 72 |
type: str |
| 73 |
sample: /sys/login/user |
| 74 |
response_code: |
| 75 |
description: The status of api request. |
| 76 |
returned: always |
| 77 |
type: int |
| 78 |
sample: 0 |
| 79 |
response_data: |
| 80 |
description: The api response. |
| 81 |
type: list |
| 82 |
returned: always |
| 83 |
response_message: |
| 84 |
description: The descriptive message of the api response. |
| 85 |
type: str |
| 86 |
returned: always |
| 87 |
sample: OK. |
| 88 |
system_information: |
| 89 |
description: The information of the target system. |
| 90 |
type: dict |
| 91 |
returned: always |
| 92 |
rc: |
| 93 |
description: The status the request. |
| 94 |
type: int |
| 95 |
returned: always |
| 96 |
sample: 0 |
| 97 |
version_check_warning: |
| 98 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 99 |
type: list |
| 100 |
returned: complex |
| 101 |
''' |
| 102 |
from ansible.module_utils.basic import AnsibleModule |
| 103 |
from ansible.module_utils.connection import Connection |
| 104 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 105 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 106 |
|
| 107 |
|
| 108 |
def main(): |
| 109 |
urls_list = [ |
| 110 |
'/pm/config/adom/{adom}/obj/wireless-controller/nac-profile', |
| 111 |
'/pm/config/global/obj/wireless-controller/nac-profile' |
| 112 |
] |
| 113 |
module_arg_spec = { |
| 114 |
'adom': {'required': True, 'type': 'str'}, |
| 115 |
'revision_note': {'type': 'str'}, |
| 116 |
'nacprofile': { |
| 117 |
'type': 'dict', 'v_range': [['7.0.3', '']], |
| 118 |
'options': { |
| 119 |
'comment': {'v_range': [['7.0.3', '']], 'type': 'str'}, |
| 120 |
'name': {'v_range': [['7.0.3', '']], 'required': True, 'type': 'str'}, |
| 121 |
'onboarding-vlan': {'v_range': [['7.0.3', '']], 'type': 'str'} |
| 122 |
} |
| 123 |
} |
| 124 |
} |
| 125 |
|
| 126 |
module_option_spec = get_module_arg_spec('full crud') |
| 127 |
module_arg_spec.update(module_option_spec) |
| 128 |
check_galaxy_version(module_arg_spec) |
| 129 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'nacprofile'), |
| 130 |
supports_check_mode=True) |
| 131 |
if not module._socket_path: |
| 132 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 133 |
connection = Connection(module._socket_path) |
| 134 |
fmgr = NAPIManager('full crud', module_arg_spec, urls_list, |
| 135 |
'name', 'data', module, connection) |
| 136 |
fmgr.process_crud() |
| 137 |
module.exit_json(meta=module.params) |
| 138 |
|
| 139 |
|
| 140 |
if __name__ == '__main__': |
| 141 |
main() |