Debian Codegraph @

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

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 #
4 # Ansible module to manage Check Point 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_install_policy
33 short_description: install policy on Check Point over Web Services API
34 description:
35 - install policy on Check Point over Web Services API
36 - All operations are performed over Web Services API.
37 - Available from R80 management version.
38 version_added: "1.0.0"
39 author: "Or Soffer (@chkp-orso)"
40 options:
41 policy_package:
42 description:
43 - The name of the Policy Package to be installed.
44 type: str
45 targets:
46 description:
47 - On what targets to execute this command. Targets may be identified by their name, or object unique identifier.
48 type: list
49 elements: str
50 access:
51 description:
52 - Set to be true in order to install the Access Control policy. By default, the value is true if Access Control policy is enabled on the input
53 policy package, otherwise false.
54 type: bool
55 desktop_security:
56 description:
57 - Set to be true in order to install the Desktop Security policy. By default, the value is true if desktop security policy is enabled on the
58 input policy package, otherwise false.
59 - Available from R80.20.M1 management version.
60 type: bool
61 qos:
62 description:
63 - Set to be true in order to install the QoS policy. By default, the value is true if Quality-of-Service policy is enabled on the input policy
64 package, otherwise false.
65 - Available from R80.20.M1 management version.
66 type: bool
67 threat_prevention:
68 description:
69 - Set to be true in order to install the Threat Prevention policy. By default, the value is true if Threat Prevention policy is enabled on the
70 input policy package, otherwise false.
71 type: bool
72 install_on_all_cluster_members_or_fail:
73 description:
74 - Relevant for the gateway clusters. If true, the policy is installed on all the cluster members. If the installation on a cluster member fails,
75 don't install on that cluster.
76 - Available from R80.10 management version.
77 type: bool
78 prepare_only:
79 description:
80 - If true, prepares the policy for the installation, but doesn't install it on an installation target.
81 - Available from R80.10 management version.
82 type: bool
83 revision:
84 description:
85 - The UID of the revision of the policy to install.
86 - Available from R80.10 management version.
87 type: str
88 extends_documentation_fragment: check_point.mgmt.checkpoint_commands
89 """
90
91 EXAMPLES = """
92 - name: install-policy
93 cp_mgmt_install_policy:
94 access: true
95 policy_package: standard
96 targets:
97 - corporate-gateway
98 threat_prevention: true
99 """
100
101 RETURN = """
102 cp_mgmt_install_policy:
103 description: The checkpoint install-policy output.
104 returned: always.
105 type: dict
106 """
107
108 from ansible.module_utils.basic import AnsibleModule
109 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
110 checkpoint_argument_spec_for_commands,
111 api_command,
112 )
113
114
115 def main():
116 argument_spec = dict(
117 policy_package=dict(type="str"),
118 targets=dict(type="list", elements="str"),
119 access=dict(type="bool"),
120 desktop_security=dict(type="bool"),
121 qos=dict(type="bool"),
122 threat_prevention=dict(type="bool"),
123 install_on_all_cluster_members_or_fail=dict(type="bool"),
124 prepare_only=dict(type="bool"),
125 revision=dict(type="str"),
126 )
127 argument_spec.update(checkpoint_argument_spec_for_commands)
128
129 module = AnsibleModule(argument_spec=argument_spec)
130
131 command = "install-policy"
132
133 result = api_command(module, command)
134 module.exit_json(**result)
135
136
137 if __name__ == "__main__":
138 main()