Browse code

Fix issue where Vagrant AWS deploys outside of my dev account would fail

Charles Hooper authored on 2013/03/27 06:21:54
Showing 2 changed files
... ...
@@ -25,7 +25,7 @@ def v10(config)
25 25
   # Assign this VM to a bridged network, allowing you to connect directly to a
26 26
   # network using the host's network device. This makes the VM appear as another
27 27
   # physical device on your network.
28
-  # config.vm.network :bridged
28
+  #config.vm.network :bridged
29 29
 
30 30
   # Forward a port from the guest to the host, which allows for outside
31 31
   # computers to access the VM, whereas host only networking does not.
... ...
@@ -119,7 +119,7 @@ end
119 119
     aws.keypair_name = ENV["AWS_KEYPAIR_NAME"]
120 120
     aws.ssh_private_key_path = ENV["AWS_SSH_PRIVKEY"]
121 121
     aws.region = "us-east-1"
122
-    aws.ami = "ami-4a7de623"
122
+    aws.ami = "ami-4e75ee27"
123 123
     aws.ssh_username = "ubuntu"
124 124
     aws.instance_type = "t1.micro"
125 125
   end
... ...
@@ -1,12 +1,26 @@
1 1
 class virtualbox {
2 2
 	Package { ensure => "installed" }
3 3
 
4
+	user { "vagrant":
5
+		name => "vagrant",
6
+		ensure => present,
7
+		comment => "Vagrant User",
8
+		shell => "/bin/bash",
9
+		home => "/home/vagrant",
10
+	}
11
+
12
+	file { "/home/vagrant":
13
+		mode => 644,
14
+		require => User["vagrant"],
15
+	}
16
+
4 17
 	# remove some files from the base vagrant image because they're old
5 18
 	file { "/home/vagrant/docker-master":
6 19
 		ensure => absent,
7 20
 		recurse => true,
8 21
 		force => true,
9 22
 		purge => true,
23
+		require => File["/home/vagrant"],
10 24
 	}
11 25
 	file { "/usr/local/bin/dockerd":
12 26
 		ensure => absent,
... ...
@@ -23,10 +37,21 @@ class virtualbox {
23 23
 }
24 24
 
25 25
 class ec2 {
26
+	user { "vagrant":
27
+		name => "ubuntu",
28
+		ensure => present,
29
+		comment => "Vagrant User",
30
+		shell => "/bin/bash",
31
+		home => "/home/ubuntu",
32
+	}
33
+	file { "/home/vagrant":
34
+		ensure => link,
35
+		target => "/home/ubuntu",
36
+		require => User["vagrant"],
37
+	}
26 38
 }
27 39
 
28 40
 class docker {
29
-
30 41
     # update this with latest docker binary distro
31 42
     $docker_url = "http://get.docker.io/builds/$kernel/$hardwaremodel/docker-master.tgz"
32 43
     # update this with latest go binary distry
... ...
@@ -44,19 +69,14 @@ class docker {
44 44
 
45 45
 	$ec2_version = file("/etc/ec2_version", "/dev/null")
46 46
 	if ($ec2_version) {
47
+		$vagrant_user = "ubuntu"
47 48
 		include ec2
48 49
 	} else {
50
+		$vagrant_user = "vagrant"
49 51
 		# virtualbox is the vagrant default, so it should be safe to assume
50 52
 		include virtualbox
51 53
 	}
52 54
 
53
-    user { "vagrant":
54
-        ensure => present,
55
-        comment => "Vagrant User",
56
-        shell => "/bin/bash",
57
-        home => "/home/vagrant",
58
-    }
59
-
60 55
 	file { "/usr/local/bin":
61 56
 		ensure => directory,
62 57
 		owner => root,
... ...
@@ -83,14 +103,10 @@ class docker {
83 83
         require => Exec["copy-docker-bin"],
84 84
     }
85 85
 
86
-    file { "/home/vagrant":
87
-        mode => 644,
88
-        require => User["vagrant"],
89
-    }
90 86
 
91 87
     file { "/home/vagrant/.profile":
92 88
         mode => 644,
93
-        owner => "vagrant",
89
+        owner => $vagrant_user,
94 90
         group => "ubuntu",
95 91
         content => template("docker/profile"),
96 92
         require => File["/home/vagrant"],