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

Need help in validation of service object , json parsing

Hi Team,

I am using the show-objects api to  filter the service  objects and then i am trying to fetch the name and uid of the service object.


my code is working when only one name is present against the port  however if multiple name present it is not working .

Please help me to query json for provided port number and get all the service names agains that.

- name: ALL TCP service object
url: "https://{{hostname}}/web_api/show-objects"
validate_certs: False
method: POST
x-chkp-sid: "{{ login.json.sid }}"
filter: "{{svc_port}}"
type: "service-tcp"
offset: 0
details-level: full
body_format: json
register: check_host_result
when: proto == 'tcp'

and then using set set_fact ansible module

- name: Checking if Source already exists
item_type_exists: true
svc_name: "{{ item['name'] }}"
svc_uid: "{{ item['uid'] }}"
- "{{check_host_result.json.objects }}"
- item['type'] is defined
- item['type'] == "service-tcp"
- item['port'] == '5000'

it is giving me only one service object name not all service names. I tried to search with jq also but there has also  issue for multiple names. 


used below jq-

jmesquery: '[? port=="5000"].{Name: name,uid: uid,port: port }'

I am new to the this and stuck here , Please help me,appreciate your help in advance

0 Kudos
0 Replies
Upcoming Events

    CheckMates Events