Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_passcode_profile.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_passcode_profile
31 short_description: Manages passcode-profile objects on Checkpoint over Web Services API
32 description:
33 - Manages passcode-profile objects on Checkpoint devices including creating, updating and removing objects.
34 - All operations are performed over Web Services API.
35 - Available from R82 management version.
36 version_added: "6.0.0"
37 author: "Eden Brillant (@chkp-edenbr)"
38 options:
39 name:
40 description:
41 - Object name.
42 type: str
43 required: True
44 allow_simple_passcode:
45 description:
46 - The passcode length is 4 and only numeric values allowed.
47 type: bool
48 min_passcode_length:
49 description:
50 - Minimum passcode length - relevant if "allow-simple-passcode" is disable.
51 type: int
52 require_alphanumeric_passcode:
53 description:
54 - Require alphanumeric characters in the passcode - relevant if "allow-simple-passcode" is disable.
55 type: bool
56 min_passcode_complex_characters:
57 description:
58 - Minimum number of complex characters (if "require-alphanumeric-passcode" is enabled). The number of the complex characters cannot be greater
59 than number of the passcode length.
60 type: int
61 force_passcode_expiration:
62 description:
63 - Enable/disable expiration date to the passcode.
64 type: bool
65 passcode_expiration_period:
66 description:
67 - The period in days after which the passcode will expire.
68 type: int
69 enable_inactivity_time_lock:
70 description:
71 - Lock the device if app is inactive.
72 type: bool
73 max_inactivity_time_lock:
74 description:
75 - Time without user input before passcode must be re-entered (in minutes).
76 type: int
77 enable_passcode_failed_attempts:
78 description:
79 - Exit after few failures in passcode verification.
80 type: bool
81 max_passcode_failed_attempts:
82 description:
83 - Number of failed attempts allowed.
84 type: int
85 enable_passcode_history:
86 description:
87 - Check passcode history for reparations.
88 type: bool
89 passcode_history:
90 description:
91 - Number of passcodes that will be kept in history.
92 type: int
93 tags:
94 description:
95 - Collection of tag identifiers.
96 type: list
97 elements: str
98 color:
99 description:
100 - Color of the object. Should be one of existing colors.
101 type: str
102 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
103 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
104 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
105 comments:
106 description:
107 - Comments string.
108 type: str
109 details_level:
110 description:
111 - 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
112 representation of the object.
113 type: str
114 choices: ['uid', 'standard', 'full']
115 domains_to_process:
116 description:
117 - 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
118 with ignore-warnings true. Valid values are, CURRENT_DOMAIN, ALL_DOMAINS_ON_THIS_SERVER.
119 type: list
120 elements: str
121 ignore_warnings:
122 description:
123 - Apply changes ignoring warnings.
124 type: bool
125 ignore_errors:
126 description:
127 - 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.
128 type: bool
129 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
130 """
131
132 EXAMPLES = """
133 - name: add-passcode-profile
134 cp_mgmt_passcode_profile:
135 name: New App Passcode Policy
136 state: present
137
138 - name: set-passcode-profile
139 cp_mgmt_passcode_profile:
140 allow_simple_passcode: 'true'
141 max_inactivity_time_lock: '30'
142 name: New App Passcode Policy
143 require_alphanumeric_passcode: 'false'
144 state: present
145
146 - name: delete-passcode-profile
147 cp_mgmt_passcode_profile:
148 name: My App Passcode Policy
149 state: absent
150 """
151
152 RETURN = """
153 cp_mgmt_passcode_profile:
154 description: The checkpoint object created or updated.
155 returned: always, except when deleting the object.
156 type: dict
157 """
158
159 from ansible.module_utils.basic import AnsibleModule
160 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_objects, api_call
161
162
163 def main():
164 argument_spec = dict(
165 name=dict(type='str', required=True),
166 allow_simple_passcode=dict(type='bool'),
167 min_passcode_length=dict(type='int', no_log=True),
168 require_alphanumeric_passcode=dict(type='bool'),
169 min_passcode_complex_characters=dict(type='int', no_log=True),
170 force_passcode_expiration=dict(type='bool'),
171 passcode_expiration_period=dict(type='int'),
172 enable_inactivity_time_lock=dict(type='bool'),
173 max_inactivity_time_lock=dict(type='int'),
174 enable_passcode_failed_attempts=dict(type='bool'),
175 max_passcode_failed_attempts=dict(type='int', no_log=True),
176 enable_passcode_history=dict(type='bool'),
177 passcode_history=dict(type='int', no_log=True),
178 tags=dict(type='list', elements='str'),
179 color=dict(type='str', choices=['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green',
180 'khaki', 'orchid', 'dark orange', 'dark sea green', 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown',
181 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon', 'coral', 'sea green',
182 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna',
183 'yellow']),
184 comments=dict(type='str'),
185 details_level=dict(type='str', choices=['uid', 'standard', 'full']),
186 domains_to_process=dict(type='list', elements='str'),
187 ignore_warnings=dict(type='bool'),
188 ignore_errors=dict(type='bool')
189 )
190 argument_spec.update(checkpoint_argument_spec_for_objects)
191
192 module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
193 api_call_object = 'passcode-profile'
194
195 result = api_call(module, api_call_object)
196 module.exit_json(**result)
197
198
199 if __name__ == '__main__':
200 main()