Debian Codegraph @

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