* Packaging: simplify Vagrantfile
| ... | ... |
@@ -1,55 +1,27 @@ |
| 1 | 1 |
# -*- mode: ruby -*- |
| 2 | 2 |
# vi: set ft=ruby : |
| 3 | 3 |
|
| 4 |
-def v10(config) |
|
| 5 |
- config.vm.box = 'precise64' |
|
| 6 |
- config.vm.box_url = 'http://files.vagrantup.com/precise64.box' |
|
| 7 |
- |
|
| 8 |
- # Install ubuntu packaging dependencies and create ubuntu packages |
|
| 9 |
- config.vm.provision :shell, :inline => "echo 'deb http://ppa.launchpad.net/dotcloud/lxc-docker/ubuntu precise main' >>/etc/apt/sources.list" |
|
| 10 |
- config.vm.provision :shell, :inline => 'export DEBIAN_FRONTEND=noninteractive; apt-get -qq update; apt-get install -qq -y --force-yes lxc-docker' |
|
| 11 |
-end |
|
| 12 |
- |
|
| 13 |
-Vagrant::VERSION < "1.1.0" and Vagrant::Config.run do |config| |
|
| 14 |
- v10(config) |
|
| 15 |
-end |
|
| 16 |
- |
|
| 17 |
-Vagrant::VERSION >= "1.1.0" and Vagrant.configure("1") do |config|
|
|
| 18 |
- v10(config) |
|
| 19 |
-end |
|
| 20 |
- |
|
| 21 |
-Vagrant::VERSION >= "1.1.0" and Vagrant.configure("2") do |config|
|
|
| 22 |
- config.vm.provider :aws do |aws| |
|
| 23 |
- config.vm.box = "dummy" |
|
| 24 |
- config.vm.box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box" |
|
| 25 |
- aws.access_key_id = ENV["AWS_ACCESS_KEY_ID"] |
|
| 26 |
- aws.secret_access_key = ENV["AWS_SECRET_ACCESS_KEY"] |
|
| 27 |
- aws.keypair_name = ENV["AWS_KEYPAIR_NAME"] |
|
| 28 |
- aws.ssh_private_key_path = ENV["AWS_SSH_PRIVKEY"] |
|
| 29 |
- aws.region = "us-east-1" |
|
| 30 |
- aws.ami = "ami-d0f89fb9" |
|
| 31 |
- aws.ssh_username = "ubuntu" |
|
| 32 |
- aws.instance_type = "t1.micro" |
|
| 33 |
- end |
|
| 34 |
- |
|
| 35 |
- config.vm.provider :rackspace do |rs| |
|
| 36 |
- config.vm.box = "dummy" |
|
| 37 |
- config.vm.box_url = "https://github.com/mitchellh/vagrant-rackspace/raw/master/dummy.box" |
|
| 38 |
- config.ssh.private_key_path = ENV["RS_PRIVATE_KEY"] |
|
| 39 |
- rs.username = ENV["RS_USERNAME"] |
|
| 40 |
- rs.api_key = ENV["RS_API_KEY"] |
|
| 41 |
- rs.public_key_path = ENV["RS_PUBLIC_KEY"] |
|
| 42 |
- rs.flavor = /512MB/ |
|
| 43 |
- rs.image = /Ubuntu/ |
|
| 44 |
- end |
|
| 45 |
- |
|
| 46 |
- config.vm.provider :virtualbox do |vb| |
|
| 47 |
- config.vm.box = 'precise64' |
|
| 48 |
- config.vm.box_url = 'http://files.vagrantup.com/precise64.box' |
|
| 4 |
+BOX_NAME = "ubuntu" |
|
| 5 |
+BOX_URI = "http://files.vagrantup.com/precise64.box" |
|
| 6 |
+PPA_KEY = "E61D797F63561DC6" |
|
| 7 |
+ |
|
| 8 |
+Vagrant::Config.run do |config| |
|
| 9 |
+ # Setup virtual machine box. This VM configuration code is always executed. |
|
| 10 |
+ config.vm.box = BOX_NAME |
|
| 11 |
+ config.vm.box_url = BOX_URI |
|
| 12 |
+ # Add docker PPA key to the local repository and install docker |
|
| 13 |
+ pkg_cmd = "apt-key adv --keyserver keyserver.ubuntu.com --recv-keys #{PPA_KEY}; "
|
|
| 14 |
+ pkg_cmd << "echo 'deb http://ppa.launchpad.net/dotcloud/lxc-docker/ubuntu precise main' >>/etc/apt/sources.list; " |
|
| 15 |
+ pkg_cmd << "apt-get update -qq; apt-get install -q -y lxc-docker" |
|
| 16 |
+ if ARGV.include?("--provider=aws".downcase)
|
|
| 17 |
+ # Add AUFS dependency to amazon's VM |
|
| 18 |
+ pkg_cmd << "; apt-get install linux-image-extra-3.2.0-40-virtual" |
|
| 49 | 19 |
end |
| 20 |
+ config.vm.provision :shell, :inline => pkg_cmd |
|
| 50 | 21 |
end |
| 51 | 22 |
|
| 52 |
-Vagrant::VERSION >= "1.2.0" and Vagrant.configure("2") do |config|
|
|
| 23 |
+# Providers were added on Vagrant >= 1.1.0 |
|
| 24 |
+Vagrant::VERSION >= "1.1.0" and Vagrant.configure("2") do |config|
|
|
| 53 | 25 |
config.vm.provider :aws do |aws, override| |
| 54 | 26 |
config.vm.box = "dummy" |
| 55 | 27 |
config.vm.box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box" |
| ... | ... |
@@ -75,8 +47,7 @@ Vagrant::VERSION >= "1.2.0" and Vagrant.configure("2") do |config|
|
| 75 | 75 |
end |
| 76 | 76 |
|
| 77 | 77 |
config.vm.provider :virtualbox do |vb| |
| 78 |
- config.vm.box = 'precise64' |
|
| 79 |
- config.vm.box_url = 'http://files.vagrantup.com/precise64.box' |
|
| 78 |
+ config.vm.box = BOX_NAME |
|
| 79 |
+ config.vm.box_url = BOX_URI |
|
| 80 | 80 |
end |
| 81 |
- |
|
| 82 | 81 |
end |
| 83 | 82 |
deleted file mode 100644 |
| ... | ... |
@@ -1,17 +0,0 @@ |
| 1 |
-node default {
|
|
| 2 |
- exec {
|
|
| 3 |
- "apt_update" : |
|
| 4 |
- command => "/usr/bin/apt-get update" |
|
| 5 |
- } |
|
| 6 |
- |
|
| 7 |
- Package {
|
|
| 8 |
- require => Exec['apt_update'] |
|
| 9 |
- } |
|
| 10 |
- |
|
| 11 |
- group { "puppet":
|
|
| 12 |
- ensure => "present" |
|
| 13 |
- } |
|
| 14 |
- |
|
| 15 |
- include "docker" |
|
| 16 |
- |
|
| 17 |
-} |
| 18 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,99 +0,0 @@ |
| 1 |
-class virtualbox {
|
|
| 2 |
- Package { ensure => "installed" }
|
|
| 3 |
- |
|
| 4 |
- # remove some files from the base vagrant image because they're old |
|
| 5 |
- file { "/home/vagrant/docker-master":
|
|
| 6 |
- ensure => absent, |
|
| 7 |
- recurse => true, |
|
| 8 |
- force => true, |
|
| 9 |
- purge => true, |
|
| 10 |
- } |
|
| 11 |
- file { "/usr/local/bin/dockerd":
|
|
| 12 |
- ensure => absent, |
|
| 13 |
- } |
|
| 14 |
- file { "/usr/local/bin/docker":
|
|
| 15 |
- ensure => absent, |
|
| 16 |
- } |
|
| 17 |
- |
|
| 18 |
- # Set up VirtualBox guest utils |
|
| 19 |
- package { "virtualbox-guest-utils": }
|
|
| 20 |
- exec { "vbox-add" :
|
|
| 21 |
- command => "/etc/init.d/vboxadd setup", |
|
| 22 |
- require => [ |
|
| 23 |
- Package["virtualbox-guest-utils"], |
|
| 24 |
- Package["linux-headers-3.5.0-25-generic"], ], |
|
| 25 |
- } |
|
| 26 |
-} |
|
| 27 |
- |
|
| 28 |
-class docker {
|
|
| 29 |
- # update this with latest go binary dist |
|
| 30 |
- $go_url = "http://go.googlecode.com/files/go1.0.3.linux-amd64.tar.gz" |
|
| 31 |
- |
|
| 32 |
- Package { ensure => "installed" }
|
|
| 33 |
- |
|
| 34 |
- package { ["lxc", "debootstrap", "wget", "bsdtar", "git",
|
|
| 35 |
- "linux-image-3.5.0-25-generic", |
|
| 36 |
- "linux-image-extra-3.5.0-25-generic", |
|
| 37 |
- "linux-headers-3.5.0-25-generic"]: } |
|
| 38 |
- |
|
| 39 |
- $ec2_version = file("/etc/ec2_version", "/dev/null")
|
|
| 40 |
- $rax_version = inline_template("<%= %x{/usr/bin/xenstore-read vm-data/provider_data/provider} %>")
|
|
| 41 |
- |
|
| 42 |
- if ($ec2_version) {
|
|
| 43 |
- $vagrant_user = "ubuntu" |
|
| 44 |
- $vagrant_home = "/home/ubuntu" |
|
| 45 |
- } elsif ($rax_version) {
|
|
| 46 |
- $vagrant_user = "root" |
|
| 47 |
- $vagrant_home = "/root" |
|
| 48 |
- } else {
|
|
| 49 |
- # virtualbox is the vagrant default, so it should be safe to assume |
|
| 50 |
- $vagrant_user = "vagrant" |
|
| 51 |
- $vagrant_home = "/home/vagrant" |
|
| 52 |
- include virtualbox |
|
| 53 |
- } |
|
| 54 |
- |
|
| 55 |
- exec { "fetch-go":
|
|
| 56 |
- require => Package["wget"], |
|
| 57 |
- command => "/usr/bin/wget -O - $go_url | /bin/tar xz -C /usr/local", |
|
| 58 |
- creates => "/usr/local/go/bin/go", |
|
| 59 |
- } |
|
| 60 |
- |
|
| 61 |
- file { "/etc/init/dockerd.conf":
|
|
| 62 |
- mode => 600, |
|
| 63 |
- owner => "root", |
|
| 64 |
- group => "root", |
|
| 65 |
- content => template("docker/dockerd.conf"),
|
|
| 66 |
- } |
|
| 67 |
- |
|
| 68 |
- file { "/opt/go":
|
|
| 69 |
- owner => $vagrant_user, |
|
| 70 |
- group => $vagrant_user, |
|
| 71 |
- recurse => true, |
|
| 72 |
- } |
|
| 73 |
- |
|
| 74 |
- file { "${vagrant_home}/.profile":
|
|
| 75 |
- mode => 644, |
|
| 76 |
- owner => $vagrant_user, |
|
| 77 |
- group => $vagrant_user, |
|
| 78 |
- content => template("docker/profile"),
|
|
| 79 |
- } |
|
| 80 |
- |
|
| 81 |
- exec { "build-docker" :
|
|
| 82 |
- cwd => "/opt/go/src/github.com/dotcloud/docker", |
|
| 83 |
- user => $vagrant_user, |
|
| 84 |
- environment => "GOPATH=/opt/go", |
|
| 85 |
- command => "/usr/local/go/bin/go get -v ./... && /usr/local/go/bin/go install ./docker", |
|
| 86 |
- creates => "/opt/go/bin/docker", |
|
| 87 |
- logoutput => "on_failure", |
|
| 88 |
- require => [ Exec["fetch-go"], File["/opt/go"] ], |
|
| 89 |
- } |
|
| 90 |
- |
|
| 91 |
- service { "dockerd" :
|
|
| 92 |
- ensure => "running", |
|
| 93 |
- start => "/sbin/initctl start dockerd", |
|
| 94 |
- stop => "/sbin/initctl stop dockerd", |
|
| 95 |
- require => [ Exec["build-docker"], File["/etc/init/dockerd.conf"] ], |
|
| 96 |
- name => "dockerd", |
|
| 97 |
- provider => "base" |
|
| 98 |
- } |
|
| 99 |
-} |
| 100 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,12 +0,0 @@ |
| 1 |
-description "Run dockerd" |
|
| 2 |
- |
|
| 3 |
-stop on runlevel [!2345] |
|
| 4 |
-start on runlevel [3] |
|
| 5 |
- |
|
| 6 |
-# if you want it to automatically restart if it crashes, leave the next line in |
|
| 7 |
-respawn |
|
| 8 |
- |
|
| 9 |
-script |
|
| 10 |
- test -f /etc/default/locale && . /etc/default/locale || true |
|
| 11 |
- LANG=$LANG LC_ALL=$LANG /opt/go/bin/docker -d >> /var/log/dockerd 2>&1 |
|
| 12 |
-end script |
| 13 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,30 +0,0 @@ |
| 1 |
-# ~/.profile: executed by the command interpreter for login shells. |
|
| 2 |
-# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login |
|
| 3 |
-# exists. |
|
| 4 |
-# see /usr/share/doc/bash/examples/startup-files for examples. |
|
| 5 |
-# the files are located in the bash-doc package. |
|
| 6 |
- |
|
| 7 |
-# the default umask is set in /etc/profile; for setting the umask |
|
| 8 |
-# for ssh logins, install and configure the libpam-umask package. |
|
| 9 |
-#umask 022 |
|
| 10 |
- |
|
| 11 |
-# if running bash |
|
| 12 |
-if [ -n "$BASH_VERSION" ]; then |
|
| 13 |
- # include .bashrc if it exists |
|
| 14 |
- if [ -f "$HOME/.bashrc" ]; then |
|
| 15 |
- . "$HOME/.bashrc" |
|
| 16 |
- fi |
|
| 17 |
-fi |
|
| 18 |
- |
|
| 19 |
-# set PATH so it includes user's private bin if it exists |
|
| 20 |
-if [ -d "$HOME/bin" ] ; then |
|
| 21 |
- PATH="$HOME/bin:$PATH" |
|
| 22 |
-fi |
|
| 23 |
- |
|
| 24 |
-export GOPATH=/opt/go |
|
| 25 |
-export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin |
|
| 26 |
- |
|
| 27 |
-docker=/opt/go/src/github.com/dotcloud/docker |
|
| 28 |
-if [ -d $docker ]; then |
|
| 29 |
- cd $docker |
|
| 30 |
-fi |