Browse code

Adding support for the Rackspace Open Cloud

Antony Messerli authored on 2013/03/23 00:28:51
Showing 3 changed files
... ...
@@ -94,10 +94,11 @@ Docker probably works on other distributions featuring a recent kernel, the AUFS
94 94
 Installing with Vagrant
95 95
 -----------------------
96 96
 
97
-Currently, Docker can be installed with Vagrant both on your localhost
98
-with VirtualBox as well as on Amazon EC2. Vagrant 1.1 is required for
99
-EC2, but deploying is as simple as:
97
+Currently, Docker can be installed with Vagrant on your localhost with VirtualBox, 
98
+Amazon EC2, and Rackspace Cloud Servers. Vagrant 1.1 is required for EC2 and 
99
+Rackspace Cloud, but deploying is as simple as:
100 100
 
101
+Amazon EC2:
101 102
 ```bash
102 103
 $ export AWS_ACCESS_KEY_ID=xxx \
103 104
 	AWS_SECRET_ACCESS_KEY=xxx \
... ...
@@ -114,6 +115,23 @@ The environment variables are:
114 114
 * `AWS_KEYPAIR_NAME` - The name of the keypair used for this EC2 instance
115 115
 * `AWS_SSH_PRIVKEY` - The path to the private key for the named keypair
116 116
 
117
+Rackspace Cloud Servers:
118
+```bash
119
+$ export RS_USERNAME=xxx \
120
+        RS_API_KEY=xxx \
121
+        RS_PUBLIC_KEY=xxx \
122
+        RS_PRIVATE_KEY=xxx
123
+$ vagrant plugin install vagrant-rackspace
124
+$ vagrant up --provider=rackspace
125
+```
126
+
127
+The environment variables are:
128
+
129
+* `RS_USERNAME` - The user name used to make requests to Rackspace Cloud
130
+* `RS_API_KEY` - The secret key to make Rackspace Cloud API requests
131
+* `RS_PUBLIC_KEY` - The location on disk to your public key that will be injected into the instance.
132
+* `RS_PRIVATE_KEY` - The private key that matches the public key being injected.
133
+
117 134
 For VirtualBox, you can simply ignore setting any of the environment
118 135
 variables and omit the `provider` flag. VirtualBox is still supported with
119 136
 Vagrant <= 1.1:
... ...
@@ -31,6 +31,9 @@ Vagrant.configure("1") do |config|
31 31
   # computers to access the VM, whereas host only networking does not.
32 32
   # config.vm.forward_port 80, 8080
33 33
 
34
+  # Ensure puppet is installed on the instance
35
+  config.vm.provision :shell, :inline => "apt-get -qq update; apt-get install -y puppet"
36
+
34 37
   # Share an additional folder to the guest VM. The first argument is
35 38
   # an identifier, the second is the path on the guest to mount the
36 39
   # folder, and the third is the path on the host to the actual folder.
... ...
@@ -103,17 +106,27 @@ Vagrant.configure("2") do |config|
103 103
   config.vm.provider :aws do |aws|
104 104
 		config.vm.box = "dummy"
105 105
 		config.vm.box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box"
106
-    aws.access_key_id = ENV["AWS_ACCESS_KEY_ID"]
106
+                aws.access_key_id = ENV["AWS_ACCESS_KEY_ID"]
107 107
 		aws.secret_access_key = ENV["AWS_SECRET_ACCESS_KEY"]
108 108
 		aws.keypair_name = ENV["AWS_KEYPAIR_NAME"]
109 109
 		aws.ssh_private_key_path = ENV["AWS_SSH_PRIVKEY"]
110 110
 		aws.region = "us-east-1"
111
-    aws.ami = "ami-1c1e8075"
112
-    aws.ssh_username = "vagrant"
111
+                aws.ami = "ami-1c1e8075"
112
+                aws.ssh_username = "vagrant"
113 113
 		aws.instance_type = "t1.micro"
114 114
   end
115
+  config.vm.provider :rackspace do |rs|
116
+                config.vm.box = "dummy"
117
+                config.vm.box_url = "https://github.com/mitchellh/vagrant-rackspace/raw/master/dummy.box"
118
+                config.ssh.private_key_path = ENV["RS_PRIVATE_KEY"]
119
+                rs.username = ENV["RS_USERNAME"]
120
+                rs.api_key  = ENV["RS_API_KEY"]
121
+                rs.public_key_path = ENV["RS_PUBLIC_KEY"] 
122
+                rs.flavor   = /512MB/
123
+                rs.image    = /Ubuntu/
124
+  end     
115 125
   config.vm.provider :virtualbox do |vb|
116 126
 		config.vm.box = "quantal64_3.5.0-25"
117 127
 		config.vm.box_url = "http://get.docker.io/vbox/ubuntu/12.10/quantal64_3.5.0-25.box"
118
-	end
128
+  end
119 129
 end
... ...
@@ -25,6 +25,9 @@ class virtualbox {
25 25
 class ec2 {
26 26
 }
27 27
 
28
+class rax {
29
+}
30
+
28 31
 class docker {
29 32
 
30 33
     # update this with latest docker binary distro
... ...
@@ -42,13 +45,17 @@ class docker {
42 42
 
43 43
     notify { "docker_url = $docker_url": withpath => true }
44 44
 
45
-	$ec2_version = file("/etc/ec2_version", "/dev/null")
46
-	if ($ec2_version) {
47
-		include ec2
48
-	} else {
49
-		# virtualbox is the vagrant default, so it should be safe to assume
50
-		include virtualbox
51
-	}
45
+    $ec2_version = file("/etc/ec2_version", "/dev/null")
46
+    $rax_version = inline_template("<%= %x{/usr/bin/xenstore-read vm-data/provider_data/provider} %>")
47
+
48
+    if ($ec2_version) {
49
+	include ec2
50
+    } elsif ($rax_version) {
51
+        include rax
52
+    } else {
53
+    # virtualbox is the vagrant default, so it should be safe to assume
54
+        include virtualbox
55
+    }
52 56
 
53 57
     user { "vagrant":
54 58
         ensure => present,
... ...
@@ -84,6 +91,7 @@ class docker {
84 84
     }
85 85
 
86 86
     file { "/home/vagrant":
87
+        ensure => directory,
87 88
         mode => 644,
88 89
         require => User["vagrant"],
89 90
     }
... ...
@@ -91,7 +99,7 @@ class docker {
91 91
     file { "/home/vagrant/.profile":
92 92
         mode => 644,
93 93
         owner => "vagrant",
94
-        group => "ubuntu",
94
+        group => "vagrant",
95 95
         content => template("docker/profile"),
96 96
         require => File["/home/vagrant"],
97 97
     }