After I provision my Vagrant... I may get errors during provision... how do I restart from error, instead of doing everything from scratch ?
vagrant destroy -f && vagrant up
And I may get an error...
PLAY RECAP ********************************************************************
to retry, use: --limit @/path/to/playbook.retry
And I want to just resume from where it failed... it seems it can be done by the message... use --limit
.... but when I use it in the vagrant context it doesn't work..
You can edit the Vagrantfile
and include the ansible.start_at_task variable.
Then you can re-run the provision with $ vagrant reload --provision
Vagrant Reload docs
However, because Ansible plays are idempotent you don't really need to do the start_at_task
. You can just re-run the provision with the reload command above.
You could do an ansible run with ansible-playbook on your vagrant box. The trick is to use the inventory file ansible has created. It is located in your .vagrant foler.
ansible-playbook playbook.yml -i vagrant/.vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory --start-at-task='MY_TASK'
Vagrantfile: Assign your roles to a vagrant machines.
config.vm.provision "ansible" do |ansible|
ansible.verbose = "v"
ansible.playbook = "../playbook.yml"
ansible.groups = {
"web" => ['vm01app'],
"db" => ['vm01db'],
}
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With