machines 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +11 -0
- data/EXAMPLES.md +18 -0
- data/Gemfile +4 -0
- data/Guardfile +14 -0
- data/INSTALL.md +25 -0
- data/LICENSE +23 -0
- data/README.md +271 -0
- data/Rakefile +60 -0
- data/TODO.md +92 -0
- data/bin/machines +6 -0
- data/lib/machines/app_settings.rb +54 -0
- data/lib/machines/base.rb +13 -0
- data/lib/machines/checks.rb +63 -0
- data/lib/machines/cloud_machine.rb +33 -0
- data/lib/machines/command.rb +86 -0
- data/lib/machines/commandline.rb +148 -0
- data/lib/machines/configuration.rb +49 -0
- data/lib/machines/core.rb +117 -0
- data/lib/machines/database.rb +17 -0
- data/lib/machines/file_operations.rb +104 -0
- data/lib/machines/help.rb +30 -0
- data/lib/machines/installation.rb +151 -0
- data/lib/machines/log_command.rb +22 -0
- data/lib/machines/logger.rb +65 -0
- data/lib/machines/machinesfile.rb +25 -0
- data/lib/machines/named_buffer.rb +9 -0
- data/lib/machines/questions.rb +15 -0
- data/lib/machines/services.rb +24 -0
- data/lib/machines/upload.rb +29 -0
- data/lib/machines/version.rb +4 -0
- data/lib/machines.rb +19 -0
- data/lib/packages/abiword.rb +11 -0
- data/lib/packages/amazon_mp3.rb +4 -0
- data/lib/packages/awstats.rb +16 -0
- data/lib/packages/base.rb +14 -0
- data/lib/packages/chrome.rb +12 -0
- data/lib/packages/cruisecontrol.rb +22 -0
- data/lib/packages/dependencies.rb +10 -0
- data/lib/packages/docky.rb +36 -0
- data/lib/packages/dotfiles.rb +26 -0
- data/lib/packages/file_roller.rb +12 -0
- data/lib/packages/finalise.rb +4 -0
- data/lib/packages/firefox.rb +4 -0
- data/lib/packages/gedit.rb +11 -0
- data/lib/packages/git.rb +4 -0
- data/lib/packages/gmate.rb +33 -0
- data/lib/packages/gnome.rb +10 -0
- data/lib/packages/gnumeric.rb +11 -0
- data/lib/packages/hosts.rb +13 -0
- data/lib/packages/load_machines.rb +38 -0
- data/lib/packages/monit.rb +10 -0
- data/lib/packages/mysql.rb +46 -0
- data/lib/packages/nginx.rb +22 -0
- data/lib/packages/nginx_logrotate.rb +26 -0
- data/lib/packages/openbox.rb +35 -0
- data/lib/packages/passenger.rb +14 -0
- data/lib/packages/passenger_nginx.rb +8 -0
- data/lib/packages/postfix.rb +10 -0
- data/lib/packages/questions.rb +5 -0
- data/lib/packages/rbenv.rb +27 -0
- data/lib/packages/rvm.rb +20 -0
- data/lib/packages/save_machines.rb +4 -0
- data/lib/packages/slim.rb +6 -0
- data/lib/packages/sqlserver.rb +5 -0
- data/lib/packages/subtle.rb +29 -0
- data/lib/packages/sudo_mods.rb +6 -0
- data/lib/packages/time.rb +6 -0
- data/lib/packages/time_daily.rb +5 -0
- data/lib/packages/timezone.rb +10 -0
- data/lib/packages/unison.rb +5 -0
- data/lib/packages/virtualbox.rb +11 -0
- data/lib/packages/virtualbox_guest.rb +7 -0
- data/lib/packages/webapps.rb +36 -0
- data/lib/template/Machinesfile +48 -0
- data/lib/template/certificates/example.com.crt +0 -0
- data/lib/template/certificates/example.com.key +0 -0
- data/lib/template/certificates/selfsigned.crt +14 -0
- data/lib/template/certificates/selfsigned.key +16 -0
- data/lib/template/config.yml +98 -0
- data/lib/template/logrotate/app.erb +10 -0
- data/lib/template/logrotate/nginx.erb +12 -0
- data/lib/template/machines.yml +179 -0
- data/lib/template/misc/awstats.conf.erb +7 -0
- data/lib/template/misc/ntp.conf +7 -0
- data/lib/template/monit/conf.d/delayed_job.erb +11 -0
- data/lib/template/monit/conf.d/mysql.erb +7 -0
- data/lib/template/monit/conf.d/nginx +5 -0
- data/lib/template/monit/conf.d/postfix +7 -0
- data/lib/template/monit/conf.d/ssh +6 -0
- data/lib/template/monit/conf.d/system.erb +14 -0
- data/lib/template/monit/monitrc.erb +10 -0
- data/lib/template/monit/upstart.conf +16 -0
- data/lib/template/mysql/dbmaster.cnf +7 -0
- data/lib/template/mysql/dbslave.cnf +3 -0
- data/lib/template/nginx/app_server.conf.erb +87 -0
- data/lib/template/nginx/nginx.conf.erb +46 -0
- data/lib/template/nginx/upstart.conf.erb +21 -0
- data/lib/template/packages/custom.rb +17 -0
- data/lib/template/packages/productivity.rb +18 -0
- data/lib/template/slim/themes/dark/background.jpg +0 -0
- data/lib/template/slim/themes/dark/panel.png +0 -0
- data/lib/template/slim/themes/dark/slim.theme +39 -0
- data/lib/template/users/phil/dotfiles/bash_aliases +45 -0
- data/lib/template/users/phil/dotfiles/config/Trolltech.conf +4 -0
- data/lib/template/users/phil/dotfiles/config/gtk-3.0/settings.ini +9 -0
- data/lib/template/users/phil/dotfiles/config/openbox/autostart.sh +14 -0
- data/lib/template/users/phil/dotfiles/config/openbox/rc.xml +482 -0
- data/lib/template/users/phil/dotfiles/config/terminator/config +10 -0
- data/lib/template/users/phil/dotfiles/fonts.conf +15 -0
- data/lib/template/users/phil/dotfiles/gitconfig +27 -0
- data/lib/template/users/phil/dotfiles/gtkrc-2.0 +16 -0
- data/lib/template/users/phil/dotfiles/local/share/applications/mimeapps.list +4 -0
- data/lib/template/users/phil/dotfiles/unison/default.prf +33 -0
- data/lib/template/users/www/authorized_keys +0 -0
- data/lib/template/users/www/dotfiles/bash_aliases +40 -0
- data/lib/template/webapps.yml +75 -0
- data/machines.gemspec +44 -0
- data/spec/acceptance/dev_machine_spec.rb +22 -0
- data/spec/lib/machines/app_settings_spec.rb +106 -0
- data/spec/lib/machines/checks_spec.rb +105 -0
- data/spec/lib/machines/cloud_machine_spec.rb +36 -0
- data/spec/lib/machines/command_spec.rb +184 -0
- data/spec/lib/machines/commandline_spec.rb +299 -0
- data/spec/lib/machines/configuration_spec.rb +61 -0
- data/spec/lib/machines/core_spec.rb +299 -0
- data/spec/lib/machines/database_spec.rb +51 -0
- data/spec/lib/machines/file_operations_spec.rb +124 -0
- data/spec/lib/machines/help_spec.rb +22 -0
- data/spec/lib/machines/installation_spec.rb +176 -0
- data/spec/lib/machines/log_command_spec.rb +16 -0
- data/spec/lib/machines/logger_spec.rb +70 -0
- data/spec/lib/machines/machinesfile_spec.rb +34 -0
- data/spec/lib/machines/questions_spec.rb +73 -0
- data/spec/lib/machines/services_spec.rb +26 -0
- data/spec/lib/machines/upload_spec.rb +86 -0
- data/spec/lib/packages/abiword_spec.rb +20 -0
- data/spec/lib/packages/amazon_mp3_spec.rb +17 -0
- data/spec/lib/packages/awstats_spec.rb +26 -0
- data/spec/lib/packages/base_spec.rb +21 -0
- data/spec/lib/packages/chrome_spec.rb +30 -0
- data/spec/lib/packages/cruisecontrol_spec.rb +33 -0
- data/spec/lib/packages/dependencies_spec.rb +20 -0
- data/spec/lib/packages/docky_spec.rb +32 -0
- data/spec/lib/packages/dotfiles_spec.rb +44 -0
- data/spec/lib/packages/file_roller_spec.rb +69 -0
- data/spec/lib/packages/firefox_spec.rb +16 -0
- data/spec/lib/packages/gedit_spec.rb +20 -0
- data/spec/lib/packages/git_spec.rb +16 -0
- data/spec/lib/packages/gmate_spec.rb +39 -0
- data/spec/lib/packages/gnome_spec.rb +22 -0
- data/spec/lib/packages/gnumeric_spec.rb +21 -0
- data/spec/lib/packages/hosts_spec.rb +41 -0
- data/spec/lib/packages/load_machines_spec.rb +118 -0
- data/spec/lib/packages/monit_spec.rb +34 -0
- data/spec/lib/packages/mysql_spec.rb +69 -0
- data/spec/lib/packages/nginx_logrotate_spec.rb +80 -0
- data/spec/lib/packages/nginx_spec.rb +46 -0
- data/spec/lib/packages/openbox_spec.rb +41 -0
- data/spec/lib/packages/passenger_nginx_spec.rb +20 -0
- data/spec/lib/packages/passenger_spec.rb +26 -0
- data/spec/lib/packages/postfix_spec.rb +19 -0
- data/spec/lib/packages/questions_spec.rb +29 -0
- data/spec/lib/packages/rbenv_spec.rb +32 -0
- data/spec/lib/packages/rvm_spec.rb +31 -0
- data/spec/lib/packages/save_machines_spec.rb +51 -0
- data/spec/lib/packages/slim_spec.rb +22 -0
- data/spec/lib/packages/sqlserver_spec.rb +17 -0
- data/spec/lib/packages/timezone_spec.rb +27 -0
- data/spec/lib/packages/unison_spec.rb +17 -0
- data/spec/lib/packages/virtualbox_guest_spec.rb +25 -0
- data/spec/lib/packages/virtualbox_spec.rb +23 -0
- data/spec/lib/packages/webapps_spec.rb +70 -0
- data/spec/spec_helper.rb +103 -0
- data/spec/support/coverage.rb +8 -0
- data/spec/support/fake_out.rb +22 -0
- data/spec/support/fakefs_additions.rb +10 -0
- data/spec/support/minitest.rb +69 -0
- data/spec/support/vm_control.rb +54 -0
- data/tmp/.gitkeep +0 -0
- metadata +581 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
class ConfigError < StandardError; end
|
|
2
|
+
|
|
3
|
+
task :load_machines, 'Loads the machines.yml' do
|
|
4
|
+
$conf.machines = AppConf.new
|
|
5
|
+
$conf.load('machines.yml')
|
|
6
|
+
|
|
7
|
+
machine = $conf.machine = $conf.machines[$conf.machine_name]
|
|
8
|
+
raise ConfigError, "#{$conf.machine_name} does not match any machine in machines.yml" unless machine
|
|
9
|
+
$conf.db_server = $conf.machines[machine.db_server]
|
|
10
|
+
|
|
11
|
+
if machine.root_pass.nil?
|
|
12
|
+
machine.root_pass = generate_password
|
|
13
|
+
$conf.machines_changed = true
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
$conf.user_home = "/home/#{machine.user}"
|
|
17
|
+
$conf.appsroot = $conf.appsroots[machine.user] if machine.user
|
|
18
|
+
$conf.users = $conf.appsroots.keys
|
|
19
|
+
$conf.user = machine.user
|
|
20
|
+
$conf.environment = machine.environment
|
|
21
|
+
$conf.roles = machine.roles
|
|
22
|
+
|
|
23
|
+
errors = []
|
|
24
|
+
errors << 'Machine needs to have an address or be an EC2 instance.' unless machine.address || machine.ec2
|
|
25
|
+
errors << 'No user set for machine.' unless machine.user
|
|
26
|
+
errors << 'User does not have an appsroot.' unless $conf.appsroot || machine.user.nil?
|
|
27
|
+
if errors.any?
|
|
28
|
+
errors << 'Check machines.yml and config.yml for errors.'
|
|
29
|
+
raise ConfigError, errors.join("\n")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
thread = Thread.new { connect && run_instance } if machine.ec2 && machine.address.nil? unless $conf.log_only
|
|
33
|
+
|
|
34
|
+
load_app_settings(machine.apps)
|
|
35
|
+
|
|
36
|
+
thread.join if thread
|
|
37
|
+
end
|
|
38
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
task :monit, 'Install and configure monit' do
|
|
2
|
+
sudo install 'monit'
|
|
3
|
+
sudo "/etc/init.d/monit stop && update-rc.d -f monit remove"
|
|
4
|
+
sudo upload 'monit/upstart.conf', '/etc/init/monit.conf'
|
|
5
|
+
|
|
6
|
+
sudo create_from 'monit/monitrc.erb', :to => '/etc/monit/monitrc'
|
|
7
|
+
sudo create_from 'monit/conf.d/system.erb', :to => '/etc/monit/conf.d/system'
|
|
8
|
+
sudo upload 'monit/conf.d/ssh', '/etc/monit/conf.d/ssh'
|
|
9
|
+
end
|
|
10
|
+
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
def mysql_execute(sql, options)
|
|
2
|
+
required_options options, [:password]
|
|
3
|
+
run "echo \"#{sql}\" | mysql -u root -p#{options[:password]}", nil
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
only roles: :db do
|
|
7
|
+
task :mysql, 'Install MySQL' do
|
|
8
|
+
name = 'mysql-server-5.5'
|
|
9
|
+
key = 'mysql-server/root_password'
|
|
10
|
+
sudo debconf name, key, 'password', $conf.machine.root_pass
|
|
11
|
+
sudo debconf name, "#{key}_again", 'password', $conf.machine.root_pass
|
|
12
|
+
sudo install %w(mysql-server mysql-client libmysqlclient-dev)
|
|
13
|
+
run restart 'mysql'
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
only roles: :dbmaster do
|
|
18
|
+
task :dbperms, 'Grant applications access to the database' do
|
|
19
|
+
$conf.webapps.values.each do |app|
|
|
20
|
+
mysql_execute "GRANT ALL ON *.* TO '#{app.name}'@'%' " +
|
|
21
|
+
"IDENTIFIED BY '#{app.password}';", password: $conf.machine.root_pass
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
task :replication, 'Grant replication access to this machine' do
|
|
26
|
+
sudo upload "mysql/dbmaster.cnf", "/etc/mysql/conf.d/dbmaster.cnf"
|
|
27
|
+
mysql_execute "GRANT REPLICATION SLAVE ON *.* " +
|
|
28
|
+
"TO '#{$conf.machine.replication_user}'@'%' " +
|
|
29
|
+
"IDENTIFIED BY '#{$conf.machine.replication_pass}';", password: $conf.machine.root_pass
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
only roles: :dbslave do
|
|
34
|
+
task :replication, 'Setup database replication from master' do
|
|
35
|
+
sudo upload "mysql/dbslave.cnf", "/etc/mysql/conf.d/dbslave.cnf"
|
|
36
|
+
mysql_execute "CHANGE MASTER TO " +
|
|
37
|
+
"MASTER_HOST='#{$conf.db_server.address}', " +
|
|
38
|
+
"MASTER_USER='#{$conf.db_server.replication_user}' " +
|
|
39
|
+
"MASTER_PASSWORD='#{$conf.db_server.replication_pass}';", password: $conf.machine.root_pass
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
task :monit_mysql, 'Configure monit for MySQL', if: [:monit, :mysql] do
|
|
44
|
+
sudo create_from 'monit/conf.d/mysql.erb', to: '/etc/monit/conf.d/mysql'
|
|
45
|
+
end
|
|
46
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
task :nginx, 'Download and configure Nginx' do
|
|
2
|
+
sudo extract $conf.webserver.url
|
|
3
|
+
modules = "#{$conf.webserver.modules} --add-module=#{$conf.passenger.nginx}"
|
|
4
|
+
commands = [
|
|
5
|
+
"cd #{$conf.webserver.src_path}",
|
|
6
|
+
"./configure #{modules}",
|
|
7
|
+
"make",
|
|
8
|
+
"make install"
|
|
9
|
+
].join(' && ')
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
sudo commands, check_file("#{$conf.webserver.path}/sbin/nginx")
|
|
13
|
+
|
|
14
|
+
sudo create_from 'nginx/nginx.conf.erb', :to => "#{$conf.webserver.path}/#{$conf.webserver.conf_path}/nginx.conf"
|
|
15
|
+
|
|
16
|
+
sudo create_from 'nginx/upstart.conf.erb', :to => "/etc/init/nginx.conf"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
task :monit_nginx, 'Add monit configuration for Nginx', :if => [:monit, :nginx] do
|
|
20
|
+
sudo upload 'monit/conf.d/nginx', '/etc/monit/conf.d/nginx'
|
|
21
|
+
end
|
|
22
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
task :logrotate_nginx, 'Logrotate nginx access and error logs and optionally generate stats' do
|
|
2
|
+
$conf.webapps.each do |app_name, app|
|
|
3
|
+
%w(access error).each do |type|
|
|
4
|
+
if type == 'access' && app.stats
|
|
5
|
+
stats_prerotate = "/usr/lib/cgi-bin/awstats.pl -update -config=#{app.server_name} > /dev/null"
|
|
6
|
+
stats_postrotate = "/usr/local/bin/awstats_render #{app.server_name} #{app.path}_stats/public > /dev/null"
|
|
7
|
+
else
|
|
8
|
+
stats_prerotate = stats_postrotate = nil
|
|
9
|
+
end
|
|
10
|
+
settings = AppBuilder.new(
|
|
11
|
+
log_path: "/var/log/nginx/#{app.name}.#{type}.log",
|
|
12
|
+
stats_prerotate: stats_prerotate,
|
|
13
|
+
stats_postrotate: stats_postrotate
|
|
14
|
+
)
|
|
15
|
+
sudo create_from 'logrotate/nginx.erb', settings: settings, to: "/etc/logrotate.d/#{app.name}_nginx_#{type}"
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
task :logrotate_apps, 'Logrotate Rails app logs' do
|
|
21
|
+
$conf.webapps.each do |app_name, app|
|
|
22
|
+
settings = AppBuilder.new(log_path: File.join(app.path, 'shared', 'log', '*.log'))
|
|
23
|
+
sudo create_from 'logrotate/app.erb', settings: settings, to: File.join('/etc', 'logrotate.d', "#{app.name}_app")
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
task :openbox, 'Install Openbox window manager and associated fonts, themes, etc' do
|
|
2
|
+
sudo debconf 'ttf-mscorefonts-installer', 'msttcorefonts/accepted-mscorefonts-eula', 'boolean', true
|
|
3
|
+
sudo install [
|
|
4
|
+
'dmz-cursor-theme', # Mouse cursor theme
|
|
5
|
+
'elementary-icon-theme', # An icon theme
|
|
6
|
+
'feh', # Set the background image: feh --bg-scale
|
|
7
|
+
'gnome-screenshot', # Press Print Screen to take a screen shot of the desktop
|
|
8
|
+
'gnome-themes-standard', # Needed to theme GTK 3 apps
|
|
9
|
+
'lxappearance', # Set gtk themes, cursors and icons - Set to clearlooks
|
|
10
|
+
'obconf', # Set openbox themes - Set to onyx black
|
|
11
|
+
'openbox', # Openbox lightweight Window Manager
|
|
12
|
+
'pcmanfm', # Lightweight File manager
|
|
13
|
+
'suckless-tools', # Includes slock - Locks screen. Password unlocks - no prompt. Can be used with xautolock
|
|
14
|
+
'terminator', # Multi-window enhanced console
|
|
15
|
+
'ttf-ubuntu-font-family', # The new ubuntu font
|
|
16
|
+
'ttf-mscorefonts-installer', # Microsoft fonts
|
|
17
|
+
'xautolock', # Locks screen after idle
|
|
18
|
+
'xcompmgr', # Compositing manager - Needed by docky for transparency
|
|
19
|
+
'xorg', # Basic X Windows Graphical Interface needed by Openbox
|
|
20
|
+
]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
task :fonts, 'Set openbox and Gnome interface fonts (See also rc.xml, fonts.conf, gtkrc-2.0)' do
|
|
24
|
+
run configure "/apps/metacity/general/titlebar_font" => "Ubuntu Bold 8"
|
|
25
|
+
run configure "/apps/nautilus/preferences/desktop_font" => "Ubuntu Light 8"
|
|
26
|
+
run configure "/apps/nautilus/preferences/default_folder_viewer" => 'compact_view'
|
|
27
|
+
run configure "/desktop/gnome/interface/font_name" => "Ubuntu Light 8"
|
|
28
|
+
run configure "/desktop/gnome/interface/document_font_name" => "Ubuntu Light 8"
|
|
29
|
+
run configure "/desktop/gnome/interface/monospace_font_name" => "Monospace 10"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
sudo append 'inode/directory=pcmanfm.desktop', :to => '.local/share/applications/mimeapps.list'
|
|
33
|
+
|
|
34
|
+
run append 'ck-launch-session openbox-session', :to => '~/.xinitrc'
|
|
35
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
task :passenger, 'Install passenger' do
|
|
2
|
+
sudo install 'libcurl4-openssl-dev'
|
|
3
|
+
#HACK: PATHS are added to .profile which is not run on a non-login shell. NET::Ssh creates non-login shells
|
|
4
|
+
if $conf.ruby.gems_path =~ /^.rbenv/
|
|
5
|
+
rbenv_gem = '~/.rbenv/bin/rbenv exec gem '
|
|
6
|
+
run "#{rbenv_gem} install passenger -v #{$conf.passenger.version}", check_command("#{rbenv_gem} list", 'passenger')
|
|
7
|
+
else
|
|
8
|
+
run gem 'passenger', :version => $conf.passenger.version
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
$conf.passenger.root = File.join($conf.user_home, $conf.ruby.gems_path, "passenger-#{$conf.passenger.version}")
|
|
12
|
+
$conf.passenger.ruby = File.join($conf.user_home, $conf.ruby.executable)
|
|
13
|
+
end
|
|
14
|
+
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
task :passenger_nginx, 'Build the passenger module for Nginx' do
|
|
2
|
+
$conf.passenger.nginx = File.join($conf.passenger.root, 'ext/nginx')
|
|
3
|
+
rake_command = 'rake'
|
|
4
|
+
rake_command = '~/.rbenv/bin/rbenv exec rake' if $conf.ruby.gems_path =~ /^.rbenv/
|
|
5
|
+
check = check_command("ls #{$conf.passenger.root}/ext/ruby/ruby-#{$conf.ruby.version}*", 'passenger_native_support.so')
|
|
6
|
+
run "cd #{$conf.passenger.nginx} && #{rake_command} nginx RELEASE=yes && cd -", check
|
|
7
|
+
end
|
|
8
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
task :postfix, 'Install postfix mail' do
|
|
2
|
+
sudo debconf 'postfix', 'postfix/main_mailer_type', 'select', 'Internet Site'
|
|
3
|
+
sudo debconf 'postfix', 'postfix/mailname', 'string', $conf.mail.domain
|
|
4
|
+
sudo install 'postfix'
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
task :monit_postfix, 'Configure monit for postfix', :if => [:monit, :postfix] do
|
|
8
|
+
sudo upload 'monit/conf.d/postfix', '/etc/monit/conf.d/postfix'
|
|
9
|
+
end
|
|
10
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
task :rbenv, "Install ruby-build, rbenv, ruby #{$conf.ruby.version} and Bundler" do
|
|
2
|
+
sudo install ['git-core', 'curl']
|
|
3
|
+
run git_clone 'git://github.com/sstephenson/ruby-build.git'
|
|
4
|
+
sudo 'cd ~/ruby-build && ./install.sh', check_file('/usr/local/bin/ruby-build')
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
# Safely execute bundler generated shims for your projects
|
|
8
|
+
# (https://twitter.com/#!/tpope/statuses/165631968996900865)
|
|
9
|
+
# cd your_project
|
|
10
|
+
# mkdir .bin/safe
|
|
11
|
+
# bundle --binstubs=.bin (or just bundle if you use the example bashrc)
|
|
12
|
+
#
|
|
13
|
+
run git_clone 'git://github.com/sstephenson/rbenv.git', :to => '~/.rbenv'
|
|
14
|
+
#NOTE: This path will not be available to the session as Net::SSH uses a non-login shell
|
|
15
|
+
path = 'PATH=.bin/safe/../../.bin:$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH'
|
|
16
|
+
run append path, :to => '~/.profile'
|
|
17
|
+
rbenv = '$HOME/.rbenv/bin/rbenv'
|
|
18
|
+
|
|
19
|
+
run "#{rbenv} install #{$conf.ruby.full_version}", check_command("#{rbenv} versions", $conf.ruby.version)
|
|
20
|
+
run "#{rbenv} rehash", check_command("#{path} which gem", '.rbenv/shims/gem')
|
|
21
|
+
run "#{rbenv} global #{$conf.ruby.full_version}", check_command("#{rbenv} exec ruby -v", $conf.ruby.version)
|
|
22
|
+
|
|
23
|
+
run write "gem: --no-rdoc --no-ri", :to => '.gemrc', :name => '.gemrc'
|
|
24
|
+
run "#{rbenv} exec gem install bundler", check_command("#{rbenv} exec gem list", 'bundler')
|
|
25
|
+
run "#{rbenv} rehash", check_command("#{path} which bundle", '.rbenv/shims/bundle')
|
|
26
|
+
end
|
|
27
|
+
|
data/lib/packages/rvm.rb
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
task :rvm, 'Install RVM' do
|
|
2
|
+
sudo install ['git-core']
|
|
3
|
+
installer = "bash -s #{$conf.rvm.version} < <(wget -q https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )"
|
|
4
|
+
run installer, check_file('~/.rvm/bin/rvm')
|
|
5
|
+
|
|
6
|
+
run "source .bashrc", "type rvm | head -1 | grep 'rvm is a function' #{echo_result}"
|
|
7
|
+
run remove 'rvm-installer'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
task :rvm_prompt_off, 'turn off trust prompting for new .rvmrc files' do
|
|
11
|
+
run append 'export rvm_trust_rvmrcs_flag=1', :to => '.rvmrc'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
task :ruby, "Install Ruby, make #{$conf.ruby.version}@global the default and install Bundler" do
|
|
15
|
+
run "rvm install #{$conf.ruby.version}", "rvm #{$conf.ruby.version} #{echo_result}"
|
|
16
|
+
run "rvm #{$conf.ruby.version}@global --default", "ruby -v | grep #{$conf.ruby.version} #{echo_result}"
|
|
17
|
+
run write "gem: --no-rdoc --no-ri", :to => '.gemrc', :name => '.gemrc'
|
|
18
|
+
run gem 'bundler'
|
|
19
|
+
end
|
|
20
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
task :subtle, 'Install Subtle tiling window manager and associated fonts, themes, etc' do
|
|
2
|
+
sudo debconf 'ttf-mscorefonts-installer', 'msttcorefonts/accepted-mscorefonts-eula', 'boolean', true
|
|
3
|
+
sudo install [
|
|
4
|
+
'dmz-cursor-theme', # Mouse cursor theme
|
|
5
|
+
'elementary-icon-theme', # An icon theme
|
|
6
|
+
'feh', # Set background image/view pics/slideshow/etc
|
|
7
|
+
'gnome-screenshot', # Press Print Screen to take a screen shot of the desktop
|
|
8
|
+
'gnome-themes-standard', # Needed to theme GTK 3 apps
|
|
9
|
+
'lxappearance', # Set gtk themes, cursors and icons - Set to clearlooks
|
|
10
|
+
'pcmanfm', # Lightweight File manager
|
|
11
|
+
'rxvt-unicode', # Default Subtle console
|
|
12
|
+
'subtle', # Tiling window manager
|
|
13
|
+
'suckless-tools', # Includes slock - Locks screen. Password unlocks - no prompt. Can be used with xautolock
|
|
14
|
+
'ttf-ubuntu-font-family', # The new ubuntu font
|
|
15
|
+
'ttf-mscorefonts-installer', # Microsoft fonts
|
|
16
|
+
'xautolock', # Locks screen after idle
|
|
17
|
+
'xorg', # Basic X Windows Graphical Interface
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
sudo append 'inode/directory=pcmanfm.desktop', to: '.local/share/applications/mimeapps.list'
|
|
21
|
+
|
|
22
|
+
# Copy default subtle.rb file for easy modification
|
|
23
|
+
run mkdir '.local/share/subtle'
|
|
24
|
+
run copy '/etc/xdg/subtle/subtle.rb', '.local/share/subtle'
|
|
25
|
+
|
|
26
|
+
run append 'ck-launch-session subtle', to: '~/.xinitrc'
|
|
27
|
+
sudo append 'snd_mixer_oss', to: '/etc/modules'
|
|
28
|
+
end
|
|
29
|
+
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
task :shutdown_without_password, 'Ensure we can shutdown/reboot without needing a password for sudo' do
|
|
2
|
+
sudo append 'ALL ALL=NOPASSWD:/sbin/shutdown', :to => '/etc/sudoers.d/shutdown'
|
|
3
|
+
sudo append 'ALL ALL=NOPASSWD:/sbin/reboot', :to => '/etc/sudoers.d/shutdown'
|
|
4
|
+
sudo chmod 440, '/etc/sudoers.d/shutdown'
|
|
5
|
+
end
|
|
6
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
task :timezone, 'Set timezone from config.yml' do
|
|
2
|
+
sudo link '/etc/localtime', "/usr/share/zoneinfo/#{$conf.timezone}"
|
|
3
|
+
|
|
4
|
+
# Ensure UTC is used or not
|
|
5
|
+
if !$conf.clock_utc.nil?
|
|
6
|
+
options = {false => 'no', true => 'yes'}
|
|
7
|
+
sudo replace "UTC=#{options[!$conf.clock_utc]}", :with => "UTC=#{options[$conf.clock_utc]}", :in => '/etc/default/rcS'
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
task :virtualbox, 'Install VirtualBox' do
|
|
2
|
+
sudo install %w(dkms) # Ensures kernal modules are updated when upgrading virtual box
|
|
3
|
+
|
|
4
|
+
sudo add_ppa 'debfx/virtualbox', 'felix'
|
|
5
|
+
|
|
6
|
+
sudo install 'virtualbox'
|
|
7
|
+
sudo add :user => $conf.user, :to => 'vboxusers'
|
|
8
|
+
sudo append 'application/x-virtualbox-vbox-extpack=virtualbox.desktop', :to => '.local/share/applications/mimeapps.list'
|
|
9
|
+
sudo append 'application/x-virtualbox-ova=virtualbox.desktop', :to => '.local/share/applications/mimeapps.list'
|
|
10
|
+
end
|
|
11
|
+
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
task :virtualbox_guest, 'Installs VirtualBox Guest Additions and fixes piix4_smbus error' do
|
|
2
|
+
sudo add_ppa 'debfx/virtualbox', 'felix'
|
|
3
|
+
sudo install 'virtualbox-guest-additions'
|
|
4
|
+
sudo append 'blacklist i2c_piix4', to: '/etc/modprobe.d/blacklist.conf'
|
|
5
|
+
run append 'VBoxClient-all &', to: '.xinitrc' if $conf.autostart_vbox_client
|
|
6
|
+
end
|
|
7
|
+
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
task :webapps, 'Sets up Web apps in config/webapps.yml using app_server.conf.erb. Copies SSL certs.' do
|
|
2
|
+
sudo mkdir File.join($conf.webserver.path, $conf.webserver.servers_dir) if $conf.webserver.servers_dir
|
|
3
|
+
$conf.webapps.each do |app_name, app|
|
|
4
|
+
if $conf.environment == 'development'
|
|
5
|
+
run git_clone app.scm, :to => app.path, :branch => app.branch
|
|
6
|
+
bundle_command = $conf.ruby.gems_path =~ /^.rbenv/ ? "$HOME/.rbenv/bin/rbenv exec bundle" : "bundle"
|
|
7
|
+
bundle_command = "cd #{app.path} && #{bundle_command}"
|
|
8
|
+
run bundle_command, check_command("#{bundle_command} check")
|
|
9
|
+
run "#{bundle_command} --binstubs=.bin", check_dir("#{app.path}/.bin")
|
|
10
|
+
run mkdir "#{app.path}/.bin/safe" if $conf.bin_safe
|
|
11
|
+
else
|
|
12
|
+
%w(releases shared/config shared/system shared/log).each do |dir|
|
|
13
|
+
run mkdir File.join(app.path, dir)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
if app.ssl && File.exists?("certificates/#{app.ssl_crt}") && File.exists?("certificates/#{app.ssl_key}")
|
|
18
|
+
webserver_conf_path = File.join $conf.webserver.path, $conf.webserver.conf_path
|
|
19
|
+
sudo upload "certificates/#{app.ssl_crt}", "#{webserver_conf_path}/#{app.ssl_crt}"
|
|
20
|
+
sudo upload "certificates/#{app.ssl_key}", "#{webserver_conf_path}/#{app.ssl_key}"
|
|
21
|
+
sudo chmod '600', "#{webserver_conf_path}/#{app.ssl_key}"
|
|
22
|
+
end
|
|
23
|
+
conf_name = "#{app.name}.conf"
|
|
24
|
+
conf_path = File.join($conf.webserver.path, $conf.webserver.servers_dir, conf_name)
|
|
25
|
+
sudo create_from "#{$conf.webserver.name}/app_server.conf.erb", :settings => app, :to => conf_path
|
|
26
|
+
sudo mkdir "/var/log/#{$conf.webserver.name}"
|
|
27
|
+
|
|
28
|
+
run write_database_yml app if app.write_yml && $conf.environment != 'development'
|
|
29
|
+
sudo append "127.0.0.1 #{app.server_name}", :to => '/etc/hosts'
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
task :monit_delayed_job, 'Add monit config for each delayed_job app', :if => [:monit] do
|
|
34
|
+
sudo create_from 'monit/conf.d/delayed_job.erb', :to => '/etc/monit/conf.d/delayed_job'
|
|
35
|
+
end
|
|
36
|
+
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
package :load_machines
|
|
2
|
+
package :questions
|
|
3
|
+
|
|
4
|
+
package :dependencies
|
|
5
|
+
package :timezone
|
|
6
|
+
package :hosts
|
|
7
|
+
package :base
|
|
8
|
+
|
|
9
|
+
package :virtualbox_guest if $conf.machine.name == 'phil_desktop'
|
|
10
|
+
|
|
11
|
+
only :roles => :app do
|
|
12
|
+
package :monit unless $conf.environment == 'development'
|
|
13
|
+
package :dotfiles
|
|
14
|
+
package :git
|
|
15
|
+
package :rbenv
|
|
16
|
+
package :passenger
|
|
17
|
+
package :passenger_nginx
|
|
18
|
+
package :nginx
|
|
19
|
+
package :nginx_logrotate
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
only :roles => :db do
|
|
23
|
+
package :mysql
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
only :roles => :app do
|
|
27
|
+
package :webapps
|
|
28
|
+
package :postfix unless $conf.environment == 'development'
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
only :user => 'phil' do
|
|
32
|
+
package :sudo_mods
|
|
33
|
+
package :subtle
|
|
34
|
+
package :chrome
|
|
35
|
+
package :firefox
|
|
36
|
+
package :gedit
|
|
37
|
+
package :unison
|
|
38
|
+
package :abiword
|
|
39
|
+
package :gnumeric
|
|
40
|
+
package :file_roller
|
|
41
|
+
package :productivity
|
|
42
|
+
package :custom
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
package :finalise
|
|
46
|
+
|
|
47
|
+
package :save_machines
|
|
48
|
+
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
|
2
|
+
MIICATCCAWoCCQDpeSjLwR24MDANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJB
|
|
3
|
+
VTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0
|
|
4
|
+
cyBQdHkgTHRkMB4XDTEyMDUxMjE2Mzk0OVoXDTEzMDUxMjE2Mzk0OVowRTELMAkG
|
|
5
|
+
A1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0
|
|
6
|
+
IFdpZGdpdHMgUHR5IEx0ZDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA0+ik
|
|
7
|
+
UCFYH0l283N2Cca0ojdq1ttVauxLXL2JD1yZPAngFyu8NpHw2062B0Ah2TYLhrsn
|
|
8
|
+
MR3omzv2dVBsd+aydQFNYLHDbQqgQ372s3lnpFykpH3UG9TakrT9RloxjPGLhRpC
|
|
9
|
+
Xkbo881Ffb84OQHjJQvQS9/GhiWdOXlF7yKMxK8CAwEAATANBgkqhkiG9w0BAQUF
|
|
10
|
+
AAOBgQA6QarkZpqG1+ysR0v7Cmxajz4ifMGxPyogPiC53XsqvUahYh6Ky7+fGl4q
|
|
11
|
+
3ikgeGftxpWOa9atHS//cCGauG1KesywDn54pFg81+jfCUqMXYDOaRTm4KvFltmo
|
|
12
|
+
xtt410RLwocAG1jOjJX2zBgWfMhfyYH+7AeSDRNYremlHWyHZA==
|
|
13
|
+
-----END CERTIFICATE-----
|
|
14
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
-----BEGIN RSA PRIVATE KEY-----
|
|
2
|
+
MIICXAIBAAKBgQDT6KRQIVgfSXbzc3YJxrSiN2rW21Vq7EtcvYkPXJk8CeAXK7w2
|
|
3
|
+
kfDbTrYHQCHZNguGuycxHeibO/Z1UGx35rJ1AU1gscNtCqBDfvazeWekXKSkfdQb
|
|
4
|
+
1NqStP1GWjGM8YuFGkJeRujzzUV9vzg5AeMlC9BL38aGJZ05eUXvIozErwIDAQAB
|
|
5
|
+
AoGBAMkW+G4t5kDyZxXJWJcYYCubqSAwzVME3tMn7VuNhMBLosJ6N0YVodmLTQN+
|
|
6
|
+
YWCNf8yf5yYd+rDs6wkSg4wYePkCbR40kw0T3qU5nCIxIG817B375dG4I0Qjmzdw
|
|
7
|
+
FhsgDoXR09tKHd2aqDd0IiqNjqBcCY1J8vaGdI0Vw/FtbAsxAkEA+UEzRBbtF/oG
|
|
8
|
+
wzdIW4ggElNJDaVIUQ0GFdUcLOS94pLZ8EawiVJqF1dM/3cvfi7YNiyo/ctR+gx7
|
|
9
|
+
fwUso7OUeQJBANmktuhXDMXNiBLsHmMHg5KVRwEsiPWtf42FXwFE8Qz2ysSVDrv5
|
|
10
|
+
SlQ84M3PEBfyGnbQt5o2LlCkHIZUAtlaSGcCQAxZZZ/W/vI0KgecApK+YNBnnfP2
|
|
11
|
+
H2ocmhOU1muG/b1vBys3ZWG4WpdDdQYnMowu5/lvJwREAZDA85FsgTSvHgkCQArt
|
|
12
|
+
3Y1/SZHpR0sD9masquvCeUVS0jHcG4qkxueOabhn8Di873d7BkOCpxtOqZU6QB/1
|
|
13
|
+
TTL+Q4cjJpeMQnRdt0MCQA7rI1d9TPea84NDTR7QnL23AigqxOwLZDS0UVi7mMa6
|
|
14
|
+
eLTTyaPtqInApXmtF+gqso1+O2FVuSyirGKLldJCtmA=
|
|
15
|
+
-----END RSA PRIVATE KEY-----
|
|
16
|
+
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Base folder where webapps are installed for each user
|
|
2
|
+
# $conf.appsroot points to the current users root
|
|
3
|
+
appsroots:
|
|
4
|
+
phil: /home/phil/workspace
|
|
5
|
+
www: /home/www
|
|
6
|
+
|
|
7
|
+
# Adds VBoxClient-all to xinitrc (needed when using a Window Manager that does not start /etc/xdg/autostart/*.desktop such as subtle)
|
|
8
|
+
autostart_vbox_client: true
|
|
9
|
+
|
|
10
|
+
# Create .bin/safe folder in bundler controlled projects
|
|
11
|
+
# (https://twitter.com/#!/tpope/statuses/165631968996900865)
|
|
12
|
+
# The post recommends .git/safe but I find this confusing and suggest using .bin as this is where binstubs
|
|
13
|
+
# are configured (bin/ is the default for `bundler --binstubs` but bin/ is already used by gems that have one
|
|
14
|
+
# or more executables.)
|
|
15
|
+
bin_safe: true
|
|
16
|
+
|
|
17
|
+
# Set to false if your BIOS clock is set to localtime (e.g. you dual boot Windows)
|
|
18
|
+
# This will override whatever option was chosen when Ubuntu was installed
|
|
19
|
+
clock_utc: true
|
|
20
|
+
|
|
21
|
+
cloud:
|
|
22
|
+
provider: AWS
|
|
23
|
+
aws_access_key_id: 123
|
|
24
|
+
aws_secret_access_key: 456
|
|
25
|
+
|
|
26
|
+
# IP hosts. These are added to /etc/hosts by the hosts task in the base package
|
|
27
|
+
# They are also added to known hosts but the host must be accessible at this point
|
|
28
|
+
# Note:
|
|
29
|
+
# localhost and local domain hosts are added by base package
|
|
30
|
+
# app URLS are added by webapps package
|
|
31
|
+
# hosts without addresses are only added to known_hosts file and not to /etc/hosts
|
|
32
|
+
hosts:
|
|
33
|
+
github.com:
|
|
34
|
+
gist.github.com:
|
|
35
|
+
server: 192.168.1.4
|
|
36
|
+
host: 192.168.56.1
|
|
37
|
+
|
|
38
|
+
login_theme: dark
|
|
39
|
+
|
|
40
|
+
mail:
|
|
41
|
+
domain: example.com
|
|
42
|
+
address: mail
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
monit:
|
|
46
|
+
mailto: admin@example.com
|
|
47
|
+
check:
|
|
48
|
+
paths: /
|
|
49
|
+
webserver:
|
|
50
|
+
address: 192.168.1.0/255.255.255.0
|
|
51
|
+
username: admin
|
|
52
|
+
password: monit
|
|
53
|
+
|
|
54
|
+
# Latest version including preferred nginx version:
|
|
55
|
+
# https://github.com/FooBarWidget/passenger/blob/master/NEWS
|
|
56
|
+
passenger:
|
|
57
|
+
version: 3.0.11
|
|
58
|
+
# Set in passenger.rb package
|
|
59
|
+
# root: Points to passenger path in rubygems
|
|
60
|
+
# ruby: Points to the ruby executable in rbenv, rvm, compiled or installed by your package manager
|
|
61
|
+
|
|
62
|
+
# Uncomment to use RVM
|
|
63
|
+
# Ruby will be installed using RVM
|
|
64
|
+
# Passenger will be installed using rvmsudo
|
|
65
|
+
#rvm:
|
|
66
|
+
# url: https://rvm.beginrescueend.com/install/rvm
|
|
67
|
+
# version: 1.9.2
|
|
68
|
+
|
|
69
|
+
ruby:
|
|
70
|
+
version: 1.9.2
|
|
71
|
+
full_version: 1.9.2-p290
|
|
72
|
+
# gems_path: '.rvm/gems/1.9.2-p290/@global/gems'
|
|
73
|
+
# executable: .rvm/wrappers/1.9.2-p290@global/ruby
|
|
74
|
+
gems_path: .rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems
|
|
75
|
+
executable: .rbenv/versions/1.9.2-p290/bin/ruby
|
|
76
|
+
|
|
77
|
+
set_rails_env_for:
|
|
78
|
+
- qa
|
|
79
|
+
- staging
|
|
80
|
+
- production
|
|
81
|
+
|
|
82
|
+
timezone: GB
|
|
83
|
+
|
|
84
|
+
# Where different packages exist for open and non open source
|
|
85
|
+
# setting this to true prefers opensource - Currently only
|
|
86
|
+
# used by chrome/chromium
|
|
87
|
+
use_opensource: true
|
|
88
|
+
|
|
89
|
+
# Settings used in webserver packages such as nginx and apache
|
|
90
|
+
webserver:
|
|
91
|
+
name: nginx
|
|
92
|
+
modules: --with-http_ssl_module
|
|
93
|
+
version: 1.0.11
|
|
94
|
+
url: http://nginx.org/download/nginx-1.0.11.tar.gz
|
|
95
|
+
src_path: /usr/local/src/nginx-1.0.11
|
|
96
|
+
path: /usr/local/nginx
|
|
97
|
+
servers_dir: conf/servers
|
|
98
|
+
|