Merge pull request #192 from chooper/vagrant11-providers

Fix AWS provisioning with Vagrant
This commit is contained in:
Charles Hooper 2013-03-26 20:18:09 -07:00
commit 00b81936aa
2 changed files with 49 additions and 41 deletions

8
Vagrantfile vendored
View file

@ -25,7 +25,7 @@ def v10(config)
# Assign this VM to a bridged network, allowing you to connect directly to a
# network using the host's network device. This makes the VM appear as another
# physical device on your network.
# config.vm.network :bridged
#config.vm.network :bridged
# Forward a port from the guest to the host, which allows for outside
# computers to access the VM, whereas host only networking does not.
@ -119,10 +119,11 @@ end
aws.keypair_name = ENV["AWS_KEYPAIR_NAME"]
aws.ssh_private_key_path = ENV["AWS_SSH_PRIVKEY"]
aws.region = "us-east-1"
aws.ami = "ami-1c1e8075"
aws.ssh_username = "vagrant"
aws.ami = "ami-ae9806c7"
aws.ssh_username = "ubuntu"
aws.instance_type = "t1.micro"
end
config.vm.provider :rackspace do |rs|
config.vm.box = "dummy"
config.vm.box_url = "https://github.com/mitchellh/vagrant-rackspace/raw/master/dummy.box"
@ -133,6 +134,7 @@ end
rs.flavor = /512MB/
rs.image = /Ubuntu/
end
config.vm.provider :virtualbox do |vb|
config.vm.box = "quantal64_3.5.0-25"
config.vm.box_url = "http://get.docker.io/vbox/ubuntu/12.10/quantal64_3.5.0-25.box"

View file

@ -1,12 +1,26 @@
class virtualbox {
Package { ensure => "installed" }
user { "vagrant":
name => "vagrant",
ensure => present,
comment => "Vagrant User",
shell => "/bin/bash",
home => "/home/vagrant",
}
file { "/home/vagrant":
mode => 644,
require => User["vagrant"],
}
# remove some files from the base vagrant image because they're old
file { "/home/vagrant/docker-master":
ensure => absent,
recurse => true,
force => true,
purge => true,
require => File["/home/vagrant"],
}
file { "/usr/local/bin/dockerd":
ensure => absent,
@ -23,9 +37,33 @@ class virtualbox {
}
class ec2 {
user { "vagrant":
name => "ubuntu",
ensure => present,
comment => "Vagrant User",
shell => "/bin/bash",
home => "/home/ubuntu",
}
file { "/home/vagrant":
ensure => link,
target => "/home/ubuntu",
require => User["vagrant"],
}
}
class rax {
user { "vagrant":
name => "ubuntu",
ensure => present,
comment => "Vagrant User",
shell => "/bin/bash",
home => "/home/ubuntu",
}
file { "/home/vagrant":
ensure => link,
target => "/home/ubuntu",
require => User["vagrant"],
}
}
class docker {
@ -49,43 +87,17 @@ class docker {
$rax_version = inline_template("<%= %x{/usr/bin/xenstore-read vm-data/provider_data/provider} %>")
if ($ec2_version) {
include ec2
$vagrant_user = "ubuntu"
include ec2
} elsif ($rax_version) {
$vagrant_user = "vagrant"
include rax
} else {
# virtualbox is the vagrant default, so it should be safe to assume
$vagrant_user = "vagrant"
include virtualbox
}
user { "vagrant":
ensure => present,
comment => "Vagrant User",
shell => "/bin/bash",
home => "/home/vagrant",
groups => [
"sudo",
"vagrant",
"ubuntu",
],
require => [
Group["sudo"],
Group["vagrant"],
Group["ubuntu"],
],
}
group { "ubuntu":
ensure => present,
}
group { "vagrant":
ensure => present,
}
group { "sudo":
ensure => present,
}
file { "/usr/local/bin":
ensure => directory,
owner => root,
@ -112,16 +124,10 @@ class docker {
require => Exec["copy-docker-bin"],
}
file { "/home/vagrant":
ensure => directory,
mode => 644,
require => User["vagrant"],
}
file { "/home/vagrant/.profile":
mode => 644,
owner => "vagrant",
group => "vagrant",
owner => $vagrant_user,
group => "ubuntu",
content => template("docker/profile"),
require => File["/home/vagrant"],
}