Last active
August 29, 2015 14:01
-
-
Save tareiking/b0bf8d93fdb3bdfb5911 to your computer and use it in GitHub Desktop.
Vagrantfile for vagrant-chassis-digitalocean
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
require "yaml" | |
# Load git-managed configuration | |
_config = YAML.load( | |
File.open( | |
File.join(File.dirname(__FILE__), "config.yaml"), | |
File::RDONLY | |
).read | |
) | |
# Load other configuration files | |
config_files = [ "config.local.yaml", "content/config.yaml", "content/config.local.yaml" ] | |
config_files.each do |filename| | |
begin | |
confvars = YAML.load( | |
File.open( | |
File.join(File.dirname(__FILE__), filename), | |
File::RDONLY | |
).read | |
) | |
_config.merge!(confvars) if confvars.is_a?(Hash) | |
rescue Errno::ENOENT | |
# No overriden YAML found -- that's OK; just use the defaults. | |
end | |
end | |
CONF = _config | |
# Add extra extension modules | |
base_path = Pathname.new( File.dirname( __FILE__ ) ) | |
module_paths = [ base_path.to_s + "/puppet/modules" ] | |
module_paths.concat Dir.glob( base_path.to_s + "/extensions/*/modules" ) | |
# Convert to relative from Vagrantfile | |
module_paths.map! do |path| | |
pathname = Pathname.new(path) | |
pathname.relative_path_from(base_path).to_s | |
end | |
Vagrant.configure("2") do |config| | |
# Make sure Puppet is installed | |
config.vm.provision :shell, | |
inline: "sudo apt-get update -y && sudo apt-get install puppet -y" | |
config.vm.provision :shell, | |
inline: "sudo chmod -R a+rX /vagrant" | |
# Store the current version of Vagrant for use in conditionals when dealing | |
# with possible backward compatible issues. | |
vagrant_version = Vagrant::VERSION.sub(/^v/, '') | |
# We <3 Ubuntu LTS | |
config.vm.box = "precise32" | |
# Get it. Got it? Good. | |
config.vm.box_url = "http://files.vagrantup.com/precise32.box" | |
# Having access would be nice. | |
config.vm.network :private_network, ip: CONF['ip'] | |
config.vm.hostname = CONF['hosts'][0] | |
# You can configure an alias to handle other domains for testing. | |
config.hostsupdater.aliases = CONF['hosts'][1..-1] | |
# Before any other provisioning, ensure that we're up-to-date | |
config.vm.provision :shell, :path => "puppet/preprovision.sh" | |
config.vm.provider :chassis_digitalocean do |provider, override| | |
override.ssh.private_key_path = '~/.ssh/id_rsa' | |
override.vm.box_url = 'https://github.com/smdahlen/vagrant-digitalocean/raw/master/box/chassis_digitalocean.box' | |
provider.client_id = CONF['digitalocean']['client_id'] | |
provider.api_key = CONF['digitalocean']['api_key'] | |
end | |
config.vm.provider :chassis_digitalocean do |provider| | |
provider.image = CONF['digitalocean']['image'] | |
provider.region = CONF['digitalocean']['region'] | |
provider.size = CONF['digitalocean']['size'] | |
end | |
# Provision our setup with Puppet | |
config.vm.provision :puppet do |puppet| | |
puppet.manifests_path = "puppet/manifests" | |
puppet.manifest_file = "development.pp" | |
# Broken due to https://github.com/mitchellh/vagrant/issues/2902 | |
## puppet.module_path = module_paths | |
# Workaround: | |
module_paths.map! { |rel_path| "/vagrant/" + rel_path } | |
puppet.options = "--modulepath " + module_paths.join( ':' ).inspect | |
puppet.options = puppet.options + " --verbose --debug" | |
end | |
# Ensure that WordPress can install/update plugins, themes and core | |
if vagrant_version >= "1.3.0" | |
config.vm.synced_folder ".", "/vagrant", :mount_options => [ "dmode=777,fmode=777" ], | |
rsync__exclude: ".git/" | |
else | |
config.vm.synced_folder ".", "/vagrant", :extra => "dmode=777,fmode=777", | |
rsync__exclude: ".git/" | |
end | |
# Success? | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment