Reputation: 28879
The Ansible task that I use to mount ISO images on Windows sometimes fails.
openstack: TASK [Ensure an ISO is mounted] ************************************************
openstack: An exception occurred during task execution. To see the full traceback, use -vvv. The error was: at <ScriptBlock>, <No file>: line 54
openstack: fatal: [10.0.134.144]: FAILED! => changed=false
openstack: msg: 'Unhandled exception while executing module: The property ''DriveLetter'' cannot be found on this object. Verify that the property exists.'
I call the Ansible task like this.
- name: Ensure an ISO is mounted
community.windows.win_disk_image:
image_path: '{{tempfile.path}}/en_visual_studio_express_2013_for_windows_with_update_5_x86_dvd_6815614.iso'
state: present
register: disk_image_out
retries: 5
delay: 3
Line 54 in the PowerShell script that backs the ansible task seems to be https://github.com/ansible-collections/community.windows/blob/0f1082c372d4351751de360c1f86728adbd4386a/plugins/modules/win_disk_image.ps1#L54
# ISO, we can get the mountpoint directly from Get-Volume
$drive_letters = ($di | Get-Volume).DriveLetter
Is the PowerShell script missing a necessary wait/retry to get the DriveLetter
reliably? Why doesn't ansible retry the mount task, given that I specify retries: 5
, delay: 3
in the yaml?
Upvotes: 1
Views: 391
Reputation: 28879
First of all, I made mistake in the Ansible YAML. Retry count is ignored if until
key is not present. Therefore, what I needed to do is the following
- name: Ensure an ISO is mounted
community.windows.win_disk_image:
image_path: '{{tempfile.path}}/en_visual_studio_express_2012_for_windows_desktop_x86_dvd_1001986.iso'
state: present
register: disk_image_out
retries: 5
delay: 3
until: "disk_image_out is not failed"
the following works too
until: "disk_image_out is succeeded"
to get
openstack: TASK [Ensure an ISO is mounted] ************************************************
openstack: FAILED - RETRYING: [10.0.133.179]: Ensure an ISO is mounted (5 retries left).
openstack: ok: [10.0.133.179]
I still suspect that some additional wait loop is required in the PowerShell script that implements the Ansible task, but, in the meantime, I seem to be able to apply a retry in the Ansible YAML script instead.
Upvotes: 1