whitespace in stdout

2,936 views
Skip to first unread message

sma...@gmail.com

unread,
May 29, 2014, 2:12:57 PM5/29/14
to ansible...@googlegroups.com
hello, I am having a hard time finding anything in google on how to remove whitespace from the stdout results.

Here is the play:

  tasks:
    - name: get droplet IPs from inventory
      shell: ansible -i hosts testing --list-hosts
      register: droplet_inventory

    - debug: msg="{{ item|e - }}"
      with_items: "{{ droplet_inventory.stdout_lines}}"


output:

ok: [localhost] => (item=    10.128.164.13) => {
    "item": "    10.128.164.13",
    "msg": "    10.128.164.13"
}
ok: [localhost] => (item=    10.128.163.87) => {
    "item": "    10.128.163.87",
    "msg": "    10.128.163.87"
}
ok: [localhost] => (item=    10.128.163.89) => {
    "item": "    10.128.163.89",
    "msg": "    10.128.163.89"
}
ok: [localhost] => (item=    10.128.163.90) => {
    "item": "    10.128.163.90",
    "msg": "    10.128.163.90"
}


How can I get rid of the leading whitespace? 

sma...@gmail.com

unread,
May 29, 2014, 2:36:56 PM5/29/14
to ansible...@googlegroups.com
For now I solved this with:

    - debug: msg={{ item|replace(' ','') }}
      with_items: "{{ droplet_inventory.stdout_lines}}"

if anyone knows a better method please share.

Michael DeHaan

unread,
May 31, 2014, 12:12:47 PM5/31/14
to ansible...@googlegroups.com
Unclear why you need to remove whitespace from output, can you explain your use case?




--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/e4b6b942-5ce8-43ea-907e-fab3f7745b91%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages