I have created some scripts to run when we need to install a policy based on their name.
Let's say we have a policy called "Birds" and other "Reptiles".
I have pretty much the same script for Birds and Reptiles, check the diff:
root@server:/path/to/whatever$ diff policy_Birds.yml policy_Reptiles.yml
2c2
< - name: Policy Birds
---
> - name: Policy Reptiles
9c9
< policy_package: Birds
---
> policy_package: Reptiles
18,20c18,20
< to: hello@email.com
< subject: "Playbook: Birds FAILED"
< body: "Policy Birds Failed"
---
> to: hello2@email.com
> subject: "Playbook: Reptiles FAILED"
> body: "Policy Reptiles Failed"
But when I run the Reptiles yml I get
fatal: [IP]: FAILED! => {"changed": false, "msg": "Checkpoint device returned error 404 with message {'code': 'generic_err_object_not_found', 'message': 'Requested object [bda64744-c5bf-42f7-b052-36d1aa5757db] not found'} Unpublished changes were discarded"}
This doesn't happen to Birds.
I triple checked all the names, mainly at "policy_package" to see If I didn't mistyped something. But I'd like to say that it used to work a week prior to that. The only change is that we changed the apiuser on the firewall. From a local created account to a RADIUS account.
Here are some of the "codes and configs" we are using:
cat policy_Birds.yml
---
- name: Policy Birds
hosts: check_point
connection: httpapi
tasks:
- name: Something
check_point.mgmt.cp_mgmt_install_policy:
access: true
policy_package: Birds
threat_prevention: true
ignore_errors: True
register: result
- name: mail result
mail:
host: smtp.server.goes.here
port: 25
from: ansible@domain
to: hello@email.com
subject: "Birds FAILED"
body: "Something something.. not relevant"
delegate_to: localhost
when: result is failed
Command being used to run
ansible-playbook -i hosts --vault-id checkpoint@ansible-vault policy_Birds.yml -vvv
Or policy_Reptiles.yml
Hosts
ansible-vault view --vault-id checkpoint@ansible-vault hosts
[check_point]
IP
[check_point:vars]
ansible_httpapi_use_ssl=True
ansible_httpapi_validate_certs=False
ansible_user=RADIUS_USER
ansible_password=ULTRASECRETPASSWORD
ansible_network_os=check_point.mgmt.checkpoint
Ansible Version:
ansible --version
ansible 2.9.16
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.6/site-packages/ansible
executable location = /bin/ansible
python version = 3.6.8 (default, Aug 18 2020, 08:33:21) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
Said error:
TASK [taskname] *******************************************************
fatal: [IP]: FAILED! => {"changed": false, "msg": "Checkpoint device returned error 404 with message {'code': 'generic_err_object_not_found', 'message': 'Requested object [bda64744-c5bf-42f7-b052-36d1aa5757db] not found'} Unpublished changes were discarded"}
...ignoring
Working on the other guy:
TASK [Instalar politica] *******************************************************
changed: [IP]
Permissions:
-rw-rw-r--. 1 root root 708 Mar 10 09:43 policy_Birds.yml
-rw-rw-r--. 1 root root 719 Jul 24 2020 policy_Reptiles.yml
-rw-rw-r--. 1 root root 607 Mar 9 15:47 verify_Internet.yml
cpinfo -y all:
cpinfo -y all
This is Check Point CPinfo Build 914000202 for GAIA
[IDA]
No hotfixes..
[CPFC]
HOTFIX_R80_30_JUMBO_HF_MAIN Take: 215
[MGMT]
HOTFIX_R80_30_JUMBO_HF_MAIN Take: 215
[FW1]
HOTFIX_R80_30_JUMBO_HF_MAIN Take: 215
FW1 build number:
This is Check Point Security Management Server R80.30 - Build 031
This is Check Point's software version R80.30 - Build 205
[SecurePlatform]
HOTFIX_GOGO_LT_HEAT_JHF Take: 215
[CPinfo]
No hotfixes..
[DIAG]
No hotfixes..
[Reporting Module]
HOTFIX_R80_30_JUMBO_HF_MAIN Take: 215
[CPuepm]
HOTFIX_R80_30_JUMBO_HF_MAIN Take: 215
[VSEC]
HOTFIX_R80_30_JUMBO_HF_MAIN Take: 215
[SmartLog]
HOTFIX_R80_30_JUMBO_HF_MAIN Take: 215
[R7520CMP]
No hotfixes..
[R7540CMP]
No hotfixes..
[R76CMP]
HOTFIX_R80_30_JHF_COMP Take: 215
[SFWR77CMP]
No hotfixes..
[R77CMP]
HOTFIX_R80_30_JHF_COMP Take: 215
[R75CMP]
No hotfixes..
[NGXCMP]
No hotfixes..
[EdgeCmp]
No hotfixes..
[SFWCMP]
No hotfixes..
[FLICMP]
No hotfixes..
[SFWR75CMP]
No hotfixes..
[MGMTAPI]
No hotfixes..
[CPUpdates]
BUNDLE_HCP_AUTOUPDATE Take: 24
BUNDLE_INFRA_AUTOUPDATE Take: 39
BUNDLE_DEP_INSTALLER_AUTOUPDATE Take: 20
BUNDLE_R80_30_JUMBO_HF_MAIN_gogoKernel Take: 215
[SFWR80CMP]
No hotfixes..
[CPDepInst]
No hotfixes..
[AutoUpdater]
No hotfixes..
[hcp_wrapper]
HOTFIX_HCP_AUTOUPDATE
Oh yeah, I almost forgot. I even made a new script to verify policy on Reptiles (the one with problem) And it DID work:
cat verify_Reptiles.yml
---
- name: Verify Reptiles
hosts: check_point
connection: httpapi
tasks:
- name: verify-policy
cp_mgmt_verify_policy:
policy_package: Reptiles
register: result
That's it. HELPPPPP