Browse code

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

Conflicts:
Vagrantfile

Charles Hooper authored on 2013/03/24 19:16:50
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,12 +31,12 @@ def v10(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.
37
-  if not File.exist? File.expand_path '~/docker'
38
-    Dir.mkdir(File.expand_path '~/docker')
39
-  end
40 40
   config.vm.share_folder "v-data", "~/docker", "~/docker"
41 41
 
42 42
   # Enable provisioning with Puppet stand alone.  Puppet manifests
... ...
@@ -123,6 +123,16 @@ end
123 123
     aws.ssh_username = "vagrant"
124 124
     aws.instance_type = "t1.micro"
125 125
   end
126
+  config.vm.provider :rackspace do |rs|
127
+    config.vm.box = "dummy"
128
+    config.vm.box_url = "https://github.com/mitchellh/vagrant-rackspace/raw/master/dummy.box"
129
+    config.ssh.private_key_path = ENV["RS_PRIVATE_KEY"]
130
+    rs.username = ENV["RS_USERNAME"]
131
+    rs.api_key  = ENV["RS_API_KEY"]
132
+    rs.public_key_path = ENV["RS_PUBLIC_KEY"] 
133
+    rs.flavor   = /512MB/
134
+    rs.image    = /Ubuntu/
135
+  end   
126 136
   config.vm.provider :virtualbox do |vb|
127 137
     config.vm.box = "quantal64_3.5.0-25"
128 138
     config.vm.box_url = "http://get.docker.io/vbox/ubuntu/12.10/quantal64_3.5.0-25.box"
... ...
@@ -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
     }