Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_ldap_group.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 #
4 # Ansible module to manage CheckPoint Firewall (c) 2019
5 #
6 # Ansible is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # Ansible is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
18 #
19
20 from __future__ import (absolute_import, division, print_function)
21
22 __metaclass__ = type
23
24 ANSIBLE_METADATA = {'metadata_version': '1.1',
25 'status': ['preview'],
26 'supported_by': 'community'}
27
28 DOCUMENTATION = """
29 ---
30 module: cp_mgmt_ldap_group
31 short_description: Manages ldap-group objects on Checkpoint over Web Services API
32 description:
33 - Manages ldap-group objects on Checkpoint devices including creating, updating and removing objects.
34 - All operations are performed over Web Services API.
35 - Available from R82 JHF management version.
36 version_added: "6.5.0"
37 author: "Dor Berenstein (@chkp-dorbe)"
38 options:
39 name:
40 description:
41 - Object name.
42 type: str
43 required: True
44 account_unit:
45 description:
46 - LDAP account unit of the group. Identified by name or UID.
47 type: str
48 scope:
49 description:
50 - Group's scope. There are three possible ways of defining a group, based on the users defined on the Account Unit.
51 type: str
52 choices: ['all_account_unit_users', 'only_sub_tree', 'only_group_in_branch']
53 account_unit_branch:
54 description:
55 - Branch of the selected LDAP Account Unit.
56 type: str
57 sub_tree_prefix:
58 description:
59 - Sub tree prefix of the selected branch. <font color="red">Relevant only when</font> 'scope' is set to 'only_sub_prefix'. Must be in DN syntax.
60 type: str
61 group_prefix:
62 description:
63 - Group name in the selected branch. <font color="red">Required only when</font> 'scope' is set to 'only_group_in_branch'. Must be in DN syntax.
64 type: str
65 apply_filter_for_dynamic_group:
66 description:
67 - Indicate whether to apply LDAP filter for dynamic group. <font color="red">Relevant only when</font> 'scope' is not set to 'only_group_in_branch'.
68 type: bool
69 ldap_filter:
70 description:
71 - LDAP filter for the dynamic group. <font color="red">Relevant only when</font> 'apply-filter-for-dynamic-group' is set to 'true'.
72 type: str
73 color:
74 description:
75 - Color of the object. Should be one of existing colors.
76 type: str
77 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
78 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
79 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
80 comments:
81 description:
82 - Comments string.
83 type: str
84 details_level:
85 description:
86 - The level of detail for some of the fields in the response can vary from showing only the UID value of the object to a fully detailed
87 representation of the object.
88 type: str
89 choices: ['uid', 'standard', 'full']
90 domains_to_process:
91 description:
92 - Indicates which domains to process the commands on. It cannot be used with the details-level full, must be run from the System Domain only and
93 with ignore-warnings true. Valid values are, CURRENT_DOMAIN, ALL_DOMAINS_ON_THIS_SERVER.
94 type: list
95 elements: str
96 tags:
97 description:
98 - Collection of tag identifiers.
99 type: list
100 elements: str
101 ignore_warnings:
102 description:
103 - Apply changes ignoring warnings.
104 type: bool
105 ignore_errors:
106 description:
107 - Apply changes ignoring errors. You won't be able to publish such a changes. If ignore-warnings flag was omitted - warnings will also be ignored.
108 type: bool
109 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
110 """
111
112 EXAMPLES = """
113 - name: add-ldap-group
114 cp_mgmt_ldap_group:
115 account_unit: TestLdapAccountUnit
116 account_unit_branch: OU=Test
117 apply_filter_for_dynamic_group: true
118 group_prefix: N=TestGroup
119 ldap_filter: N=AnotherGroup
120 name: TestLdapGroup
121 scope: only_sub_tree
122 state: present
123 sub_tree_prefix: CA=AC
124
125 - name: set-ldap-group
126 cp_mgmt_ldap_group:
127 account_unit_branch: A=B
128 group_prefix: N=TestGroup2
129 ldap_filter: N=none
130 name: TestLdapGroup
131 state: present
132 sub_tree_prefix: X=Y
133
134 - name: delete-ldap-group
135 cp_mgmt_ldap_group:
136 name: TestLdapGroup
137 state: absent
138 """
139
140 RETURN = """
141 cp_mgmt_ldap_group:
142 description: The checkpoint object created or updated.
143 returned: always, except when deleting the object.
144 type: dict
145 """
146
147 from ansible.module_utils.basic import AnsibleModule
148 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_objects, api_call
149
150
151 def main():
152 argument_spec = dict(
153 name=dict(type='str', required=True),
154 account_unit=dict(type='str'),
155 scope=dict(type='str', choices=['all_account_unit_users', 'only_sub_tree', 'only_group_in_branch']),
156 account_unit_branch=dict(type='str'),
157 sub_tree_prefix=dict(type='str'),
158 group_prefix=dict(type='str'),
159 apply_filter_for_dynamic_group=dict(type='bool'),
160 ldap_filter=dict(type='str'),
161 color=dict(type='str', choices=['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green',
162 'khaki', 'orchid', 'dark orange', 'dark sea green', 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown',
163 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon', 'coral', 'sea green',
164 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna',
165 'yellow']),
166 comments=dict(type='str'),
167 details_level=dict(type='str', choices=['uid', 'standard', 'full']),
168 domains_to_process=dict(type='list', elements="str"),
169 tags=dict(type='list', elements="str"),
170 ignore_warnings=dict(type='bool'),
171 ignore_errors=dict(type='bool')
172 )
173 argument_spec.update(checkpoint_argument_spec_for_objects)
174
175 module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
176 api_call_object = 'ldap-group'
177
178 result = api_call(module, api_call_object)
179 module.exit_json(**result)
180
181
182 if __name__ == '__main__':
183 main()