| 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_best_practice_facts |
| 31 |
short_description: Get best-practice objects facts on Checkpoint over Web Services API |
| 32 |
description: |
| 33 |
- Get best-practice objects facts on Checkpoint devices. |
| 34 |
- All operations are performed over Web Services API. |
| 35 |
- This module handles both operations, get a specific object and get several objects, |
| 36 |
For getting a specific object use the parameter 'name' or 'best_practice_id'. |
| 37 |
- Available from R82.10 management version. |
| 38 |
version_added: "6.7.0" |
| 39 |
author: "Eden Brillant (@chkp-edenbr)" |
| 40 |
options: |
| 41 |
best_practice_id: |
| 42 |
description: |
| 43 |
- Best Practice ID. |
| 44 |
type: str |
| 45 |
name: |
| 46 |
description: |
| 47 |
- Best Practice Name. |
| 48 |
This parameter is relevant only for getting a specific object. |
| 49 |
type: str |
| 50 |
show_regulations: |
| 51 |
description: |
| 52 |
- Show the applicable regulations of the Best Practice. |
| 53 |
type: bool |
| 54 |
details_level: |
| 55 |
description: |
| 56 |
- 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 |
| 57 |
representation of the object. |
| 58 |
type: str |
| 59 |
choices: ['uid', 'standard', 'full'] |
| 60 |
blade: |
| 61 |
description: |
| 62 |
- Returns all the relevant Best Practices of the selected Software Blades. When empty will return all the Best Practices. |
| 63 |
type: list |
| 64 |
elements: str |
| 65 |
choices: ['firewall', 'gaia-os', 'anti-bot', 'anti-spam-and-mail', 'anti-virus', 'application-control', 'data-loss-prevention', |
| 66 |
'identity-awareness', 'ips', 'ipsec-vpn', 'mobile-access', 'threat-emulation', 'url-filtering', 'threat-prevention'] |
| 67 |
limit: |
| 68 |
description: |
| 69 |
- The maximal number of returned results. |
| 70 |
This parameter is relevant only for getting few objects. |
| 71 |
- Valid values are between 1 and 500. |
| 72 |
type: int |
| 73 |
offset: |
| 74 |
description: |
| 75 |
- Number of the results to initially skip. |
| 76 |
This parameter is relevant only for getting few objects. |
| 77 |
type: int |
| 78 |
status: |
| 79 |
description: |
| 80 |
- Returns all the relevant best practices with the selected statuses. When empty will return all best practices. |
| 81 |
type: list |
| 82 |
elements: str |
| 83 |
choices: ['secure', 'good', 'medium', 'poor', 'n/a'] |
| 84 |
gateway_name: |
| 85 |
description: |
| 86 |
- Returns all the relevant Best Practices of the selected Security Gateway object. |
| 87 |
type: str |
| 88 |
defined_by: |
| 89 |
description: |
| 90 |
- Returns all the relevant Best Practices of the selected type. |
| 91 |
type: str |
| 92 |
choices: ['user-defined', 'system-defined', 'any'] |
| 93 |
show_only_local_domain: |
| 94 |
description: |
| 95 |
- Indicates whether the query should return only objects from the current local domain. This parameter is only valid for local domain. |
| 96 |
type: bool |
| 97 |
extends_documentation_fragment: check_point.mgmt.checkpoint_facts |
| 98 |
""" |
| 99 |
|
| 100 |
EXAMPLES = """ |
| 101 |
- name: show-best-practice |
| 102 |
cp_mgmt_best_practice_facts: |
| 103 |
best_practice_id: FW183 |
| 104 |
|
| 105 |
- name: show-best-practices |
| 106 |
cp_mgmt_best_practice_facts: |
| 107 |
limit: '5' |
| 108 |
""" |
| 109 |
|
| 110 |
RETURN = """ |
| 111 |
ansible_facts: |
| 112 |
description: The checkpoint object facts. |
| 113 |
returned: always. |
| 114 |
type: dict |
| 115 |
""" |
| 116 |
|
| 117 |
from ansible.module_utils.basic import AnsibleModule |
| 118 |
from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_facts, api_call_facts |
| 119 |
|
| 120 |
|
| 121 |
def main(): |
| 122 |
argument_spec = dict( |
| 123 |
best_practice_id=dict(type='str'), |
| 124 |
name=dict(type='str'), |
| 125 |
show_regulations=dict(type='bool'), |
| 126 |
details_level=dict(type='str', choices=['uid', 'standard', 'full']), |
| 127 |
blade=dict(type='list', elements='str', choices=['firewall', 'gaia-os', 'anti-bot', 'anti-spam-and-mail', 'anti-virus', |
| 128 |
'application-control', 'data-loss-prevention', 'identity-awareness', 'ips', |
| 129 |
'ipsec-vpn', 'mobile-access', 'threat-emulation', 'url-filtering', 'threat-prevention']), |
| 130 |
limit=dict(type='int'), |
| 131 |
offset=dict(type='int'), |
| 132 |
status=dict(type='list', elements='str', choices=['secure', 'good', 'medium', 'poor', 'n/a']), |
| 133 |
gateway_name=dict(type='str'), |
| 134 |
defined_by=dict(type='str', choices=['user-defined', 'system-defined', 'any']), |
| 135 |
show_only_local_domain=dict(type='bool') |
| 136 |
) |
| 137 |
argument_spec.update(checkpoint_argument_spec_for_facts) |
| 138 |
|
| 139 |
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) |
| 140 |
|
| 141 |
api_call_object = "best-practice" |
| 142 |
api_call_object_plural_version = "best-practices" |
| 143 |
|
| 144 |
result = api_call_facts(module, api_call_object, api_call_object_plural_version) |
| 145 |
module.exit_json(ansible_facts=result) |
| 146 |
|
| 147 |
|
| 148 |
if __name__ == '__main__': |
| 149 |
main() |