Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
sergey1
Participant

Ansible

Hi all, I'm trying to make a playbook to automate some commands on a Check Point (virtual).

Playbook:

---
- hosts: mgmt-server
tasks:
- name: "login"
check_point_mgmt:
command: login
parameters:
username: "{{mgmt_user}}"
password: "{{mgmt_password}}"
management: "{{mgmt_server}}"
fingerprint: "{{mgmt_fingerprint}}"
register: login_response

 - name: "set static-route default nexthop gateway address"
command: clish -c 'set static-route default nexthop gateway address 10.0.0.1 on' -s

Host:

## db-[99:101]-node.example.com
[mgmt-server]
127.0.0.1
[mgmt-server:vars]
ansible_user=ubuntu
mgmt_server=10.11.3.185
appliance_name=MGMT
ansible_python_interpreter=/usr/bin/python2.7
mgmt_user=admin
mgmt_password=1q2w3e
mgmt_fingerprint=43:2E:E0:61:FC:0B:E5:BD:02:42:9E:49:FA:79:46:5F:B4:C0:84:2C

Ansible.cfg:

library = /usr/share/my_modules/

Error:

*
fatal: [127.0.0.1]: FAILED! => {"changed": false, "cmd": "clish -c 'set static-route default nexthop gateway address 10.0.0.1 on' -s", "msg": "[Errno 2] No such file or directory", "rc": 2}

Снимок_1.PNG

But I have NOT problem with playbook:

---
- hosts: mgmt-server
tasks:
- name: "login"
check_point_mgmt:
command: login
parameters:
username: "{{mgmt_user}}"
password: "{{mgmt_password}}"
management: "{{mgmt_server}}"
fingerprint: "{{mgmt_fingerprint}}"
register: login_response
- name: "add host"
check_point_mgmt:
command: add-host 
parameters: 
name: "host_demo"
ip-address: "1.2.3.5"
session-data: "{{ login_response }}"
- name: "add group"
check_point_mgmt:
command: add-group
parameters:
name: "group_demo"
members:
- "host_demo"
session-data: "{{ login_response }}"
- name: "publish" 
check_point_mgmt: 
command: publish
session-data: "{{login_response}}"

 

Can someone assist? Thanks!

0 Kudos
2 Replies
PhoneBoy
Admin
Admin

Pretty sure the Python interpreter you're calling is incorrect for Gaia OS.
You might look at some other examples posted to the community, e.g. https://community.checkpoint.com/t5/Ansible/Ansible-based-automation-for-Check-Point-Management-Serv...
0 Kudos
sergey1
Participant

Errors were in the module and in the code. Now my code is working. Thanks.
0 Kudos
Upcoming Events

    CheckMates Events