Kai,

Thanks for the help! This works beautifully.

On Friday, October 20, 2017 at 1:46:48 AM UTC-4, Kai Stian Olstad wrote:
>
> On 20. okt. 2017 06:08, Ken Jenney wrote: 
> > I use a script to find an available IP on my network and then assign 
> that 
> > IP to a system. The system is up and running with the new IP but 
> > wait_for_host fails. It looks like the newline is causing issues: 
> > 
> > - name: Find a free IP 
> >    local_action: script files/find_free_ip.py {{ startip }} {{ endip }} 
> >    register: freeip 
> >    become: "no" 
> > 
> > 
> > - name: Assign the correct IP and Hostname to the VM 
> >    script: files/set_ip_and_hostname.sh {{ initialip }} {{ freeip.stdout 
> }} 
> > {{ hostname }} 
> >    changed_when: "False" 
> >    delegate_to: "{{ initialip }}" 
> > 
> > 
> > - name: Wait for VM to become available 
> >    local_action: wait_for host={{ freeip.stdout }} port=22 delay=1 \ 
> >      state=started timeout=300 
> >    become: "no" 
> > 
> > 
> > fatal: [nj-kvm02 -> localhost]: FAILED! => {"changed": false, "elapsed": 
> 300 
> > , "failed": true, "msg": "Timeout when waiting for 192.168.1.147\n:22"} 
> > 
> > How can I strip the newline character and just store the bare string in 
> a 
> > variable for re-use? 
> > 
>
> According to 
> http://jinja.pocoo.org/docs/dev/templates/#list-of-builtin-filters 
> you have the trim filter. 
>
> {{ freeip.stdout | trim }} 
>
> Storing for reuse you could use set_fact module. 
> - set_fact: 
>     vm_ip: '{{ freeip.stdout | trim }}' 
>
> -- 
> 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/e8f34b4f-e427-4a0f-9d24-12ef4b0e37cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to