parsing debug information from ansible k8s_info module

Solution 1:

That isn't possible. Ansible is a CLI tool that you use to run some tasks and do some jobs. It isn't a tool for creating nice lookup terminal/shell output. So, the ok, failed, changed etc is an information that is hardcoded written to stdout.

If you only need the output for other reasons than you can call the playbook and write the output of the var to a template and stop the playbook. The next script than only outputs the data of the template. Easy example:

- name: "Write response to template"
  template:
    src: my_template.txt.j2
    dest: result.txt

And the template itself

{% for item in pod_list.resources %}
Containers in use {{ item.spec.containers }}
{% endfor %}

The response is in response.txt and can be viewed via a script like

#!/bin/sh
ansible-playbook my-play.yml > /dev/null 2>&1
cat response.txt