فهرست منبع

Merge remote-tracking branch 'amesserl/raxcloud-support'

Conflicts:
	Vagrantfile
Charles Hooper 12 سال پیش
والد
کامیت
bea7894166
3فایلهای تغییر یافته به همراه50 افزوده شده و 14 حذف شده
  1. 21 3
      README.md
  2. 13 3
      Vagrantfile
  3. 16 8
      puppet/modules/docker/manifests/init.pp

+ 21 - 3
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:

+ 13 - 3
Vagrantfile

@@ -31,12 +31,12 @@ def v10(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.
-  if not File.exist? File.expand_path '~/docker'
-    Dir.mkdir(File.expand_path '~/docker')
-  end
   config.vm.share_folder "v-data", "~/docker", "~/docker"
 
   # Enable provisioning with Puppet stand alone.  Puppet manifests
@@ -123,6 +123,16 @@ end
     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"

+ 16 - 8
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"],
     }