Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
J_Saun
Contributor

Where used query by IP address

Is there a way in R80 to query where an object is used by IP ADDRESS rather than by name?

Additionally, I'd like to be able to script it so that you are promoted for the IP and then the query runs and returns the results.

0 Kudos
4 Replies
Joshua_Hatter
Employee
Employee

You can probably use show-objects first with ip-only and filter for the ip you want. Then send the returned objects to where-used.
J_Saun
Contributor

Thanks. I was able to get what I wanted using the command line (mgmt_cli) and using Postman but when I try to use it with ansible it errors out after login.

 

Here is my code:

- name: "show objects"
check_point_mgmt:
command: show-objects
parameters:
"limit" : 50
"offset" : 0
"type" : "object"
"filter" : "1.2.3.6"
"ip-only" : true
session-data: "{{ login_response }}"

 

0 Kudos
J_Saun
Contributor

I was able to get the script to work. I was missing quotes around the word TRUE:

- name: "show objects"
check_point_mgmt:
command: show-objects
parameters:
"limit" : 50
"offset" : 0
"type" : "object"
"filter" : "1.2.3.6"
"ip-only" : "true"
session-data: "{{ login_response }}"

 

My next challenge is to have the output from the above command displayed without using -vvv. I tried using REGISTER but it errors out:

- name: "show objects"
check_point_mgmt:
command: show-objects
parameters:
"limit" : 50
"offset" : 0
"type" : "object"
"filter" : "1.2.3.6"
"ip-only" : "true"
session-data: "{{ login_response }}"

register: shell_result

- debug: var=shell_result.stdout_lines

 

ERROR

TASK [show objects] *************************************************************************************************************************************************************************************************************************
fatal: [127.0.0.1]: FAILED! => {"changed": false, "msg": "Unsupported parameters for (check_point_mgmt) module: register Supported parameters include: command,fingerprint,parameters,session-data"}

 

Any help would be appreciated.

 

0 Kudos
J_Saun
Contributor

Figured it out. Had to remove .stdout_lines form debug:

(login commands removed)

- name: "show objects"
check_point_mgmt:
command: show-objects
parameters:
filter : "1.2.3.6"
ip-only : "true"
session-data: "{{ login_response }}"
register: shell_result

- debug: var=shell_result

 

Note that Ansible is picky about columns. The above script needs to be formatted correctly (proper alignment and indentations).

0 Kudos