18/03/2018 - ANSIBLE, VAGRANT
Eğer Vagrant ile Ansible versiyonlama yaparken Ansible etiketi kullanmak isterseniz, aşağıdaki örneği kullanabilirsiniz.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
...
config.vm.provision "ansible" do |ansible|
...
ansible.playbook = "provisioning/site.yml"
ansible.raw_arguments = Shellwords.shellsplit(ENV["ANSIBLE_ARGS"]) if ENV["ANSIBLE_ARGS"]
...
end
...
end
# If running first time, runs all tasks within provisioning otherwise just starts the VM and ignores all tasks
$ vagrant up
# Runs all tasks within provisioning without restarting the VM
$ vagrant provision
# Does not run provisioning but restarts the VM
$ vagrant reload
# Runs all tasks within provisioning with restarting the VM
$ vagrant reload --provision
# If running first time, runs tasks for given tags within provisioning otherwise just starts the VM and ignores all tasks.
$ ANSIBLE_ARGS='--tags "tag_1,tag_2,..."' vagrant up
# Runs tasks for given tags within provisioning without restarting the VM
$ ANSIBLE_ARGS='--tags "tag_1,tag_2,..."' vagrant provision
# Runs tasks for given tags within provisioning with restarting the VM
$ ANSIBLE_ARGS='--tags "tag_1,tag_2,..."' vagrant reload --provision
# You can also use other tags like below
$ ANSIBLE_ARGS='--skip-tags "tag_1,tag_2,..."' vagrant ...
Eğer herhangi bir iş herhangi bir nedende dolayı durursa, --limit
etiketini kullanabilirsiniz. Bu etiket, işin ilişkide olduğu makinanın içindeki tüm işleri yeniden çalıştırır. Komutun tamamı hata mesajının hemen altında verilecektir. Örnek: --limit @/Users/inanzzz/test_app/provisioning/site.retry