| 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_global_assignment_facts |
| 33 |
short_description: Get global-assignment objects facts on Check Point over Web Services API |
| 34 |
description: |
| 35 |
- Get global-assignment objects facts on Check Point devices. |
| 36 |
- All operations are performed over Web Services API. |
| 37 |
- This module handles both operations, get a specific object and get several objects, |
| 38 |
For getting a specific object use the parameter 'name'. |
| 39 |
- Available from R80 management version. |
| 40 |
version_added: "1.0.0" |
| 41 |
author: "Or Soffer (@chkp-orso)" |
| 42 |
options: |
| 43 |
dependent_domain: |
| 44 |
description: |
| 45 |
- N/A |
| 46 |
type: str |
| 47 |
global_domain: |
| 48 |
description: |
| 49 |
- N/A |
| 50 |
type: str |
| 51 |
details_level: |
| 52 |
description: |
| 53 |
- 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 |
| 54 |
representation of the object. |
| 55 |
type: str |
| 56 |
choices: ['uid', 'standard', 'full'] |
| 57 |
limit: |
| 58 |
description: |
| 59 |
- No more than that many results will be returned. |
| 60 |
This parameter is relevant only for getting few objects. |
| 61 |
type: int |
| 62 |
offset: |
| 63 |
description: |
| 64 |
- Skip that many results before beginning to return them. |
| 65 |
This parameter is relevant only for getting few objects. |
| 66 |
type: int |
| 67 |
order: |
| 68 |
description: |
| 69 |
- Sorts results by the given field. By default the results are sorted in the ascending order by name. |
| 70 |
This parameter is relevant only for getting few objects. |
| 71 |
type: list |
| 72 |
elements: dict |
| 73 |
suboptions: |
| 74 |
ASC: |
| 75 |
description: |
| 76 |
- Sorts results by the given field in ascending order. |
| 77 |
type: str |
| 78 |
choices: ['name'] |
| 79 |
DESC: |
| 80 |
description: |
| 81 |
- Sorts results by the given field in descending order. |
| 82 |
type: str |
| 83 |
choices: ['name'] |
| 84 |
extends_documentation_fragment: check_point.mgmt.checkpoint_facts |
| 85 |
""" |
| 86 |
|
| 87 |
EXAMPLES = """ |
| 88 |
- name: show-global-assignment |
| 89 |
cp_mgmt_global_assignment_facts: |
| 90 |
dependent_domain: domain1 |
| 91 |
global_domain: Global2 |
| 92 |
|
| 93 |
- name: show-global-assignments |
| 94 |
cp_mgmt_global_assignment_facts: |
| 95 |
details_level: standard |
| 96 |
limit: 50 |
| 97 |
offset: 0 |
| 98 |
""" |
| 99 |
|
| 100 |
RETURN = """ |
| 101 |
ansible_facts: |
| 102 |
description: The checkpoint object facts. |
| 103 |
returned: always. |
| 104 |
type: dict |
| 105 |
""" |
| 106 |
|
| 107 |
from ansible.module_utils.basic import AnsibleModule |
| 108 |
from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import ( |
| 109 |
checkpoint_argument_spec_for_facts, |
| 110 |
api_call_facts, |
| 111 |
) |
| 112 |
|
| 113 |
|
| 114 |
def main(): |
| 115 |
argument_spec = dict( |
| 116 |
dependent_domain=dict(type="str"), |
| 117 |
global_domain=dict(type="str"), |
| 118 |
details_level=dict(type="str", choices=["uid", "standard", "full"]), |
| 119 |
limit=dict(type="int"), |
| 120 |
offset=dict(type="int"), |
| 121 |
order=dict( |
| 122 |
type="list", |
| 123 |
elements="dict", |
| 124 |
options=dict( |
| 125 |
ASC=dict(type="str", choices=["name"]), |
| 126 |
DESC=dict(type="str", choices=["name"]), |
| 127 |
), |
| 128 |
), |
| 129 |
) |
| 130 |
argument_spec.update(checkpoint_argument_spec_for_facts) |
| 131 |
|
| 132 |
module = AnsibleModule( |
| 133 |
argument_spec=argument_spec, supports_check_mode=True |
| 134 |
) |
| 135 |
|
| 136 |
api_call_object = "global-assignment" |
| 137 |
api_call_object_plural_version = "global-assignments" |
| 138 |
|
| 139 |
result = api_call_facts( |
| 140 |
module, api_call_object, api_call_object_plural_version |
| 141 |
) |
| 142 |
module.exit_json(ansible_facts=result) |
| 143 |
|
| 144 |
|
| 145 |
if __name__ == "__main__": |
| 146 |
main() |