Given a minimal example Vagrantfile like:
VAGRANTFILE_API_VERSION = '2'
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = 'chef/ubuntu-14.04'
config.vm.provision 'bootstrap', type: :shell, inline: 'echo BOOTSTRAP!'
config.vm.provision 'deploy', type: :shell, inline: 'echo DEPLOY!'
end
I expect vagrant up --provision-with bootstrap to work intuitively, but instead:
$ vagrant up --provision-with bootstrap
'bootstrap' is not a known provisioner. Please specify a valid provisioner.
It appears that the command validation for up in StartupMixins only respects the _types_ of registered provisioner plugins, not user-supplied names. Digging in the code and looking back at the changes in #4700, to my understanding so far there currently isn't a mapping of names to provisioner types or instances available except during a provision action when the stuff from MixinProvisioners is called, or else by grabbing instances of VagrantConfigProvisioner from a specific machine like env[:machine].config.vm.provisioners.
I'm not totally clear on initialization order yet, but at the stage of validating the up command I'd assume we'd have to iterate over machines to get the provisioner names set on them, or come up with a cleaner way of achieving that if one doesn't already exist. If anyone can point me in the right direction on that I will try to cook up a patch.
Can someone update the documentation then?
http://docs.vagrantup.com/v2/cli/provision.html
it CLEARLY states:
"The arguments to --provision-with can be the provisioner type (such as "shell") or the provisioner name (such as "bootstrap" from above)."
which is wrong.
@tacoben That document is technically correct, it _does_ work for the provision subcommand. User-supplied name _does not_ work for up (and it'd be really nice if it did).
Is this an enhancement or a bug?
@ches you are correct - i was getting confused.
i just confirmed it.
You are not the only one who get confused. It is confusing that the same option e.g. --provision-with behaves differently with up and provision commands.
I have an use case in which provisioning has to be done in two steps: Software installed requires user action at some point. I could do:
vagrant up --no-provision
vagrant provision --provision-with a, b
vagrant ssh
# perform authentication and exit
vagrant provision --provision-with c, d, e
but it will be more elegant to do:
vagrant up --provision-with a, b
vagrant ssh
# perform authentication and exit
vagrant provision --provision-with c, d, e
I ran into this issue as well, found this github issue while googling.
Possible fix: vagrant up --provision-with ought to be vagrant up --provision-with-type(s) if there's no functionality change.
:+1: +1 for the --provision-with on vagrant up. I also have a use case where I need to do :
vagrant up --no-provision
vagrant provision --provision-with a,b
vagrant provision --provision-with c,d
Now, in part this is my fault. However, I'm re-using some Puppet modules that I don't fully understand and it's in setting up a rather complex multi-node environment. The workflow I'm using is repeatable and works.
I would put my support behind any additional fine-grained control of provisioners :smile:
I ran into this issue as well, found this github issue while googling. :cry:
Ugh, me too. :disappointed:
@gaberger it's a bug, as the indended behaviour is to work on the 'up' command:
https://github.com/mitchellh/vagrant/pull/4700#issue-46697567
--provision-with flag on up, reload, etc. works with names as well as IDs
Fixed via #5981
I'm running 2.01 and still having this issue, I can specify shell but not same s. Same deal with up and provision. Did this get reverted or something?
@dgonano - no, this should still work. If you're experiencing a problem please open an issue and we'll take a look. Thanks!
@briancain Super busy but will try to get a log for you. How do I get verbose output?
edit:
sorry, like this i assume: VAGRANT_LOG=info vagrant up ...
Will try get something up for you guys
You could also run vagrant up --debug > some-log.txt and then upload the .txt to a gist and link it here.
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
:+1: +1 for the
--provision-withonvagrant up. I also have a use case where I need to do :Now, in part this is my fault. However, I'm re-using some Puppet modules that I don't fully understand and it's in setting up a rather complex multi-node environment. The workflow I'm using is repeatable and works.
I would put my support behind any additional fine-grained control of provisioners :smile: