Todd Lewis <uto...@gmail.com>: Dec 27 08:53AM -0800
You probably want something like this:
- hosts: localhost
tasks:
- name: Get Service Status
ansible.builtin.systemd:
name: '{{ item }}.service'
register: hello
loop:
...more
|
Todd Lewis <uto...@gmail.com>: Dec 27 08:55AM -0800
which produces:
TASK [Dump ActiveState] **********
ok: [localhost] => {
"msg": [
{
"name": "postfix.service",
"state": "active"
},
{
...more
|
Dick Visser <dick....@geant.org>: Dec 27 09:07PM +0100
> - debug:
> msg: "{{ hello.results | to_nice_json |
> json_query('status.ActiveState') }}"
the result var is a list, so if you want a list of a specific key:
- debug:
...more
|
Thomas Stephen Lee <lee....@gmail.com>: Dec 28 08:00AM +0530
Hi @Todd Lewis,
That works.
Thanks a lot.
---
Lee
...more
|
Thomas Stephen Lee <lee....@gmail.com>: Dec 28 08:00AM +0530
Hi @Dick Visser,
That gives the below output.
-----------------%<-----------------
TASK [debug] *******************************************************************
ok: [localhost] => {
...more
|
Dick Visser <dick....@geant.org>: Dec 28 12:26PM +0100
I meant:
- debug: var=hello|json_query('results[].status.ActiveState')
--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT
...more
|
Thomas Stephen Lee <lee....@gmail.com>: Dec 28 05:27PM +0530
Hi @Dick Visser,
That gives the below output.
-----------------%<-----------------
TASK [debug] *******************************************************************
ok: [localhost] => {
...more
|
Dick Visser <dick....@geant.org>: Dec 28 01:29PM +0100
I believe this is what you wanted - right?
--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT
...more
|