Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_admin_group.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_system_admin_group
15 short_description: User group.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_crud
20 options:
21 system_admin_group:
22 description: The top level parameters set.
23 required: false
24 type: dict
25 suboptions:
26 member:
27 type: list
28 elements: dict
29 description: Member.
30 suboptions:
31 name:
32 type: str
33 description: Group member name.
34 name:
35 type: str
36 description: Name.
37 required: true
38 '''
39
40 EXAMPLES = '''
41 - name: Example playbook
42 hosts: fortimanagers
43 gather_facts: false
44 connection: httpapi
45 vars:
46 ansible_httpapi_use_ssl: true
47 ansible_httpapi_validate_certs: false
48 ansible_httpapi_port: 443
49 tasks:
50 - name: User group.
51 fortinet.fortimanager.fmgr_system_admin_group:
52 bypass_validation: false
53 state: present
54 system_admin_group:
55 name: "ansible-group"
56 member:
57 - name: "ansible-test-radius"
58 # Member name are from Remote Authentication Server; GUI path: System Settings --> Admin --> Remote Authentication Server
59
60 - name: Gathering fortimanager facts
61 hosts: fortimanagers
62 gather_facts: false
63 connection: httpapi
64 vars:
65 ansible_httpapi_use_ssl: true
66 ansible_httpapi_validate_certs: false
67 ansible_httpapi_port: 443
68 tasks:
69 - name: Retrieve all the user groups
70 fortinet.fortimanager.fmgr_fact:
71 facts:
72 selector: "system_admin_group"
73 params:
74 group: "your_value"
75 '''
76
77 RETURN = '''
78 meta:
79 description: The result of the request.
80 type: dict
81 returned: always
82 contains:
83 request_url:
84 description: The full url requested.
85 returned: always
86 type: str
87 sample: /sys/login/user
88 response_code:
89 description: The status of api request.
90 returned: always
91 type: int
92 sample: 0
93 response_data:
94 description: The api response.
95 type: list
96 returned: always
97 response_message:
98 description: The descriptive message of the api response.
99 type: str
100 returned: always
101 sample: OK.
102 system_information:
103 description: The information of the target system.
104 type: dict
105 returned: always
106 rc:
107 description: The status the request.
108 type: int
109 returned: always
110 sample: 0
111 version_check_warning:
112 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
113 type: list
114 returned: complex
115 '''
116 from ansible.module_utils.basic import AnsibleModule
117 from ansible.module_utils.connection import Connection
118 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
119 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
120
121
122 def main():
123 urls_list = [
124 '/cli/global/system/admin/group'
125 ]
126 module_arg_spec = {
127 'system_admin_group': {
128 'type': 'dict', 'v_range': [['6.0.0', '']],
129 'options': {'member': {'type': 'list', 'options': {'name': {'type': 'str'}}, 'elements': 'dict'}, 'name': {'required': True, 'type': 'str'}}
130 }
131 }
132
133 module_option_spec = get_module_arg_spec('full crud')
134 module_arg_spec.update(module_option_spec)
135 check_galaxy_version(module_arg_spec)
136 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_admin_group'),
137 supports_check_mode=True)
138 if not module._socket_path:
139 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
140 connection = Connection(module._socket_path)
141 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
142 'name', 'data', module, connection)
143 fmgr.process_crud()
144 module.exit_json(meta=module.params)
145
146
147 if __name__ == '__main__':
148 main()