From 95ad9e457388472e2c7f8175e0bf5444ba02a76a Mon Sep 17 00:00:00 2001 From: Antony Messerli Date: Fri, 22 Mar 2013 10:28:51 -0500 Subject: [PATCH 1/2] Adding support for the Rackspace Open Cloud --- README.md | 24 +++++++++++++++++++++--- Vagrantfile | 21 +++++++++++++++++---- puppet/modules/docker/manifests/init.pp | 24 ++++++++++++++++-------- 3 files changed, 54 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 68473ce383..60ee1c56e4 100644 --- a/README.md +++ b/README.md @@ -94,10 +94,11 @@ Docker probably works on other distributions featuring a recent kernel, the AUFS Installing with Vagrant ----------------------- -Currently, Docker can be installed with Vagrant both on your localhost -with VirtualBox as well as on Amazon EC2. Vagrant 1.1 is required for -EC2, but deploying is as simple as: +Currently, Docker can be installed with Vagrant on your localhost with VirtualBox, +Amazon EC2, and Rackspace Cloud Servers. Vagrant 1.1 is required for EC2 and +Rackspace Cloud, but deploying is as simple as: +Amazon EC2: ```bash $ export AWS_ACCESS_KEY_ID=xxx \ AWS_SECRET_ACCESS_KEY=xxx \ @@ -114,6 +115,23 @@ The environment variables are: * `AWS_KEYPAIR_NAME` - The name of the keypair used for this EC2 instance * `AWS_SSH_PRIVKEY` - The path to the private key for the named keypair +Rackspace Cloud Servers: +```bash +$ export RS_USERNAME=xxx \ + RS_API_KEY=xxx \ + RS_PUBLIC_KEY=xxx \ + RS_PRIVATE_KEY=xxx +$ vagrant plugin install vagrant-rackspace +$ vagrant up --provider=rackspace +``` + +The environment variables are: + +* `RS_USERNAME` - The user name used to make requests to Rackspace Cloud +* `RS_API_KEY` - The secret key to make Rackspace Cloud API requests +* `RS_PUBLIC_KEY` - The location on disk to your public key that will be injected into the instance. +* `RS_PRIVATE_KEY` - The private key that matches the public key being injected. + For VirtualBox, you can simply ignore setting any of the environment variables and omit the `provider` flag. VirtualBox is still supported with Vagrant <= 1.1: diff --git a/Vagrantfile b/Vagrantfile index e847659848..e58d83ee12 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -31,6 +31,9 @@ Vagrant.configure("1") do |config| # computers to access the VM, whereas host only networking does not. # config.vm.forward_port 80, 8080 + # Ensure puppet is installed on the instance + config.vm.provision :shell, :inline => "apt-get -qq update; apt-get install -y puppet" + # Share an additional folder to the guest VM. The first argument is # an identifier, the second is the path on the guest to mount the # folder, and the third is the path on the host to the actual folder. @@ -103,17 +106,27 @@ Vagrant.configure("2") do |config| config.vm.provider :aws do |aws| config.vm.box = "dummy" config.vm.box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box" - aws.access_key_id = ENV["AWS_ACCESS_KEY_ID"] + aws.access_key_id = ENV["AWS_ACCESS_KEY_ID"] aws.secret_access_key = ENV["AWS_SECRET_ACCESS_KEY"] 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-1c1e8075" + aws.ssh_username = "vagrant" 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" + config.ssh.private_key_path = ENV["RS_PRIVATE_KEY"] + rs.username = ENV["RS_USERNAME"] + rs.api_key = ENV["RS_API_KEY"] + rs.public_key_path = ENV["RS_PUBLIC_KEY"] + 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" - end + end end diff --git a/puppet/modules/docker/manifests/init.pp b/puppet/modules/docker/manifests/init.pp index 1862c524b8..ab14ef2c4c 100644 --- a/puppet/modules/docker/manifests/init.pp +++ b/puppet/modules/docker/manifests/init.pp @@ -25,6 +25,9 @@ class virtualbox { class ec2 { } +class rax { +} + class docker { # update this with latest docker binary distro @@ -42,13 +45,17 @@ class docker { notify { "docker_url = $docker_url": withpath => true } - $ec2_version = file("/etc/ec2_version", "/dev/null") - if ($ec2_version) { - include ec2 - } else { - # virtualbox is the vagrant default, so it should be safe to assume - include virtualbox - } + $ec2_version = file("/etc/ec2_version", "/dev/null") + $rax_version = inline_template("<%= %x{/usr/bin/xenstore-read vm-data/provider_data/provider} %>") + + if ($ec2_version) { + include ec2 + } elsif ($rax_version) { + include rax + } else { + # virtualbox is the vagrant default, so it should be safe to assume + include virtualbox + } user { "vagrant": ensure => present, @@ -84,6 +91,7 @@ class docker { } file { "/home/vagrant": + ensure => directory, mode => 644, require => User["vagrant"], } @@ -91,7 +99,7 @@ class docker { file { "/home/vagrant/.profile": mode => 644, owner => "vagrant", - group => "ubuntu", + group => "vagrant", content => template("docker/profile"), require => File["/home/vagrant"], } From 94b9ca988de6970406789759b5f75fee19fd5dbb Mon Sep 17 00:00:00 2001 From: Charles Hooper Date: Sun, 24 Mar 2013 10:49:16 +0000 Subject: [PATCH 2/2] Fix missing group "Vagrant" error --- puppet/modules/docker/manifests/init.pp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/puppet/modules/docker/manifests/init.pp b/puppet/modules/docker/manifests/init.pp index 13de621749..b6b8aecd1c 100644 --- a/puppet/modules/docker/manifests/init.pp +++ b/puppet/modules/docker/manifests/init.pp @@ -62,8 +62,30 @@ class docker { 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,