diff --git a/lib/puppet-standalone-mashup/capistrano.rb b/lib/puppet-standalone-mashup/capistrano.rb index dfca02a..183abcb 100644 --- a/lib/puppet-standalone-mashup/capistrano.rb +++ b/lib/puppet-standalone-mashup/capistrano.rb @@ -61,7 +61,7 @@ Capistrano::Configuration.instance.load do desc "Rename the server" task :rename do - hostname = fetch(:hostname, nil) || Capistrano::CLI.ui.ask("Hostname: ") + hostname = ENV['HOSTNAME'] || fetch(:hostname, nil) || Capistrano::CLI.ui.ask("Hostname: ") top.copy_skel run "cd #{puppet_dir} && #{sudo} ./rename #{hostname}" diff --git a/lib/puppet-standalone-mashup/cucumber.rb b/lib/puppet-standalone-mashup/cucumber.rb new file mode 100644 index 0000000..3bff9c6 --- /dev/null +++ b/lib/puppet-standalone-mashup/cucumber.rb @@ -0,0 +1,12 @@ +Before do + # thanks dave. thave. + @sugarpuck = { + :username => 'vagrant', + :password => 'vagrant', + :port => 2222 + } +end + +require 'puppet-standalone-mashup/cucumber/via_ssh' +require 'puppet-standalone-mashup/cucumber/vagrant' + diff --git a/lib/puppet-standalone-mashup/cucumber/vagrant.rb b/lib/puppet-standalone-mashup/cucumber/vagrant.rb new file mode 100644 index 0000000..295ea2e --- /dev/null +++ b/lib/puppet-standalone-mashup/cucumber/vagrant.rb @@ -0,0 +1,12 @@ +def vagrant(*args) + system %{vagrant #{args.collect(&:to_s).join(' ')}} +end + +def cap(*args) + system %{cap vagrant #{args.collect(&:to_s).join(' ')}} +end + +def bootstrap(hostname = ENV['HOSTNAME']) + ENV['HOSTNAME'] = hostname + system %{cap vagrant bootstrap} +end diff --git a/lib/puppet-standalone-mashup/cucumber/via_ssh.rb b/lib/puppet-standalone-mashup/cucumber/via_ssh.rb new file mode 100644 index 0000000..cc85bf0 --- /dev/null +++ b/lib/puppet-standalone-mashup/cucumber/via_ssh.rb @@ -0,0 +1,13 @@ +require 'net/ssh' + +def via_ssh(&block) + result = nil + + Net::SSH.start('localhost', @sugarpuck[:username], :password => @sugarpuck[:password], :port => @sugarpuck[:port]) do |ssh| + result = block.call(ssh) + result = result.strip if result.respond_to?(:strip) + end + + result +end + diff --git a/puppet-standalone-mashup.gemspec b/puppet-standalone-mashup.gemspec index eb1ff9f..84ee658 100644 --- a/puppet-standalone-mashup.gemspec +++ b/puppet-standalone-mashup.gemspec @@ -18,12 +18,13 @@ Gem::Specification.new do |s| s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } s.require_paths = ["lib"] - # specify any dependencies here; for example: - # s.add_development_dependency "rspec" - # s.add_runtime_dependency "rest-client" - - s.add_runtime_dependency 'guard' - s.add_runtime_dependency 'guard-shell' + s.add_runtime_dependency 'vagrant' s.add_runtime_dependency 'capistrano' s.add_runtime_dependency 'capistrano-ext' + + s.add_runtime_dependency 'net-ssh' + s.add_runtime_dependency 'rspec' + s.add_runtime_dependency 'cucumber' + s.add_runtime_dependency 'guard' + s.add_runtime_dependency 'guard-cucumber' end diff --git a/shared/additional-modules/debian/manifests/init.pp b/shared/additional-modules/debian/manifests/init.pp new file mode 100644 index 0000000..5c05507 --- /dev/null +++ b/shared/additional-modules/debian/manifests/init.pp @@ -0,0 +1,6 @@ +class debian { + group { web: + gid => 30010 + } +} + diff --git a/shared/additional-modules/god/templates/god-init.d b/shared/additional-modules/god/templates/god-init.d index 1be6219..faf844d 100644 --- a/shared/additional-modules/god/templates/god-init.d +++ b/shared/additional-modules/god/templates/god-init.d @@ -47,6 +47,8 @@ start() { stop() { echo -n "Stopping $DESC: " kill `cat $PID_PATH` + rm $PID_PATH + killall -9 god RETVAL=$? echo "$NAME." } diff --git a/shared/additional-modules/nginx-debian/manifests/init.pp b/shared/additional-modules/nginx-debian/manifests/init.pp index 4e41329..acffdd6 100644 --- a/shared/additional-modules/nginx-debian/manifests/init.pp +++ b/shared/additional-modules/nginx-debian/manifests/init.pp @@ -5,14 +5,15 @@ class nginx-debian { owner => root, group => web, mode => 2775, - ensure => directory + ensure => directory, + require => Group['web'] } file { "$log_root/sites": owner => root, group => web, mode => 2775, - require => File[$log_root], + require => [ File[$log_root], Group['web'] ], ensure => directory } @@ -23,4 +24,9 @@ class nginx-debian { pattern => "/var/log/nginx/*/access.log /var/log/nginx/*/error.log", require => Class['nginx'] } + + bash_rc_d { 'nginx': + ensure => present, + path => $base::local_path + } } diff --git a/shared/additional-modules/nginx/manifests/init.pp b/shared/additional-modules/nginx/manifests/init.pp index 4b31fbb..e6ca1c9 100644 --- a/shared/additional-modules/nginx/manifests/init.pp +++ b/shared/additional-modules/nginx/manifests/init.pp @@ -24,10 +24,12 @@ class nginx($version, $max_pool_size = 20) { $config_file = "${base::config_path}/nginx.conf" $config_path = "${base::config_path}/nginx" + $nginx_start = "${sbin_path}/nginx -c ${config_file}" + $nginx_stop = "${sbin_path}/nginx -s stop -c ${config_file}" god_init { $name: - start => "${sbin_path}/nginx -c ${config_file}", - stop => "${sbin_path}/nginx -s stop -c ${config_file}", - restart => "${sbin_path}/nginx -s reload -c ${config_file}", + start => $nginx_start, + stop => $nginx_stop, + restart => "${nginx_stop} ; ${nginx_start}", pid_file => $pid_file, ensure => present, notify => Service['god'], @@ -61,16 +63,16 @@ class nginx($version, $max_pool_size = 20) { require => File[$config_file] } - file { '/var/www': ensure => directory } + file { '/var/www': + ensure => directory, + group => web, + mode => 2775, + require => Group['web'] + } file { $symlink_path: ensure => $install_path, require => Exec['install-passenger'] } - - file { "${base::install_path}/bin/new-site": - content => template('nginx/new-site'), - mode => 755 - } } diff --git a/shared/additional-modules/nginx/templates/new-site b/shared/additional-modules/nginx/templates/new-site deleted file mode 100644 index c487356..0000000 --- a/shared/additional-modules/nginx/templates/new-site +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -if [ $UID -ne 0 ]; then - sudo $0 $@ - exit -fi - -cd /var/www -mkdir $1 -chown :www-data $1 -chmod 2775 $1 - diff --git a/shared/additional-modules/ruby-debian/manifests/init.pp b/shared/additional-modules/ruby-debian/manifests/init.pp index d83a34a..66254fa 100644 --- a/shared/additional-modules/ruby-debian/manifests/init.pp +++ b/shared/additional-modules/ruby-debian/manifests/init.pp @@ -9,8 +9,7 @@ class ruby-debian { bash_rc_d { 'ruby': ensure => present, - path => $base::local_path, - require => Build_and_install['ruby'] + path => $base::local_path } } diff --git a/shared/additional-modules/ruby/manifests/init.pp b/shared/additional-modules/ruby/manifests/init.pp index 38270c9..bd438c8 100644 --- a/shared/additional-modules/ruby/manifests/init.pp +++ b/shared/additional-modules/ruby/manifests/init.pp @@ -5,12 +5,12 @@ class ruby($version) { build_and_install { $name: version => $version, source => "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-<%= version %>.tar.gz", + configure => "--disable-install-doc" } gem { 'bundler': require => Build_and_install[$name], path => $with_ruby_path, - options => '--pre', ensure => present } } diff --git a/shared/lib/puppet/provider/bash_rc_d/install.rb b/shared/lib/puppet/provider/bash_rc_d/install.rb index f331fc2..fc9f0f3 100644 --- a/shared/lib/puppet/provider/bash_rc_d/install.rb +++ b/shared/lib/puppet/provider/bash_rc_d/install.rb @@ -2,7 +2,7 @@ Puppet::Type.type(:bash_rc_d).provide(:install) do desc "Configure a new directory to be added to every user's PATH" def create - file.open('wb') { |fh| fh.puts "export PATH=#{@resource[:path]}/#{@resource[:name]}/bin:$PATH" } + file.open('wb') { |fh| fh.puts content } end def destroy @@ -10,10 +10,14 @@ Puppet::Type.type(:bash_rc_d).provide(:install) do end def exists? - file.file? + file.file? && file.read == content end private + def content + "export PATH=#{@resource[:path]}/#{@resource[:name]}/sbin:#{@resource[:path]}/#{@resource[:name]}/bin:$PATH" + end + def file Pathname("/etc/bash.bashrc.d/#{@resource[:name]}.sh") end diff --git a/shared/lib/puppet/provider/gem/gem_install.rb b/shared/lib/puppet/provider/gem/gem_install.rb index b3605ca..b5fcad8 100644 --- a/shared/lib/puppet/provider/gem/gem_install.rb +++ b/shared/lib/puppet/provider/gem/gem_install.rb @@ -35,7 +35,7 @@ Puppet::Type.type(:gem).provide(:install) do end def gem_command(what) - command = %{bash -c 'PATH=#{@resource[:path]} gem #{what} #{@resource[:name]} #{options} #{version}'}.tap { |o| p o } + command = %{bash -c 'PATH=#{@resource[:path]} gem #{what} #{@resource[:name]} #{options} #{version}'} command end end diff --git a/shared/lib/puppet/provider/god_init/install.rb b/shared/lib/puppet/provider/god_init/install.rb index 08d4721..0f2fee7 100644 --- a/shared/lib/puppet/provider/god_init/install.rb +++ b/shared/lib/puppet/provider/god_init/install.rb @@ -53,7 +53,7 @@ God.watch do |w| w.start = lambda { system("<%= start %>") } <% if !stop.empty? %> - w.stop = lambda { system("<%= stop %>") } + w.stop = lambda { system("<%= stop %>") ; system("killall -9 <%= name %>") } <% end %> <% if !restart.empty? %> diff --git a/skel/debian/bootstrap.erb b/skel/debian/bootstrap.erb index e9965eb..7d35a89 100644 --- a/skel/debian/bootstrap.erb +++ b/skel/debian/bootstrap.erb @@ -9,8 +9,11 @@ export DEBIAN_FRONTEND=noninteractive export PAGER=cat apt-get --force-yes update -apt-get --force-yes -y upgrade +apt-get --force-yes -y remove x11-common xserver-xorg-video-all xserver-xorg-core xserver-xorg-video-radeon libgl1-mesa-dri mutt libdrm-intel1 libdrm-radeon1 +apt-get --force-yes -y install deborphan +apt-get --force-yes -y remove `deborphan` apt-get --force-yes -y dist-upgrade +apt-get --force-yes -y upgrade apt-get install --force-yes -y rubygems1.8 puppet apt-get remove --force-yes -y puppet facter