salted-rails 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +65 -20
- data/init.sh +64 -0
- data/lib/salted-rails.rb +4 -6
- data/lib/salted-rails/capistrano_helper.rb +106 -0
- data/lib/salted-rails/cloud_vbguest_installer.rb +14 -0
- data/lib/salted-rails/config.rb +212 -0
- data/lib/salted-rails/helper_base.rb +90 -0
- data/lib/salted-rails/vagrant_helper.rb +159 -0
- data/lib/salted-rails/version.rb +3 -0
- data/lib/salted_rails_base.rb +6 -0
- data/pillar/capistrano/top.sls +1 -1
- data/pillar/common.sls +5 -0
- data/pillar/vagrant/top.sls +1 -1
- data/salt/bin/change_mirror.sh +29 -20
- data/salt/bin/fix_hostname.sh +6 -0
- data/salt/bin/provision +37 -0
- data/salt/capistrano/deploy_requirements.sls +5 -0
- data/salt/capistrano/minion +8 -4
- data/salt/capistrano/top.sls +1 -5
- data/salt/ci/cruisecontrolrb.sls +72 -0
- data/salt/ci/teamcity/etc/init.d/teamcity +17 -0
- data/salt/ci/teamcity/init.sls +58 -0
- data/salt/databases/client.sls +18 -0
- data/salt/{common.sls → databases/init.sls} +1 -16
- data/salt/databases/phpmyadmin/etc/nginx/{sites-available → admin.d}/phpmyadmin.conf +1 -1
- data/salt/databases/phpmyadmin/init.sls +2 -11
- data/salt/databases/server.sls +19 -0
- data/salt/editors/gvim.sls +5 -0
- data/salt/editors/rubymine.sls +51 -0
- data/salt/gui/init.sls +3 -0
- data/salt/gui/lxde.sls +5 -0
- data/salt/gui/x2go.sls +23 -0
- data/salt/lang/java/etc/profile.d/java.sh +2 -0
- data/salt/lang/java/init.sls +48 -0
- data/salt/lang/php/composer.sls +0 -3
- data/salt/lang/ruby.sls +3 -3
- data/salt/lang/ruby.sls.bak +3 -3
- data/salt/railsapp/gems.sls +16 -3
- data/salt/railsapp/init.sls +1 -0
- data/salt/railsapp/mysql_database.sls +11 -6
- data/salt/salt/minion/init.sls +19 -18
- data/salt/vagrant/minion +8 -4
- data/salt/vagrant/minion.sls +4 -5
- data/salt/vagrant/top.sls +32 -6
- data/salt/www/admin/etc/nginx/nginx.conf +53 -0
- data/salt/{databases/phpmyadmin → www/admin}/etc/nginx/sites-available/.gitignore +0 -0
- data/salt/www/admin/etc/nginx/sites-available/phpmyadmin.conf +7 -0
- data/salt/www/admin/init.sls +31 -0
- data/salt/www/nginx/init.sls +17 -4
- data/salt/www/users.sls +4 -0
- data/salted-rails.gemspec +1 -1
- metadata +30 -13
- data/lib/salted_rails/capistrano.rb +0 -8
- data/lib/salted_rails/vagrant_helper.rb +0 -169
- data/lib/salted_rails/version.rb +0 -5
- data/salt/capistrano.sls +0 -0
- data/salt/develop/init.sls +0 -3
- data/salt/echo_pillar.sls +0 -9
- data/salt/run-standalone +0 -3
- data/salt/vagrant.sls +0 -0
@@ -0,0 +1,90 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
#
|
4
|
+
|
5
|
+
require 'erb'
|
6
|
+
require 'yaml'
|
7
|
+
require 'fileutils'
|
8
|
+
|
9
|
+
module SaltedRails
|
10
|
+
class HelperBase
|
11
|
+
|
12
|
+
attr_accessor :config
|
13
|
+
|
14
|
+
def initialize(config)
|
15
|
+
@config = config
|
16
|
+
@config.logger.info "SaltedRails: Helper created with config.rails_root = #{@config.rails_root}"
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
# Add ruby version and gemfiles
|
22
|
+
|
23
|
+
# def create_empty_custom_files
|
24
|
+
# @config.logger.info 'SaltedRails: Checking stubbed custom files exist'
|
25
|
+
#
|
26
|
+
# # Create custom files
|
27
|
+
# [ 'pillar/vagrant', 'pillar/capistrano', 'salt/vagrant', 'salt/capistrano'].each do |custom|
|
28
|
+
# file = @config.rails_root + 'config/' + custom + '.sls'
|
29
|
+
# dir = File.dirname(file)
|
30
|
+
# unless File.directory? dir
|
31
|
+
# FileUtils.mkdir_p dir
|
32
|
+
# end
|
33
|
+
# unless File.exists? file
|
34
|
+
# @config.logger.info "SaltedRails: Creating empty #{file}"
|
35
|
+
# File.open(file, 'w') do |f_out|
|
36
|
+
# f_out.puts '# Custom data'
|
37
|
+
# end
|
38
|
+
# end
|
39
|
+
# end
|
40
|
+
# end
|
41
|
+
|
42
|
+
def pillarize_application_configuration
|
43
|
+
@config.logger.info 'SaltedRails: Creating pillar application data'
|
44
|
+
|
45
|
+
# Destination
|
46
|
+
salt_dir = @config.rails_root + 'tmp/salt/'
|
47
|
+
FileUtils.rm_rf salt_dir if File.directory? salt_dir
|
48
|
+
FileUtils.mkdir_p salt_dir unless File.directory? salt_dir
|
49
|
+
pillar_dir = @config.rails_root + 'tmp/pillar/'
|
50
|
+
FileUtils.rm_rf pillar_dir if File.directory? pillar_dir
|
51
|
+
FileUtils.mkdir_p pillar_dir unless File.directory? pillar_dir
|
52
|
+
pillar_app_file = pillar_dir + 'railsapp.sls'
|
53
|
+
@config.files.each do |f|
|
54
|
+
basename = File.basename(f)
|
55
|
+
dest = salt_dir + "files/" + basename
|
56
|
+
dir = File.dirname(dest)
|
57
|
+
unless File.directory? dir
|
58
|
+
FileUtils.mkdir_p dir
|
59
|
+
end
|
60
|
+
FileUtils.cp(@config.rails_root + f, dest)
|
61
|
+
end
|
62
|
+
@config.copy_from_home.each do |f|
|
63
|
+
dest = salt_dir + "home/" + f
|
64
|
+
dir = File.dirname(dest)
|
65
|
+
unless File.directory? dir
|
66
|
+
FileUtils.mkdir_p dir
|
67
|
+
end
|
68
|
+
if !File.exist?(dest) or (File.mtime(ENV['HOME'] + '/' + f) > File.mtime(dest))
|
69
|
+
@config.logger.info "SaltedRails: Copying #{f} to #{dest}"
|
70
|
+
FileUtils.cp_r(ENV['HOME'] + '/' + f, dest)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
%w{ authorized_keys known_hosts }.each do |f|
|
74
|
+
file = salt_dir + "home/.ssh/" + f
|
75
|
+
FileUtils.mv(file, file + '.from_home') if File.exist? file
|
76
|
+
end
|
77
|
+
File.open(pillar_app_file, 'w') do |f_out|
|
78
|
+
if_command = 'if'
|
79
|
+
@config.machines.each do |machine_config|
|
80
|
+
f_out.puts "{% #{if_command} grains['fqdn'] == '#{machine_config.hostname}' %}"
|
81
|
+
if_command = 'elif'
|
82
|
+
f_out.puts machine_config.to_yaml
|
83
|
+
end
|
84
|
+
f_out.puts "{% else %}" unless @config.machines.empty?
|
85
|
+
f_out.puts @config.to_yaml
|
86
|
+
f_out.puts "{% endif %}" unless @config.machines.empty?
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,159 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
#
|
4
|
+
|
5
|
+
require "salted-rails/helper_base"
|
6
|
+
|
7
|
+
module SaltedRails
|
8
|
+
class VagrantHelper < HelperBase
|
9
|
+
|
10
|
+
def initialize(config)
|
11
|
+
super(config)
|
12
|
+
end
|
13
|
+
|
14
|
+
def configure_vagrant(vagrant_config)
|
15
|
+
port_offset = 0
|
16
|
+
configure_virtualbox(vagrant_config)
|
17
|
+
configure_vbguest(vagrant_config)
|
18
|
+
configure_ubuntu_mirror(vagrant_config)
|
19
|
+
configure_digital_ocean(vagrant_config)
|
20
|
+
if @config.machines.empty?
|
21
|
+
configure_gui(vagrant_config) if @config.gui?
|
22
|
+
configure_hostname(vagrant_config)
|
23
|
+
configure_ports(vagrant_config, port_offset)
|
24
|
+
configure_memory(vagrant_config, @config.memory)
|
25
|
+
else
|
26
|
+
@config.machines.each do |machine_config|
|
27
|
+
machine_config.logger.info "Configuring machine #{machine_config.machine}, hostname: #{machine_config.hostname}"
|
28
|
+
vagrant_config.vm.define(machine_config.machine.to_sym) do |vagrant_vm_config|
|
29
|
+
configure_gui(vagrant_vm_config) if @config.gui?
|
30
|
+
configure_hostname(vagrant_vm_config, machine_config)
|
31
|
+
configure_ports(vagrant_vm_config, port_offset, machine_config)
|
32
|
+
configure_memory(vagrant_vm_config, machine_config.memory, machine_config)
|
33
|
+
port_offset += 1
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
# create_empty_custom_files
|
38
|
+
pillarize_application_configuration
|
39
|
+
fix_hostname(vagrant_config)
|
40
|
+
configure_salt(vagrant_config)
|
41
|
+
end
|
42
|
+
|
43
|
+
def configure_ubuntu_mirror(vagrant_config, config = @config)
|
44
|
+
config.logger.info "Configuring ubuntu mirror (#{config.mirror})"
|
45
|
+
vagrant_config.vm.provision "shell" do |s|
|
46
|
+
s.path = config.salt_root + 'salt/bin/change_mirror.sh'
|
47
|
+
s.args = "'#{config.mirror}'"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def configure_hostname(vagrant_config, config = @config)
|
52
|
+
config.logger.info "Configuring hostname (#{config.hostname})"
|
53
|
+
vagrant_config.vm.hostname = config.hostname
|
54
|
+
end
|
55
|
+
|
56
|
+
def fix_hostname(vagrant_config, config = @config)
|
57
|
+
vagrant_config.vm.provision "shell" do |s|
|
58
|
+
s.path = config.salt_root + 'salt/bin/fix_hostname.sh'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def configure_vbguest(vagrant_config, config = @config)
|
63
|
+
begin
|
64
|
+
require 'vagrant-vbguest'
|
65
|
+
require 'salted-rails/cloud_vbguest_installer'
|
66
|
+
vagrant_config.vbguest.installer = SaltedRails::CloudVbguestInstaller
|
67
|
+
vagrant_config.vbguest.auto_update = false
|
68
|
+
config.logger.info 'Configured vbguest installer'
|
69
|
+
rescue LoadError
|
70
|
+
config.logger.info 'Skipping vbguest (plugin not available)'
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
def configure_virtualbox(vagrant_config, config = @config)
|
76
|
+
config.logger.info 'Configuring virtualbox box (UbuntuCloud_12.04_32bit)'
|
77
|
+
vagrant_config.vm.box = 'UbuntuCloud_12.04_32bit'
|
78
|
+
vagrant_config.vm.box_url = 'http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-vagrant-i386-disk1.box'
|
79
|
+
end
|
80
|
+
|
81
|
+
def configure_digital_ocean(vagrant_config, config = @config)
|
82
|
+
config.logger.info "Configuring digital ocean provider (#{config.machine})"
|
83
|
+
vagrant_config.vm.provider :digital_ocean do |provider, override|
|
84
|
+
override.ssh.username = 'vagrant'
|
85
|
+
override.vm.box = 'digital_ocean'
|
86
|
+
override.vm.box_url = 'https://github.com/smdahlen/vagrant-digitalocean/raw/master/box/digital_ocean.box'
|
87
|
+
provider.image = 'Ubuntu 12.04 x32'
|
88
|
+
provider.region = config.region
|
89
|
+
provider.ca_path = config.ca_path if config.ca_path
|
90
|
+
override.vm.synced_folder '.', '/vagrant', :disabled => true if config.disable_vagrant_sync
|
91
|
+
if config.private_key_path
|
92
|
+
override.ssh.private_key_path = config.private_key_path
|
93
|
+
private_key_name = 'Vagrant ' + config.private_key_path.sub(/~\//, '').sub(/\.ssh\//, '').sub(/^id_/, '').gsub(/\W+/, ' ')
|
94
|
+
provider.ssh_key_name = private_key_name.strip
|
95
|
+
end
|
96
|
+
override.ssh.forward_agent = config.forward_agent
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def configure_gui(vagrant_config)
|
101
|
+
vagrant_config.vm.provider "virtualbox" do |v|
|
102
|
+
v.gui = true
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def configure_salt(vagrant_config, config = @config)
|
107
|
+
config.logger.info "Configuring saltstack (#{config.machine})"
|
108
|
+
vagrant_config.vm.synced_folder config.rails_root + 'config/salt/', '/srv/salt/config/'
|
109
|
+
vagrant_config.vm.synced_folder config.rails_root + 'config/pillar/', '/srv/pillar/config/'
|
110
|
+
vagrant_config.vm.synced_folder config.rails_root + 'tmp/salt/', '/srv/salt/generated/'
|
111
|
+
vagrant_config.vm.synced_folder config.rails_root + 'tmp/pillar/', '/srv/pillar/generated/'
|
112
|
+
vagrant_config.vm.synced_folder config.salt_root + 'salt/', '/srv/salt/salted-rails/'
|
113
|
+
vagrant_config.vm.synced_folder config.salt_root + 'pillar/', '/srv/pillar/salted-rails/'
|
114
|
+
# Bootstrap salt
|
115
|
+
## config.vm.provision :shell, :inline => 'salt-call --version || wget -O - http://bootstrap.saltstack.org | sudo sh'
|
116
|
+
# Provisioning #2: masterless highstate call
|
117
|
+
vagrant_config.vm.provision :salt do |salt|
|
118
|
+
config.logger.info 'Configuring salt provisioner'
|
119
|
+
minion_file = config.rails_root + 'config/salt/vagrant/minion'
|
120
|
+
minion_file = config.salt_root + 'salt/vagrant/minion' unless File.exist?(minion_file)
|
121
|
+
salt.minion_config = minion_file
|
122
|
+
salt.run_highstate = true
|
123
|
+
salt.verbose = !! config.logger
|
124
|
+
# current package (salt-minion_0.17.0.1-1precise_all.deb) in ppa:saltstack/salt is broken as of Oct 10 2013:
|
125
|
+
# Unable to run multiple states and returns unhelpfull messages about list and get
|
126
|
+
salt.install_type = 'git'
|
127
|
+
salt.install_args = 'v0.16.4'
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def configure_ports(vagrant_config, port_offset=0, config = @config)
|
132
|
+
config.ports.each do |port|
|
133
|
+
host_port = port_offset + port + (port < 3000 ? 3000 : 0)
|
134
|
+
vagrant_config.vm.network :forwarded_port, :guest => port, :host => host_port, auto_correct: true
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def configure_memory(vagrant_config, memory, config = @config)
|
139
|
+
config.logger.info "Configuring memory = %d" % config.memory.to_i
|
140
|
+
vagrant_config.vm.provider :virtual_box do |vb|
|
141
|
+
vb.customize ["modifyvm", :id, "--memory", config.memory]
|
142
|
+
end
|
143
|
+
vagrant_config.vm.provider :digital_ocean do |provider, override|
|
144
|
+
# configure to closest value
|
145
|
+
if config.memory >= 3000
|
146
|
+
# 32 bit linux doesn't use anything more than this anyway
|
147
|
+
provider.size = '4GB'
|
148
|
+
elsif config.memory >= 1500
|
149
|
+
provider.size = '2GB'
|
150
|
+
elsif config.memory >= 750
|
151
|
+
provider.size = '1GB'
|
152
|
+
else
|
153
|
+
provider.size = '512MB'
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
end
|
data/lib/salted_rails_base.rb
CHANGED
data/pillar/capistrano/top.sls
CHANGED
data/pillar/common.sls
CHANGED
data/pillar/vagrant/top.sls
CHANGED
data/salt/bin/change_mirror.sh
CHANGED
@@ -3,25 +3,34 @@
|
|
3
3
|
# Changes from the default to given mirror (unable to do it more than once)
|
4
4
|
|
5
5
|
case "$1" in
|
6
|
-
|
7
|
-
echo "
|
8
|
-
exec sed -i.original -e 's#http://[archivesecurity]*.ubuntu.com/ubuntu#http://'"$1"'.archive.ubuntu.com/ubuntu/#' /etc/apt/sources.list
|
9
|
-
;;
|
10
|
-
mirror)
|
11
|
-
echo "Configuring automatic selection of mirror"
|
12
|
-
exec sed -i.original -e 's#http://[archivesecurity]*.ubuntu.com/ubuntu#mirror://mirrors.ubuntu.com/mirrors.txt#' /etc/apt/sources.list
|
13
|
-
;;
|
14
|
-
internode)
|
15
|
-
echo "Configuring mirror for ISP: $1"
|
16
|
-
exec sed -i.original -e 's#http://[archivesecurity]*.ubuntu.com/ubuntu#http://mirror.internode.on.net/pub/ubuntu/ubuntu/#' /etc/apt/sources.list
|
17
|
-
;;
|
18
|
-
[hmf]*://*ubuntu*)
|
19
|
-
echo "Configuring mirror for $1"
|
20
|
-
exec sed -i.original -e 's#http://[archivesecurity]*.ubuntu.com/ubuntu#'"$1"'#' /etc/apt/sources.list
|
21
|
-
;;
|
22
|
-
*)
|
23
|
-
echo Invalid mirror ignored! >&2
|
24
|
-
exit 1
|
6
|
+
''|-h)
|
7
|
+
exec echo "usage: $0 country|mirror|auto|internode|url"
|
25
8
|
;;
|
26
9
|
esac
|
27
|
-
|
10
|
+
if grep 'http://archive.ubuntu.com/ubuntu' /etc/apt/sources.list > /dev/null; then
|
11
|
+
case "$1" in
|
12
|
+
[a-z][a-z]|usa)
|
13
|
+
echo "Configuring mirror for region: $1"
|
14
|
+
exec sed -i.original -e 's#http://[archivesecurity]*.ubuntu.com/ubuntu#http://'"$1"'.archive.ubuntu.com/ubuntu/#' /etc/apt/sources.list
|
15
|
+
;;
|
16
|
+
mirror|auto)
|
17
|
+
echo "Configuring automatic selection of mirror"
|
18
|
+
exec sed -i.original -e 's#http://[archivesecurity]*.ubuntu.com/ubuntu#mirror://mirrors.ubuntu.com/mirrors.txt#' /etc/apt/sources.list
|
19
|
+
;;
|
20
|
+
internode)
|
21
|
+
echo "Configuring mirror for ISP: $1"
|
22
|
+
exec sed -i.original -e 's#http://[archivesecurity]*.ubuntu.com/ubuntu#http://mirror.internode.on.net/pub/ubuntu/ubuntu/#' /etc/apt/sources.list
|
23
|
+
;;
|
24
|
+
[hmf]*://*ubuntu*)
|
25
|
+
echo "Configuring mirror for $1"
|
26
|
+
exec sed -i.original -e 's#http://[archivesecurity]*.ubuntu.com/ubuntu#'"$1"'#' /etc/apt/sources.list
|
27
|
+
;;
|
28
|
+
*)
|
29
|
+
echo "Invalid mirror ($1) ignored!" >&2
|
30
|
+
exit 1
|
31
|
+
;;
|
32
|
+
esac
|
33
|
+
else
|
34
|
+
echo "/etc/apt/sources.list has already been changed (leaving as is)"
|
35
|
+
fi
|
36
|
+
exit 0
|
data/salt/bin/provision
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
case "$1" in
|
4
|
+
run)
|
5
|
+
shift
|
6
|
+
case "$#" in
|
7
|
+
0)
|
8
|
+
echo "Running all states ..."
|
9
|
+
sudo salt-call saltutil.sync_all
|
10
|
+
sudo salt-call state.highstate
|
11
|
+
;;
|
12
|
+
*)
|
13
|
+
for file; do
|
14
|
+
echo "Running $file ..."
|
15
|
+
sudo salt-call state.sls "$file"
|
16
|
+
done
|
17
|
+
;;
|
18
|
+
esac
|
19
|
+
;;
|
20
|
+
grains)
|
21
|
+
sudo salt-call grains.items
|
22
|
+
;;
|
23
|
+
pillar)
|
24
|
+
sudo salt-call pillar.items
|
25
|
+
;;
|
26
|
+
packages)
|
27
|
+
dpkg --get-selections | sed -n 's/\s\s*install//p'
|
28
|
+
;;
|
29
|
+
install|remove|purge|update|upgrade|clean|autoremove)
|
30
|
+
sudo apt-get "$@"
|
31
|
+
;;
|
32
|
+
*)
|
33
|
+
echo "usage: $0 grains|pillar|run [state]|packages|install package|remove package|purge package|autoclean|autoremove\n"
|
34
|
+
;;
|
35
|
+
esac
|
36
|
+
|
37
|
+
|
data/salt/capistrano/minion
CHANGED
@@ -5,10 +5,14 @@ state_auto_order: True
|
|
5
5
|
|
6
6
|
file_roots:
|
7
7
|
base:
|
8
|
-
- /srv/salt/capistrano
|
9
|
-
- /srv/salt
|
8
|
+
- /srv/salt/config/capistrano
|
9
|
+
- /srv/salt/salted-rails/capistrano
|
10
|
+
- /srv/salt/salted-rails
|
11
|
+
- /srv/salt/generated
|
10
12
|
|
11
13
|
pillar_roots:
|
12
14
|
base:
|
13
|
-
- /srv/pillar/capistrano
|
14
|
-
- /srv/pillar
|
15
|
+
- /srv/pillar/config/capistrano
|
16
|
+
- /srv/pillar/salted-rails/capistrano
|
17
|
+
- /srv/pillar/salted-rails
|
18
|
+
- /srv/pillar/generated
|
data/salt/capistrano/top.sls
CHANGED
@@ -0,0 +1,72 @@
|
|
1
|
+
include:
|
2
|
+
- lang.ruby
|
3
|
+
|
4
|
+
{{ pillar['homedir'] }}/local:
|
5
|
+
file.directory:
|
6
|
+
- makedirs: True
|
7
|
+
- user: {{ pillar['username'] }}
|
8
|
+
- group: {{ pillar['username'] }}
|
9
|
+
|
10
|
+
cruisecontrolrb-install:
|
11
|
+
git.latest:
|
12
|
+
- name: https://github.com/thoughtworks/cruisecontrol.rb
|
13
|
+
- target: {{ pillar['homedir'] }}/local/cruisecontrol.rb
|
14
|
+
- runas: {{ pillar['username'] }}
|
15
|
+
- group: {{ pillar['username'] }}
|
16
|
+
- require:
|
17
|
+
- file.directory: {{ pillar['homedir'] }}/local
|
18
|
+
cmd.run:
|
19
|
+
# Run twice if first fails (weirdness with installing ruby-debug)
|
20
|
+
- name: {{ pillar['homedir'] }}/.rbenv/shims/bundle install || {{ pillar['homedir'] }}/.rbenv/shims/bundle install
|
21
|
+
- cwd: {{ pillar['homedir'] }}/local/cruisecontrol.rb
|
22
|
+
- user: {{ pillar['username'] }}
|
23
|
+
- group: {{ pillar['username'] }}
|
24
|
+
- watch:
|
25
|
+
- git: cruisecontrolrb-install
|
26
|
+
|
27
|
+
cruisecontrolrb-create-service:
|
28
|
+
cmd.run:
|
29
|
+
- name: cp -f {{ pillar['homedir'] }}/local/cruisecontrol.rb/daemon/cruise /etc/init.d/cruise && chmod +x /etc/init.d/cruise
|
30
|
+
- watch:
|
31
|
+
- cmd: cruisecontrolrb-install
|
32
|
+
|
33
|
+
cruisecontrolrb-fix-user:
|
34
|
+
file.sed:
|
35
|
+
- name: /etc/init.d/cruise
|
36
|
+
- before: CRUISE_USER = .*
|
37
|
+
- after: CRUISE_USER='{{ pillar['username'] }}'
|
38
|
+
- limit: CRUISE_USER =
|
39
|
+
- watch:
|
40
|
+
- cmd: cruisecontrolrb-create-service
|
41
|
+
|
42
|
+
cruisecontrolrb-fix-home:
|
43
|
+
file.sed:
|
44
|
+
- name: /etc/init.d/cruise
|
45
|
+
- before: CRUISE_HOME = .*
|
46
|
+
- after: CRUISE_HOME='{{ pillar['homedir'] }}/local/cruisecontrol.rb'
|
47
|
+
- limit: CRUISE_HOME =
|
48
|
+
- watch:
|
49
|
+
- cmd: cruisecontrolrb-create-service
|
50
|
+
|
51
|
+
cruisecontrolrb-fix-shebang:
|
52
|
+
file.sed:
|
53
|
+
- name: /etc/init.d/cruise
|
54
|
+
- before: '#!/usr/bin/env.*'
|
55
|
+
- after: '#!{{ pillar['homedir'] }}/.rbenv/shims/ruby'
|
56
|
+
- watch:
|
57
|
+
- cmd: cruisecontrolrb-create-service
|
58
|
+
|
59
|
+
cruisecontrolrb-register-service:
|
60
|
+
cmd.run:
|
61
|
+
- name: update-rc.d cruise defaults
|
62
|
+
- watch:
|
63
|
+
- file.sed: cruisecontrolrb-fix-home
|
64
|
+
- file.sed: cruisecontrolrb-fix-user
|
65
|
+
- file.sed: cruisecontrolrb-fix-shebang
|
66
|
+
service.running:
|
67
|
+
- name: cruise
|
68
|
+
- watch:
|
69
|
+
- cmd: cruisecontrolrb-register-service
|
70
|
+
- require:
|
71
|
+
- sls: lang.ruby
|
72
|
+
|