From 701fda7401abb28096408fa3cf11e298563a8deb Mon Sep 17 00:00:00 2001 From: Matthew Riley MacPherson Date: Mon, 5 Mar 2012 21:05:11 -0400 Subject: [PATCH] Fix the vagrants Add a new, lean base box, have puppet scripts for most things to easisly rebuild our box, and have it work out-of-the-box. YAY! --- Vagrantfile | 12 ++-- puppet/files/home/vagrant/zshrc | 37 ++++++---- puppet/manifests/classes/dev_tools.pp | 2 +- puppet/manifests/classes/init.pp | 25 +++++++ puppet/manifests/classes/oh_my_zsh.pp | 15 ++++ puppet/manifests/classes/playdoh.pp | 2 +- puppet/manifests/classes/python.pp | 2 +- puppet/manifests/dev-vagrant.pp | 23 ++++++- .../modules/elasticsearch/manifests/init.pp | 69 ++++++++++--------- settings/local.py-dist | 4 +- 10 files changed, 133 insertions(+), 58 deletions(-) create mode 100644 puppet/manifests/classes/init.pp create mode 100644 puppet/manifests/classes/oh_my_zsh.pp diff --git a/Vagrantfile b/Vagrantfile index 85d1723dc..a64d30543 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -16,12 +16,10 @@ CONF = _config MOUNT_POINT = '/home/vagrant/mozillians' Vagrant::Config.run do |config| + config.vm.box = "mozillians-v1.0" + config.vm.box_url = "http://people.mozilla.org/~mmacpherson/mozillians-v1.0.box" - config.vm.box = "mozillians-v9.box" - config.vm.box_url = "http://people.mozilla.com/~ddash/mozillians-v9.box" - - config.vm.forward_port("web", 8001, 8001) - config.vm.forward_port("ldap", 1389, 1389) + config.vm.forward_port 8000, 8000 # Increase vagrant's patience during hang-y CentOS bootup # see: https://github.com/jedi4ever/veewee/issues/14 @@ -29,7 +27,6 @@ Vagrant::Config.run do |config| config.ssh.timeout = 300 # nfs needs to be explicitly enabled to run. - if CONF['nfs'] == false or RUBY_PLATFORM =~ /mswin(32|64)/ config.vm.share_folder("v-root", MOUNT_POINT, ".") else @@ -41,12 +38,11 @@ Vagrant::Config.run do |config| # config.vm.customize ["modifyvm", :id, "--cpuexecutioncap", "90"] # Add to /etc/hosts: 33.33.33.24 dev.mozillians.org - config.vm.network "33.33.33.24" + config.vm.network :hostonly, "33.33.33.24" config.vm.provision :puppet do |puppet| puppet.manifests_path = "puppet/manifests" puppet.manifest_file = "dev-vagrant.pp" puppet.module_path = "puppet/modules" end - end diff --git a/puppet/files/home/vagrant/zshrc b/puppet/files/home/vagrant/zshrc index 139b64d02..8a551d569 100644 --- a/puppet/files/home/vagrant/zshrc +++ b/puppet/files/home/vagrant/zshrc @@ -1,36 +1,47 @@ # Path to your oh-my-zsh configuration. -export ZSH=$HOME/.oh-my-zsh +ZSH=$HOME/.oh-my-zsh # Set name of the theme to load. # Look in ~/.oh-my-zsh/themes/ # Optionally, if you set this to "random", it'll load a random theme each # time that oh-my-zsh is loaded. -export ZSH_THEME="cypher" +# Themes just cause trouble inside vagrant, so we disable them. +# ZSH_THEME="robbyrussell" + +# Example aliases +# alias zshconfig="mate ~/.zshrc" +# alias ohmyzsh="mate ~/.oh-my-zsh" +alias dj="./manage.py" +alias runserver="dj runserver 0.0.0.0:8000" +alias rs="runserver" +alias t="dj test -x --logging-clear-handlers --with-nicedots" +alias td="FORCE_DB=True t" +alias tf="dj test --logging-clear-handlers --with-nicedots --failed" +alias tp="t --pdb --pdb-failure" # Set to this to use case-sensitive completion -# export CASE_SENSITIVE="true" +# CASE_SENSITIVE="true" # Comment this out to disable weekly auto-update checks -# export DISABLE_AUTO_UPDATE="true" +DISABLE_AUTO_UPDATE="true" # Uncomment following line if you want to disable colors in ls -# export DISABLE_LS_COLORS="true" +# DISABLE_LS_COLORS="true" # Uncomment following line if you want to disable autosetting terminal title. -# export DISABLE_AUTO_TITLE="true" +# DISABLE_AUTO_TITLE="true" + +# Uncomment following line if you want red dots to be displayed while waiting for completion +# COMPLETION_WAITING_DOTS="true" # Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) +# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ # Example format: plugins=(rails git textmate ruby lighthouse) -plugins=() +plugins=(git django vagrant python pip) source $ZSH/oh-my-zsh.sh # Customize to your needs... -export PATH=$HOME/mozillians/directory/localtest/bin:/usr/local/libexec/:/vagrant/directory/localtest/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games +export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/ruby/bin/ -. $HOME/.virtualenvs/mozillians/bin/activate cd $HOME/mozillians - -pushd $HOME/mozillians/directory/devslapd/ -. $HOME/mozillians/directory/devslapd/setup.sh -popd diff --git a/puppet/manifests/classes/dev_tools.pp b/puppet/manifests/classes/dev_tools.pp index 80f4a9ada..f39aa2638 100644 --- a/puppet/manifests/classes/dev_tools.pp +++ b/puppet/manifests/classes/dev_tools.pp @@ -10,7 +10,7 @@ ubuntu: { package { - [ "git-core", "vim", "emacs" ]: + [ "git-core", "vim", "emacs", "zsh" ]: ensure => installed; } } diff --git a/puppet/manifests/classes/init.pp b/puppet/manifests/classes/init.pp new file mode 100644 index 000000000..1c0b8b91d --- /dev/null +++ b/puppet/manifests/classes/init.pp @@ -0,0 +1,25 @@ +# stage {"pre": before => Stage["main"]} class {'apt': stage => 'pre'} + +# Commands to run before all others in puppet. +class init { + group { "puppet": + ensure => "present", + } + + case $operatingsystem { + ubuntu: { + exec { "update_apt": + command => "sudo apt-get update", + } + + # Provides "add-apt-repository" command, useful if you need + # to install software from other apt repositories. + package { "python-software-properties": + ensure => present, + require => [ + Exec['update_apt'], + ]; + } + } + } +} diff --git a/puppet/manifests/classes/oh_my_zsh.pp b/puppet/manifests/classes/oh_my_zsh.pp new file mode 100644 index 000000000..31092802e --- /dev/null +++ b/puppet/manifests/classes/oh_my_zsh.pp @@ -0,0 +1,15 @@ +class oh_my_zsh { + exec { "oh-my-zsh": + command => "wget --no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh", + require => Package['git-core', 'zsh'], + cwd => '/home/vagrant/', + user => 'vagrant'; + #path => "/usr/bin:/usr/sbin:/bin:/usr/local/bin", + #refreshonly => true, + } + + exec { "change-shell": + command => "sudo chsh vagrant /usr/bin/zsh", + require => Exec['oh-my-zsh']; + } +} diff --git a/puppet/manifests/classes/playdoh.pp b/puppet/manifests/classes/playdoh.pp index 1da8c793c..ef6d15cd2 100644 --- a/puppet/manifests/classes/playdoh.pp +++ b/puppet/manifests/classes/playdoh.pp @@ -18,7 +18,7 @@ # TODO: make this support centos or ubuntu (#centos) exec { "sql_migrate": cwd => "$PROJ_DIR", - command => "/usr/bin/python2.6 ./vendor/src/schematic/schematic migrations/", + command => "/usr/bin/python2.6 manage.py syncdb --noinput", require => [ Service["mysql"], Package["python2.6-dev", "libapache2-mod-wsgi", "python-wsgi-intercept" ], diff --git a/puppet/manifests/classes/python.pp b/puppet/manifests/classes/python.pp index 230b1b903..7c793167b 100644 --- a/puppet/manifests/classes/python.pp +++ b/puppet/manifests/classes/python.pp @@ -29,4 +29,4 @@ } } -} \ No newline at end of file +} diff --git a/puppet/manifests/dev-vagrant.pp b/puppet/manifests/dev-vagrant.pp index 43937ec8a..2b1848546 100644 --- a/puppet/manifests/dev-vagrant.pp +++ b/puppet/manifests/dev-vagrant.pp @@ -12,10 +12,15 @@ $USE_YUM_CACHE_ON_HOST = 0 $USE_SOUTH = 1 -Exec { path => [ "/bin/"] } +$DONT_REPROVISION = 1 + +Exec { + path => "/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin", +} class dev { class { + init: before => Class[dev_hacks]; dev_hacks: before => Class[repos]; repos: before => Class[dev_tools]; dev_tools: before => Class[mysql]; @@ -25,7 +30,21 @@ memcached:; playdoh_site:; elasticsearch: version => "0.18.6"; + # oh_my_zsh:; + } +} + +if $DONT_REPROVISION == 1 { + file { "$PROJ_DIR/settings/local.py": + ensure => file, + source => "$PROJ_DIR/settings/local.py-dist"; } +} else { + include dev } -include dev +exec { "es-restart": + command => "/usr/local/elasticsearch/bin/service/elasticsearch restart", + #path => "/usr/bin:/usr/sbin:/bin:/usr/local/bin", + #refreshonly => true, +} diff --git a/puppet/modules/elasticsearch/manifests/init.pp b/puppet/modules/elasticsearch/manifests/init.pp index e5e97fc02..2a1f722c6 100644 --- a/puppet/modules/elasticsearch/manifests/init.pp +++ b/puppet/modules/elasticsearch/manifests/init.pp @@ -17,47 +17,54 @@ class sun_java_6 { - $release = regsubst(generate("/usr/bin/lsb_release", "-s", "-c"), '(\w+)\s', '\1') - - file { "partner.list": - path => "/etc/apt/sources.list.d/partner.list", - ensure => file, - owner => "root", - group => "root", - content => "deb http://archive.canonical.com/ $release partner\ndeb-src http://archive.canonical.com/ $release partner\n", - notify => Exec["apt-get-update"], - } + # $release = regsubst(generate("/usr/bin/lsb_release", "-s", "-c"), '(\w+)\s', '\1') + + # file { "partner.list": + # path => "/etc/apt/sources.list.d/partner.list", + # ensure => file, + # owner => "root", + # group => "root", + # content => "deb http://archive.canonical.com/ $release partner\ndeb-src http://archive.canonical.com/ $release partner\n", + # notify => Exec["apt-get-update"], + # require => Exec['add-java'], + # } + + # exec { "add-java": + # command => "sudo add-apt-repository ppa:ferramroberto/java", + # #path => "/usr/bin:/usr/sbin:/bin:/usr/local/bin", + # #refreshonly => true, + # } exec { "apt-get-update": command => "/usr/bin/apt-get update", refreshonly => true, } - package { "debconf-utils": + package { ["debconf-utils", "openjdk-6-jre-headless"]: ensure => installed } - exec { "agree-to-jdk-license": - command => "/bin/echo -e sun-java6-jdk shared/accepted-sun-dlj-v1-1 select true | debconf-set-selections", - unless => "debconf-get-selections | grep 'sun-java6-jdk.*shared/accepted-sun-dlj-v1-1.*true'", - path => ["/bin", "/usr/bin"], require => Package["debconf-utils"], - } + # exec { "agree-to-jdk-license": + # command => "/bin/echo -e sun-java6-jdk shared/accepted-sun-dlj-v1-1 select true | debconf-set-selections", + # unless => "debconf-get-selections | grep 'sun-java6-jdk.*shared/accepted-sun-dlj-v1-1.*true'", + # path => ["/bin", "/usr/bin"], require => Package["debconf-utils"], + # } - exec { "agree-to-jre-license": - command => "/bin/echo -e sun-java6-jre shared/accepted-sun-dlj-v1-1 select true | debconf-set-selections", - unless => "debconf-get-selections | grep 'sun-java6-jre.*shared/accepted-sun-dlj-v1-1.*true'", - path => ["/bin", "/usr/bin"], require => Package["debconf-utils"], - } + # exec { "agree-to-jre-license": + # command => "/bin/echo -e sun-java6-jre shared/accepted-sun-dlj-v1-1 select true | debconf-set-selections", + # unless => "debconf-get-selections | grep 'sun-java6-jre.*shared/accepted-sun-dlj-v1-1.*true'", + # path => ["/bin", "/usr/bin"], require => Package["debconf-utils"], + # } - package { "sun-java6-jdk": - ensure => latest, - require => [ File["partner.list"], Exec["agree-to-jdk-license"], Exec["apt-get-update"] ], - } + # package { "sun-java6-jdk": + # ensure => latest, + # require => [ File["partner.list"], Exec["agree-to-jdk-license"], Exec["apt-get-update"] ], + # } - package { "sun-java6-jre": - ensure => latest, - require => [ File["partner.list"], Exec["agree-to-jre-license"], Exec["apt-get-update"] ], - } + # package { "sun-java6-jre": + # ensure => latest, + # require => [ File["partner.list"], Exec["agree-to-jre-license"], Exec["apt-get-update"] ], + # } } @@ -84,7 +91,7 @@ $esJarfile = "${esName}.jar" $esServiceRev = "3e0b23d" - include sun_java_6 + # include sun_java_6 download_file { ["${esName}.tar.gz"]: @@ -105,7 +112,7 @@ comment => "Elasticsearch user created by puppet", managehome => true, shell => "/bin/false", - require => [Package["sun-java6-jre"]], + #require => [Package["sun-java6-jre"]], uid => 901 } diff --git a/settings/local.py-dist b/settings/local.py-dist index 8739f4fe8..1280e720b 100644 --- a/settings/local.py-dist +++ b/settings/local.py-dist @@ -6,7 +6,7 @@ from settings import * # For absoluate urls DOMAIN = "localhost" PROTOCOL = "http://" -PORT = 8001 +PORT = 8000 SITE_URL = '%s%s:%d' % (PROTOCOL, DOMAIN, PORT) @@ -55,3 +55,5 @@ DEBUG = TEMPLATE_DEBUG = True ES_DISABLED = False ES_HOSTS = ['127.0.0.1:9200'] ES_INDEXES = dict(default='mozillians_dev') + +CELERY_ALWAYS_EAGER = True