Skip to content

Instantly share code, notes, and snippets.

@madsmtm
Last active June 27, 2018 08:28
Show Gist options
  • Save madsmtm/736d09eb5fc5087294fa569e0dc70f3d to your computer and use it in GitHub Desktop.
Save madsmtm/736d09eb5fc5087294fa569e0dc70f3d to your computer and use it in GitHub Desktop.
Conditional Vagrant Provisioner
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# When you type 'up' the first time, it's always updated
config.vm.provision 'update', type: 'shell', inline: "apt-get update;apt-get -yq upgrade"
# When you provision the machine, you're asked whether you want to update it
if ARGV.include?('up') or ARGV.include?('reload') or ARGV.include?('resume') and ARGV.include?('--provision') or ARGV.include?('provision')
print 'Do you want to update the server (y/n)? '
if STDIN.gets.chomp.downcase != 'y'
config.vm.provision 'update', type: 'shell', inline: ''
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment