is it possible to never run *specific* provisioner?

369 views
Skip to first unread message

Dharmesh Sheta

unread,
Jun 19, 2015, 10:16:16 AM6/19/15
to vagra...@googlegroups.com
It is possible to run 

vagrant provision --no-provision   (for not running any provisioner)

vagrant provision --provision-with  X  (running specfic provisioner)

It is also possible to run some provisioner as "always"

config.vm.provision "shell", run: "always"  in the Vagrantfile.

Is it possible to run   config.vm.provision "shell", run: "never" and make it only possible if    vagrant provision --provision-with  X is used?
In other word, is it possible to run specific provisioner only if called using "vagrant provision --provision-with  X" in any other case including  vagrant up, vagrant reload it should run(not even once) ?

Patricio Marrone

unread,
Sep 25, 2015, 11:32:41 AM9/25/15
to Vagrant
I worked around this issue by wrapping my "never" provisioners in a condition that checks that --provision-with is present. In my Vagrantfile:

  config.vm.provision "main", type: :ansible do |ansible|
    ansible
.playbook = "site.yml"
 
end
 
if ARGV.include? '--provision-with'
    config
.vm.provision "update", type: :ansible do |ansible|
      ansible
.playbook = "update.yml"
   
end
 
end

This seems to work for me.
Reply all
Reply to author
Forward
0 new messages