Skip to content

Instantly share code, notes, and snippets.

@metabsd
Created March 14, 2018 15:15
Show Gist options
  • Save metabsd/53582bfe3aeb3d3447938274c2246bf1 to your computer and use it in GitHub Desktop.
Save metabsd/53582bfe3aeb3d3447938274c2246bf1 to your computer and use it in GitHub Desktop.
Debuging the result of searching in a Json result
I setup the variable.
- name: Set Nagios XI Services Facts
uri:
url: 'https://{{ nagios_server }}/nagiosxi/api/v1/objects/service?apikey={{ nagios_api_key }}&host_name=in:{{ ansible_play_hosts | join(",") }}'
status_code: 200
method: GET
return_content: yes
validate_certs: no
headers:
Content-Type: "application/json"
timeout: 120
delegate_to: localhost
run_once: true
register: nagios_xi_services
I want to see the result of a search.
- name: Display result of variable
debug:
var: "nagios_xi_services.json.servicelist.service|selectattr('service_description', 'search', nagios_cpu_usage_service_description)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment