caterer 0.11.0 → 0.11.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/Vagrantfile +6 -2
- data/lib/caterer/action/server.rb +1 -0
- data/lib/caterer/action/server/platform.rb +14 -0
- data/lib/caterer/actions.rb +5 -0
- data/lib/caterer/communication/rsync.rb +1 -1
- data/lib/caterer/config/provisioner/chef_solo.rb +1 -1
- data/lib/caterer/provisioner/chef_solo.rb +10 -10
- data/lib/caterer/server.rb +23 -0
- data/lib/caterer/util.rb +1 -0
- data/lib/caterer/util/shell.rb +41 -0
- data/lib/caterer/version.rb +1 -1
- data/lib/templates/provisioner/chef_solo/bootstrap.sh +34 -5
- data/lib/templates/provisioner/chef_solo/bootstrap/debian.sh +11 -0
- data/lib/templates/provisioner/chef_solo/bootstrap/el.sh +11 -0
- data/lib/templates/provisioner/chef_solo/bootstrap/fedora.sh +11 -0
- data/lib/templates/provisioner/chef_solo/bootstrap/sles.sh +11 -0
- data/lib/templates/provisioner/chef_solo/bootstrap/smartos.sh +6 -0
- data/lib/templates/provisioner/chef_solo/bootstrap/suse.sh +11 -0
- data/lib/templates/provisioner/chef_solo/bootstrap/ubuntu.sh +11 -0
- data/lib/templates/server/platform.sh +48 -0
- metadata +14 -4
data/Vagrantfile
CHANGED
@@ -3,8 +3,12 @@
|
|
3
3
|
Vagrant.configure("2") do |config|
|
4
4
|
|
5
5
|
# ubuntu
|
6
|
-
config.vm.box = 'precise'
|
7
|
-
config.vm.box_url = 'http://files.vagrantup.com/precise64.box'
|
6
|
+
# config.vm.box = 'precise'
|
7
|
+
# config.vm.box_url = 'http://files.vagrantup.com/precise64.box'
|
8
|
+
|
9
|
+
# centos
|
10
|
+
config.vm.box = 'pagoda_cent6_minimal'
|
11
|
+
config.vm.box_url = 'https://s3.amazonaws.com/vagrant.pagodabox.com/boxes/centos-6.4-x86_64-minimal.box'
|
8
12
|
|
9
13
|
config.vm.provider "virtualbox" do |v|
|
10
14
|
v.customize ["modifyvm", :id, "--cpus", "2", "--memory", "1024", "--cpuexecutioncap", "75"]
|
@@ -2,6 +2,7 @@ module Caterer
|
|
2
2
|
module Action
|
3
3
|
module Server
|
4
4
|
autoload :Lock, 'caterer/action/server/lock'
|
5
|
+
autoload :Platform, 'caterer/action/server/platform'
|
5
6
|
autoload :Reboot, 'caterer/action/server/reboot'
|
6
7
|
autoload :Validate, 'caterer/action/server/validate'
|
7
8
|
autoload :Unlock, 'caterer/action/server/unlock'
|
data/lib/caterer/actions.rb
CHANGED
@@ -29,6 +29,7 @@ Caterer.actions.register(:bootstrap) do
|
|
29
29
|
Vli::Action::Builder.new do
|
30
30
|
use Caterer::Action::Environment::Setup
|
31
31
|
use Caterer.actions.get(:validate)
|
32
|
+
use Caterer::Action::Server::Platform
|
32
33
|
use Caterer::Action::Provisioner::Load
|
33
34
|
use Caterer::Action::Provisioner::Prepare
|
34
35
|
use Caterer::Action::Server::Lock
|
@@ -43,6 +44,7 @@ Caterer.actions.register(:provision) do
|
|
43
44
|
Vli::Action::Builder.new do
|
44
45
|
use Caterer::Action::Environment::Setup
|
45
46
|
use Caterer.actions.get(:validate)
|
47
|
+
use Caterer::Action::Server::Platform
|
46
48
|
use Caterer::Action::Provisioner::Load
|
47
49
|
use Caterer::Action::Provisioner::Prepare
|
48
50
|
use Caterer::Action::Provisioner::Validate::Bootstrapped
|
@@ -57,6 +59,7 @@ Caterer.actions.register(:up) do
|
|
57
59
|
Vli::Action::Builder.new do
|
58
60
|
use Caterer::Action::Environment::Setup
|
59
61
|
use Caterer.actions.get(:validate)
|
62
|
+
use Caterer::Action::Server::Platform
|
60
63
|
use Caterer::Action::Provisioner::Load
|
61
64
|
use Caterer::Action::Provisioner::Prepare
|
62
65
|
use Caterer::Action::Server::Lock
|
@@ -72,6 +75,7 @@ Caterer.actions.register(:reboot) do
|
|
72
75
|
Vli::Action::Builder.new do
|
73
76
|
use Caterer::Action::Environment::Setup
|
74
77
|
use Caterer::Action::Server::Validate::SSH
|
78
|
+
use Caterer::Action::Server::Platform
|
75
79
|
use Caterer::Action::Server::Reboot
|
76
80
|
end
|
77
81
|
end
|
@@ -80,6 +84,7 @@ Caterer.actions.register(:clean) do
|
|
80
84
|
Vli::Action::Builder.new do
|
81
85
|
use Caterer::Action::Environment::Setup
|
82
86
|
use Caterer.actions.get(:validate)
|
87
|
+
use Caterer::Action::Server::Platform
|
83
88
|
use Caterer::Action::Provisioner::Load
|
84
89
|
use Caterer::Action::Provisioner::Uninstall
|
85
90
|
end
|
@@ -5,7 +5,7 @@ module Caterer
|
|
5
5
|
attr_accessor :dest_dir, :run_list, :json, :cookbooks_path, :roles_path, :data_bags_path, :bootstrap_scripts
|
6
6
|
|
7
7
|
def initialize
|
8
|
-
@dest_dir = '/opt/
|
8
|
+
@dest_dir = '/opt/cater/chef_solo'
|
9
9
|
@run_list = []
|
10
10
|
@json = {}
|
11
11
|
@cookbooks_path = ['cookbooks']
|
@@ -8,6 +8,8 @@ module Caterer
|
|
8
8
|
module Provisioner
|
9
9
|
class ChefSolo < Base
|
10
10
|
|
11
|
+
include Util::Shell
|
12
|
+
|
11
13
|
attr_reader :run_list
|
12
14
|
attr_accessor :dest_dir, :json, :cookbooks_path, :roles_path
|
13
15
|
attr_accessor :data_bags_path, :bootstrap_scripts
|
@@ -130,16 +132,14 @@ module Caterer
|
|
130
132
|
def install(server)
|
131
133
|
server.ui.info "Preparing installation..."
|
132
134
|
|
133
|
-
|
134
|
-
server.ssh.upload install_script, "#{target_install_path}"
|
135
|
+
installer = install_script(server.platform)
|
135
136
|
|
136
|
-
|
137
|
-
|
138
|
-
|
137
|
+
if not File.exists? installer
|
138
|
+
server.ui.error "#{server.platform} doesn't have an install script"
|
139
|
+
return
|
140
|
+
end
|
139
141
|
|
140
|
-
|
141
|
-
server.ui.info "Installing chef-solo..."
|
142
|
-
res = server.ssh.sudo "#{target_install_path}", :stream => true
|
142
|
+
res = server.ssh.sudo bash(File.read(installer)), :stream => true
|
143
143
|
|
144
144
|
unless res == 0
|
145
145
|
server.ui.error "install failed with exit code: #{res}"
|
@@ -261,8 +261,8 @@ module Caterer
|
|
261
261
|
"#{dest_dir}/config.json"
|
262
262
|
end
|
263
263
|
|
264
|
-
def install_script
|
265
|
-
File.expand_path("../../../templates/provisioner/chef_solo/bootstrap.sh", __FILE__)
|
264
|
+
def install_script(platform)
|
265
|
+
File.expand_path("../../../templates/provisioner/chef_solo/bootstrap/#{platform}.sh", __FILE__)
|
266
266
|
end
|
267
267
|
|
268
268
|
def solo_content(server)
|
data/lib/caterer/server.rb
CHANGED
@@ -3,6 +3,8 @@ require 'digest'
|
|
3
3
|
|
4
4
|
module Caterer
|
5
5
|
class Server
|
6
|
+
|
7
|
+
include Util::Shell
|
6
8
|
|
7
9
|
attr_reader :env
|
8
10
|
|
@@ -172,6 +174,27 @@ module Caterer
|
|
172
174
|
env.action_runner.run(name, options)
|
173
175
|
end
|
174
176
|
|
177
|
+
def detect_platform
|
178
|
+
@platform ||= begin
|
179
|
+
ui.info "Detecting platform..."
|
180
|
+
out = ""
|
181
|
+
res = ssh.sudo bash(File.read(platform_script)) do |_stream, data|
|
182
|
+
out += data
|
183
|
+
end
|
184
|
+
if res == 0
|
185
|
+
out.strip # success
|
186
|
+
else
|
187
|
+
ui.error "Unknown platform"
|
188
|
+
false
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
alias :platform :detect_platform
|
193
|
+
|
194
|
+
def platform_script
|
195
|
+
File.expand_path("../../templates/server/platform.sh", __FILE__)
|
196
|
+
end
|
197
|
+
|
175
198
|
def upload_directory(from, to)
|
176
199
|
if File.exists? from
|
177
200
|
if can_rsync?
|
data/lib/caterer/util.rb
CHANGED
@@ -0,0 +1,41 @@
|
|
1
|
+
module Caterer
|
2
|
+
module Util
|
3
|
+
module Shell
|
4
|
+
|
5
|
+
# strategy:
|
6
|
+
# 1- escape the escapes
|
7
|
+
# 2- escape quotes
|
8
|
+
# 3- escape dollar signs
|
9
|
+
def escape(cmd)
|
10
|
+
cmd.gsub!(/\\/, "\\\\\\")
|
11
|
+
cmd.gsub!(/"/, "\\\"")
|
12
|
+
cmd.gsub!(/\$/, "\\$")
|
13
|
+
cmd
|
14
|
+
end
|
15
|
+
|
16
|
+
def bash(cmd)
|
17
|
+
"bash -c \"#{escape(cmd)}\""
|
18
|
+
end
|
19
|
+
|
20
|
+
def su(user, cmd)
|
21
|
+
"su #{user} -l -c \"#{escape(cmd)}\""
|
22
|
+
end
|
23
|
+
|
24
|
+
def env(vars)
|
25
|
+
vars ||= {}
|
26
|
+
env = ''
|
27
|
+
vars.each do |key, val|
|
28
|
+
env += " " if not env == ''
|
29
|
+
env += env_string(key, val)
|
30
|
+
end
|
31
|
+
(env == '')? env : "#{env} "
|
32
|
+
end
|
33
|
+
|
34
|
+
def env_string(key, val)
|
35
|
+
key = key.to_s if not key.is_a? String
|
36
|
+
%Q{#{key.upcase}="#{escape(val)}"}
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/caterer/version.rb
CHANGED
@@ -34,13 +34,26 @@ detect_platform() {
|
|
34
34
|
then
|
35
35
|
platform="el"
|
36
36
|
fi
|
37
|
-
# Apple OS X
|
38
37
|
elif [ -f "/usr/bin/sw_vers" ];
|
39
38
|
then
|
40
39
|
platform="mac_os_x"
|
41
40
|
elif [ -f "/etc/release" ];
|
42
41
|
then
|
43
|
-
|
42
|
+
if [[ -n $(cat /etc/release | grep "SmartOS") ]]; then
|
43
|
+
platform="smartos"
|
44
|
+
elif [[ -n $(cat /etc/release | grep "OmniOS") ]]; then
|
45
|
+
platform="omnios"
|
46
|
+
elif [[ -n $(cat /etc/release | grep "OpenIndiana") ]]; then
|
47
|
+
platform="openindiana"
|
48
|
+
elif [[ -n $(cat /etc/release | grep "OpenSolaris") ]]; then
|
49
|
+
platform="opensolaris"
|
50
|
+
elif [[ -n $(cat /etc/release | grep "Oracle Solaris") ]]; then
|
51
|
+
platform="oracle_solaris"
|
52
|
+
elif [[ -n $(cat /etc/release | grep "Solaris") ]]; then
|
53
|
+
platform="solaris2"
|
54
|
+
elif [[ -n $(cat /etc/release | grep "NexentaCore") ]]; then
|
55
|
+
platform="nexentacore"
|
56
|
+
fi
|
44
57
|
elif [ -f "/etc/SuSE-release" ];
|
45
58
|
then
|
46
59
|
if grep -q 'Enterprise' /etc/SuSE-release;
|
@@ -74,9 +87,25 @@ install() {
|
|
74
87
|
"sles" )
|
75
88
|
yast -i $1
|
76
89
|
;;
|
90
|
+
esac
|
91
|
+
}
|
92
|
+
|
93
|
+
bootstrap() {
|
94
|
+
echo "bootstrapping chef..."
|
95
|
+
case $(detect_platform) in
|
96
|
+
"smartos" )
|
97
|
+
# made this one myself :)
|
98
|
+
echo "downloading chef fatclient..."
|
99
|
+
wget -q -P https://s3.amazonaws.com/packages.pagodabox.com/tar/smartos/chef/chef-fatclient.tar.bz2
|
100
|
+
cd /; tar -xjf /tmp/Chef-fatclient-SmartOS-10.14.2.tar.bz2
|
101
|
+
# make an executable link
|
102
|
+
mkdir -p /opt/local/bin
|
103
|
+
ln -s /opt/local/bin/chef-solo /opt/chef/bin/chef-solo
|
104
|
+
# cleanup
|
105
|
+
rm -f /tmp/Chef-fatclient-SmartOS-10.14.2.tar.bz2
|
106
|
+
;;
|
77
107
|
*)
|
78
|
-
|
79
|
-
exit 1
|
108
|
+
curl -L https://www.opscode.com/chef/install.sh | bash
|
80
109
|
;;
|
81
110
|
esac
|
82
111
|
}
|
@@ -86,4 +115,4 @@ exists curl || install curl
|
|
86
115
|
exists rsync || install rsync
|
87
116
|
|
88
117
|
# install chef-solo
|
89
|
-
exists chef-solo ||
|
118
|
+
exists chef-solo || bootstrap
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# install curl
|
2
|
+
echo "ensure curl exists..."
|
3
|
+
command -v curl &>/dev/null || apt-get -y --force-yes install curl
|
4
|
+
|
5
|
+
# install rsync
|
6
|
+
echo "ensure rsync exists..."
|
7
|
+
command -v rsync &>/dev/null || apt-get -y --force-yes install rsync
|
8
|
+
|
9
|
+
# install chef
|
10
|
+
echo "bootstrapping chef..."
|
11
|
+
curl -L https://www.opscode.com/chef/install.sh | bash
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# install curl
|
2
|
+
echo "ensure curl exists..."
|
3
|
+
command -v curl &>/dev/null || yum -y install curl
|
4
|
+
|
5
|
+
# install rsync
|
6
|
+
echo "ensure rsync exists..."
|
7
|
+
command -v rsync &>/dev/null || yum -y install rsync
|
8
|
+
|
9
|
+
# install chef
|
10
|
+
echo "bootstrapping chef..."
|
11
|
+
curl -L https://www.opscode.com/chef/install.sh | bash
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# install curl
|
2
|
+
echo "ensure curl exists..."
|
3
|
+
command -v curl &>/dev/null || yum -y install curl
|
4
|
+
|
5
|
+
# install rsync
|
6
|
+
echo "ensure rsync exists..."
|
7
|
+
command -v rsync &>/dev/null || yum -y install rsync
|
8
|
+
|
9
|
+
# install chef
|
10
|
+
echo "bootstrapping chef..."
|
11
|
+
curl -L https://www.opscode.com/chef/install.sh | bash
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# install curl
|
2
|
+
echo "ensure curl exists..."
|
3
|
+
command -v curl &>/dev/null || yast -i curl
|
4
|
+
|
5
|
+
# install rsync
|
6
|
+
echo "ensure rsync exists..."
|
7
|
+
command -v rsync &>/dev/null || yast -i rsync
|
8
|
+
|
9
|
+
# install chef
|
10
|
+
echo "bootstrapping chef..."
|
11
|
+
curl -L https://www.opscode.com/chef/install.sh | bash
|
@@ -0,0 +1,6 @@
|
|
1
|
+
# download and install fatclient
|
2
|
+
[[ -d /opt/chef ]] || (cd /; curl -k -s -S https://s3.amazonaws.com/packages.pagodabox.com/tar/smartos/chef/chef-fatclient.tar.bz2 | bzcat | tar -xf -)
|
3
|
+
|
4
|
+
# create symlink for chef-solo
|
5
|
+
[[ -d /opt/local/bin ]] || mkdir -p /opt/local/bin
|
6
|
+
[[ -f /opt/local/bin/chef-solo ]] || ln -s /opt/chef/bin/chef-solo /opt/local/bin/chef-solo
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# install curl
|
2
|
+
echo "ensure curl exists..."
|
3
|
+
command -v curl &>/dev/null || yast -i curl
|
4
|
+
|
5
|
+
# install rsync
|
6
|
+
echo "ensure rsync exists..."
|
7
|
+
command -v rsync &>/dev/null || yast -i rsync
|
8
|
+
|
9
|
+
# install chef
|
10
|
+
echo "bootstrapping chef..."
|
11
|
+
curl -L https://www.opscode.com/chef/install.sh | bash
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# install curl
|
2
|
+
echo "ensure curl exists..."
|
3
|
+
command -v curl &>/dev/null || apt-get -y --force-yes install curl
|
4
|
+
|
5
|
+
# install rsync
|
6
|
+
echo "ensure rsync exists..."
|
7
|
+
command -v rsync &>/dev/null || apt-get -y --force-yes install rsync
|
8
|
+
|
9
|
+
# install chef
|
10
|
+
echo "bootstrapping chef..."
|
11
|
+
curl -L https://www.opscode.com/chef/install.sh | bash
|
@@ -0,0 +1,48 @@
|
|
1
|
+
platform=""
|
2
|
+
if [ -f "/etc/lsb-release" ];
|
3
|
+
then
|
4
|
+
platform=$(grep DISTRIB_ID /etc/lsb-release | cut -d "=" -f 2 | tr '[A-Z]' '[a-z]')
|
5
|
+
elif [ -f "/etc/debian_version" ];
|
6
|
+
then
|
7
|
+
platform="debian"
|
8
|
+
elif [ -f "/etc/redhat-release" ];
|
9
|
+
then
|
10
|
+
platform="el"
|
11
|
+
elif [ -f "/etc/system-release" ];
|
12
|
+
then
|
13
|
+
platform=$(sed 's/^\(.\+\) release.\+/\1/' /etc/system-release | tr '[A-Z]' '[a-z]')
|
14
|
+
# amazon is built off of fedora, so act like RHEL
|
15
|
+
if [ "$platform" = "amazon linux ami" ];
|
16
|
+
then
|
17
|
+
platform="el"
|
18
|
+
fi
|
19
|
+
elif [ -f "/usr/bin/sw_vers" ];
|
20
|
+
then
|
21
|
+
platform="mac_os_x"
|
22
|
+
elif [ -f "/etc/release" ];
|
23
|
+
then
|
24
|
+
if [[ -n $(cat /etc/release | grep "SmartOS") ]]; then
|
25
|
+
platform="smartos"
|
26
|
+
elif [[ -n $(cat /etc/release | grep "OmniOS") ]]; then
|
27
|
+
platform="omnios"
|
28
|
+
elif [[ -n $(cat /etc/release | grep "OpenIndiana") ]]; then
|
29
|
+
platform="openindiana"
|
30
|
+
elif [[ -n $(cat /etc/release | grep "OpenSolaris") ]]; then
|
31
|
+
platform="opensolaris"
|
32
|
+
elif [[ -n $(cat /etc/release | grep "Oracle Solaris") ]]; then
|
33
|
+
platform="oracle_solaris"
|
34
|
+
elif [[ -n $(cat /etc/release | grep "Solaris") ]]; then
|
35
|
+
platform="solaris2"
|
36
|
+
elif [[ -n $(cat /etc/release | grep "NexentaCore") ]]; then
|
37
|
+
platform="nexentacore"
|
38
|
+
fi
|
39
|
+
elif [ -f "/etc/SuSE-release" ];
|
40
|
+
then
|
41
|
+
if grep -q 'Enterprise' /etc/SuSE-release;
|
42
|
+
then
|
43
|
+
platform="sles"
|
44
|
+
else
|
45
|
+
platform="suse"
|
46
|
+
fi
|
47
|
+
fi
|
48
|
+
echo $platform
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caterer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: log4r
|
@@ -204,6 +204,7 @@ files:
|
|
204
204
|
- lib/caterer/action/provisioner/validate/engine.rb
|
205
205
|
- lib/caterer/action/server.rb
|
206
206
|
- lib/caterer/action/server/lock.rb
|
207
|
+
- lib/caterer/action/server/platform.rb
|
207
208
|
- lib/caterer/action/server/reboot.rb
|
208
209
|
- lib/caterer/action/server/unlock.rb
|
209
210
|
- lib/caterer/action/server/validate.rb
|
@@ -246,9 +247,18 @@ files:
|
|
246
247
|
- lib/caterer/util.rb
|
247
248
|
- lib/caterer/util/ansi_escape_code_remover.rb
|
248
249
|
- lib/caterer/util/retryable.rb
|
250
|
+
- lib/caterer/util/shell.rb
|
249
251
|
- lib/caterer/version.rb
|
250
252
|
- lib/templates/provisioner/chef_solo/bootstrap.sh
|
253
|
+
- lib/templates/provisioner/chef_solo/bootstrap/debian.sh
|
254
|
+
- lib/templates/provisioner/chef_solo/bootstrap/el.sh
|
255
|
+
- lib/templates/provisioner/chef_solo/bootstrap/fedora.sh
|
256
|
+
- lib/templates/provisioner/chef_solo/bootstrap/sles.sh
|
257
|
+
- lib/templates/provisioner/chef_solo/bootstrap/smartos.sh
|
258
|
+
- lib/templates/provisioner/chef_solo/bootstrap/suse.sh
|
259
|
+
- lib/templates/provisioner/chef_solo/bootstrap/ubuntu.sh
|
251
260
|
- lib/templates/provisioner/chef_solo/solo.erb
|
261
|
+
- lib/templates/server/platform.sh
|
252
262
|
homepage: ''
|
253
263
|
licenses: []
|
254
264
|
post_install_message:
|
@@ -263,7 +273,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
263
273
|
version: '0'
|
264
274
|
segments:
|
265
275
|
- 0
|
266
|
-
hash:
|
276
|
+
hash: 4321504824518012860
|
267
277
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
268
278
|
none: false
|
269
279
|
requirements:
|
@@ -272,7 +282,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
272
282
|
version: '0'
|
273
283
|
segments:
|
274
284
|
- 0
|
275
|
-
hash:
|
285
|
+
hash: 4321504824518012860
|
276
286
|
requirements: []
|
277
287
|
rubyforge_project:
|
278
288
|
rubygems_version: 1.8.23
|