Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_securityconsole_install_preview.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_securityconsole_install_preview
15 short_description: Generate install preview for a device.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 options:
20 securityconsole_install_preview:
21 description: The top level parameters set.
22 required: false
23 type: dict
24 suboptions:
25 adom:
26 type: str
27 description: Source ADOM name.
28 device:
29 type: str
30 description: Device.
31 flags:
32 type: list
33 elements: str
34 description: Flags.
35 choices: ['none', 'json', 'default_cfg']
36 vdoms:
37 type: raw
38 description: (list) Vdoms.
39 scope:
40 type: list
41 elements: dict
42 description: Scope.
43 suboptions:
44 name:
45 type: str
46 description: Name.
47 vdom:
48 type: str
49 description: Vdom.
50 '''
51
52 EXAMPLES = '''
53 - name: INSTALL PREVIEW - POLICY PACKAGE
54 hosts: fortimanagers
55 gather_facts: false
56 connection: httpapi
57 vars:
58 adom: demo
59 ppkg: ppkg_hubs
60 device: fgt_00_1
61 tasks:
62 - name: Install for policy package [preview mode] {{ ppkg }}
63 fortinet.fortimanager.fmgr_securityconsole_install_package:
64 securityconsole_install_package:
65 adom: "{{ adom }}"
66 flags:
67 - preview
68 pkg: "{{ ppkg }}"
69 scope:
70 - name: "{{ device }}"
71 vdom: root
72 register: r
73 - name: Poll the task of installing policy package
74 fortinet.fortimanager.fmgr_fact:
75 facts:
76 selector: "task_task"
77 params:
78 task: "{{ r.meta.response_data.task }}"
79 register: taskinfo
80 until: taskinfo.meta.response_data.percent == 100
81 retries: 30
82 delay: 5
83 - name: Trigger the preview report generation for policy package {{ ppkg }}
84 fortinet.fortimanager.fmgr_securityconsole_install_preview:
85 securityconsole_install_preview:
86 adom: "{{ adom }}"
87 device: "{{ device }}"
88 flags:
89 - json
90 vdoms: root
91 register: r
92 - name: Poll the task of generating preview report
93 fortinet.fortimanager.fmgr_fact:
94 facts:
95 selector: "task_task"
96 params:
97 task: "{{ r.meta.response_data.task }}"
98 register: taskinfo
99 until: taskinfo.meta.response_data.percent == 100
100 retries: 30
101 delay: 5
102 - name: Get the preview report for policy package {{ ppkg }}
103 fortinet.fortimanager.fmgr_securityconsole_preview_result:
104 securityconsole_preview_result:
105 adom: "{{ adom }}"
106 device: "{{ device }}"
107 register: r
108 - name: Cancel install task for policy package {{ ppkg }}
109 fortinet.fortimanager.fmgr_securityconsole_package_cancel_install:
110 securityconsole_package_cancel_install:
111 adom: "{{ adom }}"
112 - name: Show preview report
113 ansible.builtin.debug:
114 msg: "{{ r }}"
115 '''
116
117 RETURN = '''
118 meta:
119 description: The result of the request.
120 type: dict
121 returned: always
122 contains:
123 request_url:
124 description: The full url requested.
125 returned: always
126 type: str
127 sample: /sys/login/user
128 response_code:
129 description: The status of api request.
130 returned: always
131 type: int
132 sample: 0
133 response_data:
134 description: The api response.
135 type: list
136 returned: always
137 response_message:
138 description: The descriptive message of the api response.
139 type: str
140 returned: always
141 sample: OK.
142 system_information:
143 description: The information of the target system.
144 type: dict
145 returned: always
146 rc:
147 description: The status the request.
148 type: int
149 returned: always
150 sample: 0
151 version_check_warning:
152 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
153 type: list
154 returned: complex
155 '''
156 from ansible.module_utils.basic import AnsibleModule
157 from ansible.module_utils.connection import Connection
158 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
159 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
160
161
162 def main():
163 urls_list = [
164 '/securityconsole/install/preview'
165 ]
166 module_arg_spec = {
167 'securityconsole_install_preview': {
168 'type': 'dict', 'v_range': [['6.0.0', '']],
169 'options': {
170 'adom': {'type': 'str'},
171 'device': {'v_range': [['6.0.0', '7.4.3']], 'type': 'str'},
172 'flags': {'type': 'list', 'choices': ['none', 'json', 'default_cfg'], 'elements': 'str'},
173 'vdoms': {'v_range': [['6.0.0', '7.4.3']], 'type': 'raw'},
174 'scope': {
175 'v_range': [['7.4.4', '']],
176 'type': 'list',
177 'options': {'name': {'v_range': [['7.4.4', '']], 'type': 'str'}, 'vdom': {'v_range': [['7.4.4', '']], 'type': 'str'}},
178 'elements': 'dict'
179 }
180 }
181 }
182 }
183
184 module_option_spec = get_module_arg_spec('exec')
185 module_arg_spec.update(module_option_spec)
186 check_galaxy_version(module_arg_spec)
187 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'securityconsole_install_preview'),
188 supports_check_mode=True)
189 if not module._socket_path:
190 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
191 connection = Connection(module._socket_path)
192 fmgr = NAPIManager('exec', module_arg_spec, urls_list,
193 None, 'data', module, connection)
194 fmgr.process_exec()
195 module.exit_json(meta=module.params)
196
197
198 if __name__ == '__main__':
199 main()