Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix AWS provisioning with Vagrant #192

Merged
merged 6 commits into from

4 participants

@chooper

It was pointed out to me that users on AWS accounts other than my own could not provision Docker EC2 instances using Vagrant. These commits fix this issue.

@titanous

How hard would it be to set up an AMI that has a vagrant user so that we have parity across providers? Changing #184 to support multiple home directories sucks (I just tried).

@jpetazzo

... And by the way, why do we need a custom AMI? Wouldn't be better to use a standard AMI?
(I don't know at all how the Vagrant provisioning mechanism work, but I secretly hope that it could let us provide some user data, which in turn, could be used by cloud-init to do any kind of extra setup?)

@titanous

@jpetazzo I think we just need it for puppet, but we could just shift to using a plain shell script, as the provisioning is quite simple.

@titanous

@jpetazzo Vagrant uses SSH to provision via Puppet, Chef, shell scripts, or custom providers after the instance boots. It doesn't use cloud-init at all AFAIK.

@jpetazzo
@chooper

Ubuntu AMI's use cloud-init by default to install SSH keys. Currently this (and needing to install puppet) is the only reason we use a custom AMI, since it's non-trivial to replace/augment the "ubuntu" user with a "vagrant" user.

This was my "needs to ship today" fix, but yes, the overall goal would be to use one of the publicly available, standard AMIs

@titanous

Hmm, yeah, that feels like a lot of work when Vagrant is supposed to solve this by doing provisioning from a vanilla-ish AMI. I'd prefer to pick from:

  • Build custom AMIs with Docker included, don't use Vagrant.

OR

  • Shift to vanilla Ubuntu AMIs and use shell provisioning with Vagrant.
@vsekhar

Couldn't you add a user-data-script to cloud-init that installs puppet and creates a vagrant user? You could also use the cloud-config syntax to have Ubuntu manage those steps for you. It would basically replicate the steps you took to create your custom AMI every time, without needing to maintain the image.

https://help.ubuntu.com/community/CloudInit

EDIT: relevant cloud-init examples

Charles Hooper Merge remote-tracking branch 'upstream/master' into vagrant11-providers
Conflicts:
	puppet/modules/docker/manifests/init.pp
2b09032
@chooper

Looking over another pull request, it seems we've got a branch queued up that will actually install puppet prior to running the puppet provisioner. I'm going to test and merge that pull request and then follow up with this one.

@chooper

Turns out that pull request was already merged. I've tested using one of the public/standard Ubuntu AMIs successfully. The changes will be appearing here shortly.

@jpetazzo
@chooper

OK, we're off the custom AMI.

We still have some puppet "magic" that causes different home directories because the VirtualBox image we're using needs it but I've opened a separate issue (#201) for that.

@chooper chooper merged commit 00b8193 into docker:master
@aanand aanand referenced this pull request from a commit in aanand/docker
@damm damm Ensure `pwd`/dist exists always and is 777.
  Fixes #192

Signed-off-by: Scott M. Likens <scott@likens.us>
c2acceb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 26, 2013
Commits on Mar 27, 2013
  1. Merge remote-tracking branch 'upstream/master' into vagrant11-providers

    Charles Hooper authored
    Conflicts:
    	puppet/modules/docker/manifests/init.pp
  2. Remove duplicate user definition

    Charles Hooper authored
  3. Stop using custom AMI and use standard Ubuntu AMI

    Charles Hooper authored
This page is out of date. Refresh to see the latest.
Showing with 49 additions and 41 deletions.
  1. +5 −3 Vagrantfile
  2. +44 −38 puppet/modules/docker/manifests/init.pp
View
8 Vagrantfile
@@ -25,7 +25,7 @@ def v10(config)
# Assign this VM to a bridged network, allowing you to connect directly to a
# network using the host's network device. This makes the VM appear as another
# physical device on your network.
- # config.vm.network :bridged
+ #config.vm.network :bridged
# Forward a port from the guest to the host, which allows for outside
# computers to access the VM, whereas host only networking does not.
@@ -119,10 +119,11 @@ end
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-ae9806c7"
+ aws.ssh_username = "ubuntu"
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"
@@ -133,6 +134,7 @@ end
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"
View
82 puppet/modules/docker/manifests/init.pp
@@ -1,12 +1,26 @@
class virtualbox {
Package { ensure => "installed" }
+ user { "vagrant":
+ name => "vagrant",
+ ensure => present,
+ comment => "Vagrant User",
+ shell => "/bin/bash",
+ home => "/home/vagrant",
+ }
+
+ file { "/home/vagrant":
+ mode => 644,
+ require => User["vagrant"],
+ }
+
# remove some files from the base vagrant image because they're old
file { "/home/vagrant/docker-master":
ensure => absent,
recurse => true,
force => true,
purge => true,
+ require => File["/home/vagrant"],
}
file { "/usr/local/bin/dockerd":
ensure => absent,
@@ -23,9 +37,33 @@
}
class ec2 {
+ user { "vagrant":
+ name => "ubuntu",
+ ensure => present,
+ comment => "Vagrant User",
+ shell => "/bin/bash",
+ home => "/home/ubuntu",
+ }
+ file { "/home/vagrant":
+ ensure => link,
+ target => "/home/ubuntu",
+ require => User["vagrant"],
+ }
}
class rax {
+ user { "vagrant":
+ name => "ubuntu",
+ ensure => present,
+ comment => "Vagrant User",
+ shell => "/bin/bash",
+ home => "/home/ubuntu",
+ }
+ file { "/home/vagrant":
+ ensure => link,
+ target => "/home/ubuntu",
+ require => User["vagrant"],
+ }
}
class docker {
@@ -49,43 +87,17 @@
$rax_version = inline_template("<%= %x{/usr/bin/xenstore-read vm-data/provider_data/provider} %>")
if ($ec2_version) {
- include ec2
+ $vagrant_user = "ubuntu"
+ include ec2
} elsif ($rax_version) {
+ $vagrant_user = "vagrant"
include rax
} else {
# virtualbox is the vagrant default, so it should be safe to assume
+ $vagrant_user = "vagrant"
include virtualbox
}
- user { "vagrant":
- ensure => present,
- 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,
@@ -112,16 +124,10 @@
require => Exec["copy-docker-bin"],
}
- file { "/home/vagrant":
- ensure => directory,
- mode => 644,
- require => User["vagrant"],
- }
-
file { "/home/vagrant/.profile":
mode => 644,
- owner => "vagrant",
- group => "vagrant",
+ owner => $vagrant_user,
+ group => "ubuntu",
content => template("docker/profile"),
require => File["/home/vagrant"],
}
Something went wrong with that request. Please try again.