Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_wanopt_authgroup.py

raw symbols SCIP
1 #!/usr/bin/python
2 from __future__ import absolute_import, division, print_function
3 # Copyright 2019-2024 Fortinet, Inc.
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
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_wanopt_authgroup
15 short_description: Configure WAN optimization authentication groups.
16 version_added: "2.0.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 wanopt_authgroup:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 auth_method:
34 aliases: ['auth-method']
35 type: str
36 description: Select certificate or pre-shared key authentication for this authentication group.
37 choices: ['cert', 'psk']
38 cert:
39 type: str
40 description: Name of certificate to identify this peer.
41 name:
42 type: str
43 description: Auth-group name.
44 required: true
45 peer:
46 type: str
47 description: If peer-accept is set to one, select the name of one peer to add to this authentication group.
48 peer_accept:
49 aliases: ['peer-accept']
50 type: str
51 description: Determine if this auth group accepts, any peer, a list of defined peers, or just one peer.
52 choices: ['any', 'defined', 'one']
53 psk:
54 type: raw
55 description: (list) Pre-shared key used by the peers in this authentication group.
56 '''
57
58 EXAMPLES = '''
59 - name: Example playbook (generated based on argument schema)
60 hosts: fortimanagers
61 connection: httpapi
62 gather_facts: false
63 tasks:
64 - name: Configure WAN optimization authentication groups.
65 fortinet.fortimanager.fmgr_wanopt_authgroup:
66 # workspace_locking_adom: <global or your adom name>
67 adom: <your own value>
68 state: present # <value in [present, absent]>
69 wanopt_authgroup:
70 name: "your value" # Required variable, string
71 # auth_method: <value in [cert, psk]>
72 # cert: <string>
73 # peer: <string>
74 # peer_accept: <value in [any, defined, one]>
75 # psk: <list or string>
76 '''
77
78 RETURN = '''
79 meta:
80 description: The result of the request.
81 type: dict
82 returned: always
83 contains:
84 request_url:
85 description: The full url requested.
86 returned: always
87 type: str
88 sample: /sys/login/user
89 response_code:
90 description: The status of api request.
91 returned: always
92 type: int
93 sample: 0
94 response_data:
95 description: The api response.
96 type: list
97 returned: always
98 response_message:
99 description: The descriptive message of the api response.
100 type: str
101 returned: always
102 sample: OK.
103 system_information:
104 description: The information of the target system.
105 type: dict
106 returned: always
107 rc:
108 description: The status the request.
109 type: int
110 returned: always
111 sample: 0
112 version_check_warning:
113 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
114 type: list
115 returned: complex
116 '''
117 from ansible.module_utils.basic import AnsibleModule
118 from ansible.module_utils.connection import Connection
119 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
120 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
121
122
123 def main():
124 urls_list = [
125 '/pm/config/adom/{adom}/obj/wanopt/auth-group',
126 '/pm/config/global/obj/wanopt/auth-group'
127 ]
128 module_arg_spec = {
129 'adom': {'required': True, 'type': 'str'},
130 'revision_note': {'type': 'str'},
131 'wanopt_authgroup': {
132 'type': 'dict', 'v_range': [['6.0.0', '']],
133 'options': {
134 'auth-method': {'choices': ['cert', 'psk'], 'type': 'str'},
135 'cert': {'type': 'str'},
136 'name': {'required': True, 'type': 'str'},
137 'peer': {'type': 'str'},
138 'peer-accept': {'choices': ['any', 'defined', 'one'], 'type': 'str'},
139 'psk': {'type': 'raw'}
140 }
141 }
142 }
143
144 module_option_spec = get_module_arg_spec('full crud')
145 module_arg_spec.update(module_option_spec)
146 check_galaxy_version(module_arg_spec)
147 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'wanopt_authgroup'),
148 supports_check_mode=True)
149 if not module._socket_path:
150 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
151 connection = Connection(module._socket_path)
152 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
153 'name', 'data', module, connection)
154 fmgr.process_crud()
155 module.exit_json(meta=module.params)
156
157
158 if __name__ == '__main__':
159 main()