Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_virtualpatch_profile.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_virtualpatch_profile
15 short_description: Configure virtual-patch profile.
16 version_added: "2.3.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 virtualpatch_profile:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 action:
34 type: str
35 description: Action
36 choices: ['pass', 'block']
37 comment:
38 type: str
39 description: Comment.
40 exemption:
41 type: list
42 elements: dict
43 description: Exemption.
44 suboptions:
45 device:
46 type: list
47 elements: str
48 description: Device MAC addresses.
49 id:
50 type: int
51 description: IDs.
52 rule:
53 type: list
54 elements: int
55 description: Patch signature rule IDs.
56 status:
57 type: str
58 description: Enable/disable exemption.
59 choices: ['disable', 'enable']
60 log:
61 type: str
62 description: Enable/disable logging of detection.
63 choices: ['disable', 'enable']
64 name:
65 type: str
66 description: Profile name.
67 required: true
68 severity:
69 type: list
70 elements: str
71 description: Relative severity of the signature
72 choices: ['low', 'medium', 'high', 'critical', 'info']
73 '''
74
75 EXAMPLES = '''
76 - name: Example playbook (generated based on argument schema)
77 hosts: fortimanagers
78 connection: httpapi
79 gather_facts: false
80 tasks:
81 - name: Configure virtual-patch profile.
82 fortinet.fortimanager.fmgr_virtualpatch_profile:
83 # workspace_locking_adom: <global or your adom name>
84 adom: <your own value>
85 state: present # <value in [present, absent]>
86 virtualpatch_profile:
87 name: "your value" # Required variable, string
88 # action: <value in [pass, block]>
89 # comment: <string>
90 # exemption:
91 # - device: <list or string>
92 # id: <integer>
93 # rule: <list or integer>
94 # status: <value in [disable, enable]>
95 # log: <value in [disable, enable]>
96 # severity: ["low", "medium", "high", "critical", "info"]
97 '''
98
99 RETURN = '''
100 meta:
101 description: The result of the request.
102 type: dict
103 returned: always
104 contains:
105 request_url:
106 description: The full url requested.
107 returned: always
108 type: str
109 sample: /sys/login/user
110 response_code:
111 description: The status of api request.
112 returned: always
113 type: int
114 sample: 0
115 response_data:
116 description: The api response.
117 type: list
118 returned: always
119 response_message:
120 description: The descriptive message of the api response.
121 type: str
122 returned: always
123 sample: OK.
124 system_information:
125 description: The information of the target system.
126 type: dict
127 returned: always
128 rc:
129 description: The status the request.
130 type: int
131 returned: always
132 sample: 0
133 version_check_warning:
134 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
135 type: list
136 returned: complex
137 '''
138 from ansible.module_utils.basic import AnsibleModule
139 from ansible.module_utils.connection import Connection
140 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
141 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
142
143
144 def main():
145 urls_list = [
146 '/pm/config/adom/{adom}/obj/virtual-patch/profile',
147 '/pm/config/global/obj/virtual-patch/profile'
148 ]
149 module_arg_spec = {
150 'adom': {'required': True, 'type': 'str'},
151 'revision_note': {'type': 'str'},
152 'virtualpatch_profile': {
153 'type': 'dict', 'v_range': [['7.4.1', '']],
154 'options': {
155 'action': {'v_range': [['7.4.1', '']], 'choices': ['pass', 'block'], 'type': 'str'},
156 'comment': {'v_range': [['7.4.1', '']], 'type': 'str'},
157 'exemption': {
158 'v_range': [['7.4.1', '']],
159 'type': 'list',
160 'options': {
161 'device': {'v_range': [['7.4.1', '']], 'type': 'list', 'elements': 'str'},
162 'id': {'v_range': [['7.4.1', '']], 'type': 'int'},
163 'rule': {'v_range': [['7.4.1', '']], 'type': 'list', 'elements': 'int'},
164 'status': {'v_range': [['7.4.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'}
165 },
166 'elements': 'dict'
167 },
168 'log': {'v_range': [['7.4.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
169 'name': {'v_range': [['7.4.1', '']], 'required': True, 'type': 'str'},
170 'severity': {'v_range': [['7.4.1', '']], 'type': 'list', 'choices': ['low', 'medium', 'high', 'critical', 'info'], 'elements': 'str'}
171 }
172 }
173 }
174
175 module_option_spec = get_module_arg_spec('full crud')
176 module_arg_spec.update(module_option_spec)
177 check_galaxy_version(module_arg_spec)
178 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'virtualpatch_profile'),
179 supports_check_mode=True)
180 if not module._socket_path:
181 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
182 connection = Connection(module._socket_path)
183 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
184 'name', 'data', module, connection)
185 fmgr.process_crud()
186 module.exit_json(meta=module.params)
187
188
189 if __name__ == '__main__':
190 main()