Hi,

When I try to split the output of uptime to capture the "load average from 
the below line

$ uptime
 18:37:01 up 5 days,  4:37,  2 users,  load average: 0.02, 0.05, 0.00

using the below playbook 

---
- name: uptime_collect22
  hosts: localhost
  gather_facts: no
  tasks:
    - name:  register the uptime
      shell: "uptime"
      register: up_out

    - set_fact:
        #load_avg: "{{ up_out.stdout_lines[0].split()[[7],[8],[9],[10]] }}"
        load_avg: "{{ up_out.stdout_lines[0].split()[7] }}"

    - name: print the load average
      debug:
        var: load_avg

when i execute i got the output debug as 
TASK [print the   load average  ] 
***********************************************************************************************************************************************
ok: [my-client-2] => {
    "load_avg": "load"
}

I can split the stdout lines . How can I split/print with  multiple columns 
similar to awk '{print $7,$8,$9,$10}'  .?
Expected output:  "load average: 0.02, 0.05, 0.00"  

I can achieve it with shell module with uptime |awk '{print $8,$9,$10, $11, 
$12}'
However I want to check the  ansible filtering and split 


-- 
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/31258954-4fc0-4ef7-91b1-2fb7f92b5066n%40googlegroups.com.

Reply via email to