Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_securityconsole_assign_package.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_assign_package
15 short_description: Assign or unassign global policy package to ADOM packages.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 options:
20 securityconsole_assign_package:
21 description: The top level parameters set.
22 required: false
23 type: dict
24 suboptions:
25 flags:
26 type: list
27 elements: str
28 description:
29 - cp_all_objs - Assign all objects during global policy assignment.
30 - copy_assigned_pkg - For global policy assignment - copy assigned package from ADOM to device.
31 - unassign - Remove global policy from ADOM.
32 choices: ['none', 'cp_all_objs', 'copy_assigned_pkg', 'unassign']
33 pkg:
34 type: str
35 description: Source package path and name.
36 target:
37 type: list
38 elements: dict
39 description: Target.
40 suboptions:
41 adom:
42 type: str
43 description: Destination ADOM.
44 excluded:
45 type: str
46 description:
47 - disable - Only include the packages listed in the pkg list.
48 - enable - Exclude the package listed in the pkg list, and assign to all other packages in the ADOM.
49 choices: ['disable', 'enable']
50 pkg:
51 type: str
52 description: Destination ADOM policy package path and name.
53 '''
54
55 EXAMPLES = '''
56 - name: Example playbook (generated based on argument schema)
57 hosts: fortimanagers
58 connection: httpapi
59 gather_facts: false
60 tasks:
61 - name: Assign or unassign global policy package to ADOM packages.
62 fortinet.fortimanager.fmgr_securityconsole_assign_package:
63 # workspace_locking_adom: <global or your adom name>
64 securityconsole_assign_package:
65 # flags: ["none", "cp_all_objs", "copy_assigned_pkg", "unassign"]
66 # pkg: <string>
67 # target:
68 # - adom: <string>
69 # excluded: <value in [disable, enable]>
70 # pkg: <string>
71 '''
72
73 RETURN = '''
74 meta:
75 description: The result of the request.
76 type: dict
77 returned: always
78 contains:
79 request_url:
80 description: The full url requested.
81 returned: always
82 type: str
83 sample: /sys/login/user
84 response_code:
85 description: The status of api request.
86 returned: always
87 type: int
88 sample: 0
89 response_data:
90 description: The api response.
91 type: list
92 returned: always
93 response_message:
94 description: The descriptive message of the api response.
95 type: str
96 returned: always
97 sample: OK.
98 system_information:
99 description: The information of the target system.
100 type: dict
101 returned: always
102 rc:
103 description: The status the request.
104 type: int
105 returned: always
106 sample: 0
107 version_check_warning:
108 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
109 type: list
110 returned: complex
111 '''
112 from ansible.module_utils.basic import AnsibleModule
113 from ansible.module_utils.connection import Connection
114 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
115 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
116
117
118 def main():
119 urls_list = [
120 '/securityconsole/assign/package'
121 ]
122 module_arg_spec = {
123 'securityconsole_assign_package': {
124 'type': 'dict', 'v_range': [['6.0.0', '']],
125 'options': {
126 'flags': {'type': 'list', 'choices': ['none', 'cp_all_objs', 'copy_assigned_pkg', 'unassign'], 'elements': 'str'},
127 'pkg': {'type': 'str'},
128 'target': {
129 'type': 'list',
130 'options': {'adom': {'type': 'str'}, 'excluded': {'choices': ['disable', 'enable'], 'type': 'str'}, 'pkg': {'type': 'str'}},
131 'elements': 'dict'
132 }
133 }
134 }
135 }
136
137 module_option_spec = get_module_arg_spec('exec')
138 module_arg_spec.update(module_option_spec)
139 check_galaxy_version(module_arg_spec)
140 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'securityconsole_assign_package'),
141 supports_check_mode=True)
142 if not module._socket_path:
143 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
144 connection = Connection(module._socket_path)
145 fmgr = NAPIManager('exec', module_arg_spec, urls_list,
146 None, 'data', module, connection)
147 fmgr.process_exec()
148 module.exit_json(meta=module.params)
149
150
151 if __name__ == '__main__':
152 main()