when: search stdout_lines

473 views
Skip to first unread message

John Harmon

unread,
Mar 1, 2018, 6:00:33 PM3/1/18
to Ansible Project
I can't seem to find the proper syntax to search the stdout_lines for a string.  Consider the following.

  tasks:
   
- name: List home dirs
      shell
: "ls /home"
     
register: home
      changed_when
: false

   
- name: List scripts directory
      shell
: "ls /home/gomer/Scripts/ | wc -l"
      changed_when
: false
     
when: "gomer" in home.stdout_lines

I have tried all sorts of combinations to search (regexp, etc), but whatever I try fails... can someone point me in the right direction?


John Harmon

unread,
Mar 1, 2018, 6:03:08 PM3/1/18
to Ansible Project
Figured it out:

when: '"gomer" in home.stdout_lines'


Reply all
Reply to author
Forward
0 new messages