Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_tacacs_server.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_tacacs_server
31 short_description: Manages tacacs-server objects on Checkpoint over Web Services API
32 description:
33 - Manages tacacs-server objects on Checkpoint devices including creating, updating and removing objects.
34 - All operations are performed over Web Services API.
35 - Available from R81 management version.
36 version_added: "5.0.0"
37 author: "Eden Brillant (@chkp-edenbr)"
38 options:
39 name:
40 description:
41 - Object name.
42 type: str
43 required: True
44 secret_key:
45 description:
46 - The server's secret key.<br><font color="red">Required only when</font> "server-type" was selected to be "TACACS+".
47 type: str
48 server:
49 description:
50 - The UID or Name of the host that is the TACACS Server.
51 type: str
52 encryption:
53 description:
54 - Is there a secret key defined on the server. Must be set true when "server-type" was selected to be "TACACS+".
55 type: bool
56 priority:
57 description:
58 - The priority of the TACACS Server in case it is a member of a TACACS Group.
59 type: int
60 server_type:
61 description:
62 - Server type, TACACS or TACACS+.
63 type: str
64 choices: ['TACACS', 'TACACS+']
65 service:
66 description:
67 - Server service, only relevant when "server-type" is TACACS.
68 type: str
69 tags:
70 description:
71 - Collection of tag identifiers.
72 type: list
73 elements: str
74 color:
75 description:
76 - Color of the object. Should be one of existing colors.
77 type: str
78 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
79 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
80 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
81 comments:
82 description:
83 - Comments string.
84 type: str
85 details_level:
86 description:
87 - 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
88 representation of the object.
89 type: str
90 choices: ['uid', 'standard', 'full']
91 groups:
92 description:
93 - Collection of group identifiers.
94 type: list
95 elements: str
96 ignore_warnings:
97 description:
98 - Apply changes ignoring warnings.
99 type: bool
100 ignore_errors:
101 description:
102 - 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.
103 type: bool
104 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
105 """
106
107 EXAMPLES = """
108 - name: add-tacacs-server
109 cp_mgmt_tacacs_server:
110 name: tacacs7
111 server: h1
112 state: present
113
114 - name: set-tacacs-server
115 cp_mgmt_tacacs_server:
116 encryption: 'true'
117 name: tacacs server
118 priority: '5'
119 secret_key: '**secret**'
120 server: d700e8d5-d010-4f37-ab14-f78f5a26426c
121 server_type: TACACS
122 state: present
123
124 - name: delete-tacacs-server
125 cp_mgmt_tacacs_server:
126 name: tacacs server
127 state: absent
128 """
129
130 RETURN = """
131 cp_mgmt_tacacs_server:
132 description: The checkpoint object created or updated.
133 returned: always, except when deleting the object.
134 type: dict
135 """
136
137 from ansible.module_utils.basic import AnsibleModule
138 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_objects, api_call
139
140
141 def main():
142 argument_spec = dict(
143 name=dict(type='str', required=True),
144 secret_key=dict(type='str', no_log=True),
145 server=dict(type='str'),
146 encryption=dict(type='bool'),
147 priority=dict(type='int'),
148 server_type=dict(type='str', choices=['TACACS', 'TACACS+']),
149 service=dict(type='str'),
150 tags=dict(type='list', elements='str'),
151 color=dict(type='str', choices=['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green',
152 'khaki', 'orchid', 'dark orange', 'dark sea green', 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown',
153 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon', 'coral', 'sea green',
154 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna',
155 'yellow']),
156 comments=dict(type='str'),
157 details_level=dict(type='str', choices=['uid', 'standard', 'full']),
158 groups=dict(type='list', elements='str'),
159 ignore_warnings=dict(type='bool'),
160 ignore_errors=dict(type='bool')
161 )
162 argument_spec.update(checkpoint_argument_spec_for_objects)
163
164 module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
165 api_call_object = 'tacacs-server'
166
167 result = api_call(module, api_call_object)
168 module.exit_json(**result)
169
170
171 if __name__ == '__main__':
172 main()