Jamespath in Ansible Playbooks
Santhosh Balasa
Posted on June 22, 2020
Have you ever heard of JSON query language ? Well, if not take a look at this: https://jmespath.org/examples.html
This is absolutely brilliant when you're trying to get the exact information from the JSON results spitted by Ansible play runs especially, let me show you an example on how you can actually register the output to a variable and run your query on it.
Example:
- name: Sample Playbook
// Fill up your task
no_log: True
register: example_output
- name: Json Query
set_fact:
query_result:
example_output:"{{ example_output | json_query('results[*].name') }}"
💖 💪 🙅 🚩
Santhosh Balasa
Posted on June 22, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
kubernetes Setting Up a Production-Ready Kubernetes Cluster with RKE2 in vSphere Using Terraform
November 29, 2024