Hi Sandeep,
Could you please provide -vvvv log for your playbook run ? Without that
information it is very difficult to know what is wrong. I would recommend
you to add more debugging statements in shell script before running via
Ansible. btw, I see domain name hardcoded at "domifaddr" line (is that
expected ?).
Thanks,
On Tuesday, November 5, 2019 at 4:41:34 PM UTC+5:30, Sandeep Sridhar wrote:
>
> I have a shell script that is designed to run "virsh domifaddr <domain
> name> | grep ipv4 | awk '{print $4}'" on the remote host. From my ansible
> controller, the playbook calls this piece:
>
> - name: Find out the IP address of ucloud_vm_name
> script: /root/mltr_source_code/compute_ucloud_vm_ip.sh {{
> ucloud_vm_name }}
>
> The actual shell script is as follows:
>
> ucloud_vm_name=$1
> ucloud_vm_status=`virsh list --all | grep $ucloud_vm_name | awk '{print $3}'`
> ucloud_vm_ip_file=/root/$ucloud_vm_name.ip
> echo "ucloud_vm_status=$ucloud_vm_status"
> if [ "$ucloud_vm_status" = "running" ]
> then
> ucloud_vm_ip=`virsh domifaddr mini | grep ipv4 | awk '{print $4}'`
> if [ -f /root/$ucloud_vm_name.ip ]
> then
> rm -rf /root/$ucloud_vm_name.ip
> fi
> echo $ucloud_vm_ip > /root/$ucloud_vm_name.ip
> elif [ "$ucloud_vm_status" = "shut off" ]
> then
> echo "undercloud_vm is shut off"
> else
> # do nothing
> echo "Have a beer"
> fi
>
> playbook runs fine without any errors. However, the IP address is never
> computed and written onto /root/$ucloud_vm_name.ip. The file content is
> empty after running the playbook.
>
> Interestingly, if I execute the above shell script manually on the remote
> host, it just runs fine. Only if I execute from the ansible controller
> through script module, the content of /root/$ucloud_vm_name.ip is empty
> always.
>
> Can you please help me with what is going wrong?
>
> -Sandeep.
>
>
--
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/2a206ff2-fd18-4a77-9b57-570ec89a6a0d%40googlegroups.com.