lee  
                
                  
                    December 27, 2021,  6:30am
                   
                  1 
               
             
            
              Hi,
I am trying to write a playbook that displays the ActiveState of some
-----------------%<-----------------
- hosts: localhost
-----------------%<-----------------
The output is
-----------------%<-----------------
PLAY [localhost] ***************************************************************
TASK [Gathering Facts] *********************************************************
TASK [Get Service Status] ******************************************************
TASK [debug] *******************************************************************
PLAY RECAP *********************************************************************
-----------------%<-----------------
Kindly advice
Thanks
             
            
              
            
           
          
            
            
              Can you post the unfiltered variable hello
             
            
              
            
           
          
            
            
              You can try something like this if it suits your requirements.
             
            
              
            
           
          
            
              
                lee  
              
                  
                    December 27, 2021, 10:20am
                   
                  4 
               
             
            
            
              
            
           
          
            
              
                lee  
              
                  
                    December 27, 2021, 10:21am
                   
                  5 
               
             
            
              Hi @Marian  Saldhana,
I need a loop as I want to add more services and machines.
Thanks
             
            
              
            
           
          
            
              
                utoddl  
              
                  
                    December 27, 2021,  4:53pm
                   
                  6 
               
             
            
              You probably want something like this:
hosts: localhost
 
name: Get Service Status
 
postfix
 
rsyslog
 
sshd
 
name: Dump ActiveState
 
 
             
            
              
            
           
          
            
              
                utoddl  
              
                  
                    December 27, 2021,  4:55pm
                   
                  7 
               
             
            
              which produces:
             
            
              
            
           
          
            
            
              the result var is a list, so if you want a list of a specific key:
- debug: var=results|json_query('
             
            
              
            
           
          
            
              
                lee  
              
                  
                    December 28, 2021,  2:30am
                   
                  9 
               
             
            
              Hi @Dick  Visser,
That gives the below output.
-----------------%<-----------------
TASK [debug] *******************************************************************
-----------------%<-----------------
Thanks
             
            
              
            
           
          
            
              
                Dick_Visser  
              
                  
                    December 28, 2021, 11:26am
                   
                  11 
               
             
            
              I meant:
- debug: var=hello|json_query('results
             
            
              
            
           
          
            
              
                lee  
              
                  
                    December 28, 2021, 11:57am
                   
                  12 
               
             
            
              Hi @Dick  Visser,
That gives the below output.
-----------------%<-----------------
TASK [debug] *******************************************************************
-----------------%<-----------------
I will explore more, thanks a lot.
             
            
              
            
           
          
            
              
                Dick_Visser  
              
                  
                    December 28, 2021, 12:29pm
                   
                  13 
               
             
            
              I believe this is what you wanted - right?
             
            
              
            
           
          
            
              
                lee  
              
                  
                    December 29, 2021,  5:30am
                   
                  14 
               
             
            
              Hi @Dick  Visser,
In my code, I wrote only for the state value, but I also wanted the
My current status is
-----------------%<-----------------
Thanks a lot.
             
            
              
            
           
          
            
              
                lee  
              
                  
                    January 25, 2022,  7:30am
                   
                  15 
               
             
            
              Hi,
My current status is attached.
Thanks a lot.
(attachments) 
get.services.list.yml  (1.61 KB)