issue with script module in ansible 2.8

I have a shell script that is designed to run “virsh domifaddr | 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:

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,

Hi Sandeep,

Did you get it working ?

Hi Abhijeet,

Sorry for the delayed response. We can close this thread.

It was not working because, I wasn’t waiting enough for the VM to render an IP address when “virsh domifaddr” was executed.

I just added a sleep 60 in the beginning of the shell script and things went fine after that.

Thank you for your help on this. Really appreciate it.

Greetings,
Sandeep.