As far as I can find out I cannot control the order provisioning is done. In the following example I want my shell script run before puppet is done, however, Vagrant decides it's better to Puppet first:
puppet_master = 'puppetmaster'
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Configure Shell behaviour.
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
config.ssh.keep_alive = true
# The following is done on all Vagrant machines.
config.vm.define 'puppetagent' do |vmconfig|
vmconfig.vm.box = 'debian-73-64'
vmconfig.vm.box_url = 'http://puppet-vagrant-boxes.puppetlabs.com/debian-73-x64-virtualbox-puppet.box'
vmconfig.vm.network 'private_network', ip: '192.168.33.3'
vmconfig.vm.network 'forwarded_port', guest: 22, host: 2203
#vmconfig.vm.hostname = 'puppetagent.ḣealthcare.nedap.local'
vmconfig.vm.provider 'virtualbox' do |vb|
# Use VBoxManage to customize the VM
vb.customize ['modifyvm', :id, '--name', 'puppetagent.example.local' ]
vb.customize ['modifyvm', :id, '--cpus', 2 ]
vb.customize ['modifyvm', :id, '--memory', 512 ]
end # provider virtualbox
vmconfig.vm.provision :shell,
:path => 'install_puppet_agent.sh',
:args => sprintf('-r %s -p %s -h %s', 'wheezy', '3.6.2-1puppetlabs1', '1.3.4-1puppetlabs1'),
:upload_path => '/var/tmp/install_puppet_agent.sh'
config.vm.provision :puppet_server do |puppet|
puppet.puppet_server = puppet_master
puppet.options = '--verbose'
end # vmconfig.vm.provision
end # config.vm.define
end # Vagrant.configure
I suggest to add an option to select the order, or just respect the order provision stanza's are written in the Vagrantfile.
+1
Also a way to only run certain provisioners. Right now I have environment variables set up to control which provisioners run.
@aswen Provisioning scripts are executed in the order in which they are specified in the Vagrantfile. Are you seeing different behavior? I believe you need to change the config.vm.provision block to vmconfig.vm.provision so that the order is respected (config is global in this context, vmconfig is the local context).
@sethvargo Thanx Seth, I worked arround this by stuffing the puppet execution into the shell script but I will try your suggestion. It sounds as a good origin of the behaviour I had. (I was indeed having the Puppet provisioner executing before the shell script while I wanted another version of Puppet to run that.).
@aswen okay, please report back if you have any issues and/or if it's fixed! :smile:
@sethvargo will do off course.
@sethvargo Hi Seth, the solution suggested works! Thanks a lot.
@sethvargo thank you for clarifying. I also had the mistake of not using the right scope. The order worked well once I fixed it.
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
@aswen Provisioning scripts are executed in the order in which they are specified in the
Vagrantfile. Are you seeing different behavior? I believe you need to change theconfig.vm.provisionblock tovmconfig.vm.provisionso that the order is respected (configis global in this context,vmconfigis the local context).