Hii You're trying to parse the standard format, which is not meant to be parsed. Instead use the json output option of kubectl.
On Mon, 19 Dec 2022 at 09:10, Deepanshu Dang <[email protected]> wrote: > > Hi team > > Need your support I'm looking out for put loop on register stdout _lines > my stdout_lines output is this > > "stdout_lines": [ > "NAME READY STATUS RESTARTS AGE", > "kafka-0 1/1 Running 3 (3h1m ago) 3d", > "kafka-1 1/1 Running 3 (3h1m ago) 3d", > "kafka-zookeeper-0 1/1 Running 1 (3h2m ago) 3d" > ] > > My playbook task is this > > - name: List of {{release_name}} pods > shell: kubectl get pods -l 'app.kubernetes.io/component in > (zookeeper,kafka)' > register: pod_output > when: pod_status is succeeded > - debug: > var: pod_output.stdout_lines > > Output: > > "pod_output": { > "changed": true, > "cmd": "kubectl get pods -l 'app.kubernetes.io/component in > (zookeeper,kafka)'", > "delta": "0:00:00.080215", > "end": "2022-12-19 07:35:22.925000", > "failed": false, > "rc": 0, > "start": "2022-12-19 07:35:22.844785", > "stderr": "", > "stderr_lines": [], > "stdout": "NAME READY STATUS RESTARTS AGE\nkafka-0 1/1 Running 3 (3h1m ago) > 3d\nkafka-1 1/1 Running 3 (3h1m ago) 3d\nkafka-zookeeper- > 0 1/1 Running 1 (3h2m ago) 3d", > "stdout_lines": [ > "NAME READY STATUS RESTARTS AGE", > "kafka-0 1/1 Running 3 (3h1m ago) 3d", > "kafka-1 1/1 Running 3 (3h1m ago) 3d", > "kafka-zookeeper-0 1/1 Running 1 (3h2m ago) 3d" > ] > } > } > > Now i want to put loop or with_items on the stdout_lines to check the status > of running if it is not running i will get a result > > How can i achieve this with the help of loop or with_items. > Stdout_lines are list but when i'm trying it it showing me {"msg": "'dict > object' has no attribute 'stdout'"} > > How can I achieve this can you please help me > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/3ef3ca96-f266-4863-a9bf-8942dbad73dbn%40googlegroups.com. -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAF8BbLZBcAPqEQ%2BrQwEwv8rgqL25nh2MhnVZUy1Hvx_nZcoQQA%40mail.gmail.com.
