Can you post the unfiltered variable hello

On Mon, 27 Dec 2021 at 07:32, Thomas Stephen Lee <[email protected]> wrote:

> Hi,
>
> I am trying to write a playbook that displays the ActiveState of some
> services on a machine. I tried various tips from google but could not
> get the information I wanted, which is the "service.ActiveState" .
> Below is the bare minimum script.
>
> -----------------%<-----------------
>
> - hosts: localhost
>   tasks:
>   - name: Get Service Status
>     ansible.builtin.systemd:
>       name: '{{ item }}.service'
>     register: hello
>     loop:
>       - postfix
>       - rsyslog
>       - sshd
>   - debug:
>       msg: "{{ hello.results | to_nice_json |
> json_query('status.ActiveState') }}"
>
> -----------------%<-----------------
>
> The output is
>
> -----------------%<-----------------
>
> PLAY [localhost]
> ***************************************************************
>
> TASK [Gathering Facts]
> *********************************************************
> ok: [localhost]
>
> TASK [Get Service Status]
> ******************************************************
> ok: [localhost] => (item=postfix)
> ok: [localhost] => (item=rsyslog)
> ok: [localhost] => (item=sshd)
>
> TASK [debug]
> *******************************************************************
> ok: [localhost] => {}
>
> PLAY RECAP
> *********************************************************************
> localhost                  : ok=3    changed=0    unreachable=0
> failed=0    skipped=0    rescued=0    ignored=0
>
> -----------------%<-----------------
>
> Kindly advice
>
> Thanks
>
> ---
> Lee
>
> --
> 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/CAG7s96V2RgCu6LrKt06DKigdH-_DA0n%2Bp8Tsv9s6UB4205__BQ%40mail.gmail.com
> .
>
> --
Sent from a mobile device - please excuse the brevity, spelling and
punctuation.

-- 
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/CAL8fbwOSnpe%3D_zn4fxm5X7Sy3ofcHDdrUWMjm5YnvEM%3DZeAtNQ%40mail.gmail.com.

Reply via email to