Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_add_domain.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 = {
25 "metadata_version": "1.1",
26 "status": ["preview"],
27 "supported_by": "community",
28 }
29
30 DOCUMENTATION = """
31 ---
32 module: cp_mgmt_add_domain
33 short_description: Create new object
34 description:
35 - Create new object
36 - All operations are performed over Web Services API.
37 - Available from R80 management version.
38 version_added: "2.1.0"
39 author: "Or Soffer (@chkp-orso)"
40 options:
41 name:
42 description:
43 - Object name.
44 type: str
45 required: True
46 servers:
47 description:
48 - Domain servers. When this field is provided, 'set-domain' command is executed asynchronously.
49 type: list
50 elements: dict
51 suboptions:
52 name:
53 description:
54 - Object name. Must be unique in the domain.
55 type: str
56 ip_address:
57 description:
58 - IPv4 or IPv6 address. If both addresses are required use ipv4-address and ipv6-address fields explicitly.
59 type: str
60 ipv4_address:
61 description:
62 - IPv4 address.
63 type: str
64 ipv6_address:
65 description:
66 - IPv6 address.
67 type: str
68 multi_domain_server:
69 description:
70 - Multi Domain server name or UID.
71 type: str
72 active:
73 description:
74 - Activate domain server. Only one domain server is allowed to be active
75 type: bool
76 skip_start_domain_server:
77 description:
78 - Set this value to be true to prevent starting the new created domain.
79 type: bool
80 type:
81 description:
82 - Domain server type.
83 type: str
84 choices: ['management server', 'log server', 'smc']
85 color:
86 description:
87 - Color of the object. Should be one of existing colors.
88 type: str
89 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
90 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
91 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
92 comments:
93 description:
94 - Comments string.
95 type: str
96 details_level:
97 description:
98 - 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
99 representation of the object.
100 type: str
101 choices: ['uid', 'standard', 'full']
102 ignore_warnings:
103 description:
104 - Apply changes ignoring warnings.
105 type: bool
106 ignore_errors:
107 description:
108 - 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.
109 type: bool
110 extends_documentation_fragment: check_point.mgmt.checkpoint_commands
111 """
112
113 EXAMPLES = """
114 - name: add-domain
115 cp_mgmt_add_domain:
116 name: domain1
117 servers:
118 ip_address: 192.0.2.1
119 multi_domain_server: MDM_Server
120 name: domain1_ManagementServer_1
121 """
122
123 RETURN = """
124 cp_mgmt_domain:
125 description: The checkpoint add-domain output.
126 returned: always.
127 type: dict
128 """
129
130 from ansible.module_utils.basic import AnsibleModule
131 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
132 checkpoint_argument_spec_for_commands,
133 api_command,
134 )
135
136
137 def main():
138 argument_spec = dict(
139 name=dict(type="str", required=True),
140 servers=dict(
141 type="list",
142 elements="dict",
143 options=dict(
144 name=dict(type="str"),
145 ip_address=dict(type="str"),
146 ipv4_address=dict(type="str"),
147 ipv6_address=dict(type="str"),
148 multi_domain_server=dict(type="str"),
149 active=dict(type="bool"),
150 skip_start_domain_server=dict(type="bool"),
151 type=dict(
152 type="str",
153 choices=["management server", "log server", "smc"],
154 ),
155 ),
156 ),
157 color=dict(
158 type="str",
159 choices=[
160 "aquamarine",
161 "black",
162 "blue",
163 "crete blue",
164 "burlywood",
165 "cyan",
166 "dark green",
167 "khaki",
168 "orchid",
169 "dark orange",
170 "dark sea green",
171 "pink",
172 "turquoise",
173 "dark blue",
174 "firebrick",
175 "brown",
176 "forest green",
177 "gold",
178 "dark gold",
179 "gray",
180 "dark gray",
181 "light green",
182 "lemon chiffon",
183 "coral",
184 "sea green",
185 "sky blue",
186 "magenta",
187 "purple",
188 "slate blue",
189 "violet red",
190 "navy blue",
191 "olive",
192 "orange",
193 "red",
194 "sienna",
195 "yellow",
196 ],
197 ),
198 comments=dict(type="str"),
199 details_level=dict(type="str", choices=["uid", "standard", "full"]),
200 ignore_warnings=dict(type="bool"),
201 ignore_errors=dict(type="bool"),
202 )
203 argument_spec.update(checkpoint_argument_spec_for_commands)
204
205 module = AnsibleModule(argument_spec=argument_spec)
206 command = "add-domain"
207
208 result = api_command(module, command)
209 module.exit_json(**result)
210
211
212 if __name__ == "__main__":
213 main()