I want to know if the script execution failed (but I don't want provisioning to abort) so I can run it again in a loop. Is it possible to get access to the 'exitcode' variable somehow after exection completes?
I have set "abort_on_nonzero = false", but I'd like to run something like this in my Vagrantfile:
exitcode=1
while $exitcode != 0
config.vm.provision :host_shell do |host_shell|
host_shell.abort_on_nonzero = false
host_shell.inline = "ansible-playbook apply-windows-updates.yml -e ansible_winrm_scheme=http -i .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory"
exitcode = host_shell.exitcode
config.vm.provision :reload
end
end
Basically the Ansible way of applying Windows Updates will always fails during it's run if you try it often enough. All you need to do is reboot the box, and re-run the updates to try again. What I want to do is repeat this block until there are no errors reported... but I can't find a way to do this.
I can't do a reboot via Ansible as that wipes out any port forwarding that Vagrent sets up, hence the use of the "vagrant-reload" plugin to restart the VM the Vagrant way.
Does anyone have any ideas?
I want to know if the script execution failed (but I don't want provisioning to abort) so I can run it again in a loop. Is it possible to get access to the 'exitcode' variable somehow after exection completes?
I have set "abort_on_nonzero = false", but I'd like to run something like this in my Vagrantfile:
Basically the Ansible way of applying Windows Updates will always fails during it's run if you try it often enough. All you need to do is reboot the box, and re-run the updates to try again. What I want to do is repeat this block until there are no errors reported... but I can't find a way to do this.
I can't do a reboot via Ansible as that wipes out any port forwarding that Vagrent sets up, hence the use of the "vagrant-reload" plugin to restart the VM the Vagrant way.
Does anyone have any ideas?