Thanks for your help, it worked fine.

On Friday, 7 April 2017 00:25:06 UTC+5:30, Kai Stian Olstad wrote:
>
> On 06. april 2017 18:55, nishant bawane wrote: 
> > Below is the playbook using "for command". 
> > 
> > Playbook: 
> > 
> >     - name: "Fetch the ip of all the servers from hosts.new file" 
> >       shell: for i in `awk '{print $1}' hosts.new` 
> >                do echo "$i" 
> >                done 
> >       args: 
> >         chdir: "/home/dp794d/" 
> >       failed_when: "output.rc > 1" 
> >       register: output 
> >    - debug: msg="{{ output.stdout }}" 
> > 
> > Actual output : 
> > 
> > PLAY [myserver] 
> > **************************************************************** 
> > 
> > TASK [setup] 
> > ******************************************************************* 
> > ok: [zlp12037] 
> > 
> > TASK [Fetch the ip of all the servers from hosts.new file] 
> > ********************* 
> > changed: [zlp12037] 
> > 
> > TASK [set_fact] 
> > **************************************************************** 
> > ok: [zlp12037] 
> > 
>
> I'm baffled that you didn't get an error message since your for loop is 
> not valid syntax. 
>
> Try: 
>
>   shell: for i in `awk '{print $1}' hosts.new`; 
>          do echo "$i"; 
>          done 
>
>
> Or on one line 
>
>   shell: for i in `awk '{print $1}' hosts.new`; do echo "$i"; done 
>
>
> -- 
> Kai Stian Olstad 
>

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f4ac2592-5f09-47e7-a4b0-f227ac9c3eb4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to