Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_template.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_template
15 short_description: Require device/vdom scope member
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 template:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 description:
34 type: str
35 description: Description.
36 modification_time:
37 aliases: ['modification-time']
38 type: str
39 description: Modification time.
40 name:
41 type: str
42 description: Name.
43 required: true
44 script:
45 type: str
46 description: Script.
47 provision:
48 type: str
49 description: Provision.
50 choices: ['disable', 'enable']
51 type:
52 type: str
53 description: Type.
54 choices: ['cli', 'jinja']
55 variables:
56 type: raw
57 description: (list) Variables.
58 position:
59 type: str
60 description: Position.
61 choices: ['post-vdom-copy', 'prep-vdom-copy']
62 option:
63 type: list
64 elements: str
65 description: Option.
66 choices: ['sdwan-overlay', 'sdwan-manager']
67 scope_member:
68 aliases: ['scope member']
69 type: list
70 elements: dict
71 description: Scope member.
72 suboptions:
73 name:
74 type: str
75 description: Name.
76 vdom:
77 type: str
78 description: Vdom.
79 '''
80
81 EXAMPLES = '''
82 - name: Example playbook (generated based on argument schema)
83 hosts: fortimanagers
84 connection: httpapi
85 gather_facts: false
86 tasks:
87 - name: Require device/vdom scope member
88 fortinet.fortimanager.fmgr_template:
89 # workspace_locking_adom: <global or your adom name>
90 adom: <your own value>
91 state: present # <value in [present, absent]>
92 template:
93 name: "your value" # Required variable, string
94 # description: <string>
95 # modification_time: <string>
96 # script: <string>
97 # provision: <value in [disable, enable]>
98 # type: <value in [cli, jinja]>
99 # variables: <list or string>
100 # position: <value in [post-vdom-copy, prep-vdom-copy]>
101 # option: ["sdwan-overlay", "sdwan-manager"]
102 # scope_member:
103 # - name: <string>
104 # vdom: <string>
105 '''
106
107 RETURN = '''
108 meta:
109 description: The result of the request.
110 type: dict
111 returned: always
112 contains:
113 request_url:
114 description: The full url requested.
115 returned: always
116 type: str
117 sample: /sys/login/user
118 response_code:
119 description: The status of api request.
120 returned: always
121 type: int
122 sample: 0
123 response_data:
124 description: The api response.
125 type: list
126 returned: always
127 response_message:
128 description: The descriptive message of the api response.
129 type: str
130 returned: always
131 sample: OK.
132 system_information:
133 description: The information of the target system.
134 type: dict
135 returned: always
136 rc:
137 description: The status the request.
138 type: int
139 returned: always
140 sample: 0
141 version_check_warning:
142 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
143 type: list
144 returned: complex
145 '''
146 from ansible.module_utils.basic import AnsibleModule
147 from ansible.module_utils.connection import Connection
148 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
149 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
150
151
152 def main():
153 urls_list = [
154 '/pm/config/adom/{adom}/obj/cli/template',
155 '/pm/config/global/obj/cli/template'
156 ]
157 module_arg_spec = {
158 'adom': {'required': True, 'type': 'str'},
159 'revision_note': {'type': 'str'},
160 'template': {
161 'type': 'dict', 'v_range': [['6.0.0', '']],
162 'options': {
163 'description': {'type': 'str'},
164 'modification-time': {'v_range': [['6.0.0', '7.0.3']], 'type': 'str'},
165 'name': {'required': True, 'type': 'str'},
166 'script': {'type': 'str'},
167 'provision': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
168 'type': {'v_range': [['7.0.1', '']], 'choices': ['cli', 'jinja'], 'type': 'str'},
169 'variables': {'v_range': [['7.0.1', '']], 'type': 'raw'},
170 'position': {'v_range': [['7.4.2', '']], 'choices': ['post-vdom-copy', 'prep-vdom-copy'], 'type': 'str'},
171 'option': {'v_range': [['7.6.0', '']], 'type': 'list', 'choices': ['sdwan-overlay', 'sdwan-manager'], 'elements': 'str'},
172 'scope member': {
173 'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']],
174 'type': 'list',
175 'options': {
176 'name': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'str'},
177 'vdom': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'str'}
178 },
179 'elements': 'dict'
180 }
181 }
182 }
183 }
184
185 module_option_spec = get_module_arg_spec('full crud')
186 module_arg_spec.update(module_option_spec)
187 check_galaxy_version(module_arg_spec)
188 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'template'),
189 supports_check_mode=True)
190 if not module._socket_path:
191 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
192 connection = Connection(module._socket_path)
193 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
194 'name', 'data', module, connection)
195 fmgr.process_crud()
196 module.exit_json(meta=module.params)
197
198
199 if __name__ == '__main__':
200 main()