gusteau 1.0.4.dev → 1.0.5.dev
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -0
- data/README.md +28 -2
- data/bootstrap/solo.rb +1 -1
- data/lib/gusteau/chef.rb +30 -13
- data/lib/gusteau/config.rb +2 -1
- data/lib/gusteau/server.rb +1 -1
- data/lib/gusteau/ssh.rb +4 -2
- data/lib/gusteau/version.rb +1 -1
- data/spec/lib/gusteau/chef_spec.rb +2 -2
- data/spec/lib/gusteau/config_spec.rb +2 -1
- data/spec/lib/gusteau/server_spec.rb +1 -1
- data/spec/lib/gusteau/ssh_spec.rb +7 -3
- metadata +3 -3
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## 1.0.5.dev / 2013-07-09
|
2
|
+
* Bugfix: `cookbooks_path` was not working properly
|
3
|
+
* Add an ability to specify a custom bootstrap script
|
4
|
+
* Streamline file uploading logic in `chef.rb`
|
5
|
+
|
1
6
|
## 1.0.4.dev / 2013-07-08
|
2
7
|
* Bugfix: `after` hook was not taking effect
|
3
8
|
* Add a quick `show nodename` subcommand for printing out individual node configuration
|
data/README.md
CHANGED
@@ -31,7 +31,7 @@ Gettings started
|
|
31
31
|
Gusteau is a Ruby gem:
|
32
32
|
|
33
33
|
```
|
34
|
-
gem install gusteau
|
34
|
+
gem install gusteau
|
35
35
|
```
|
36
36
|
|
37
37
|
The following command generates an example Chef-repo:
|
@@ -144,7 +144,33 @@ vagrant plugin install gusteau
|
|
144
144
|
|
145
145
|
Notes
|
146
146
|
-----
|
147
|
+
### Bootstrapping
|
147
148
|
|
148
|
-
|
149
|
+
By default, Gusteau installs the [Omnibus Chef](http://www.opscode.com/chef/install/). However if you're targetting an unsupported platform you might want to specify the `platform` value for a node: this invokes a specific [script](https://github.com/locomote/gusteau/tree/master/bootstrap).
|
149
150
|
|
151
|
+
### Before and after hooks
|
150
152
|
|
153
|
+
You can tell Gusteau to execute specific commands before and / or after `converge` or `apply` take place. They get executed on the host system. Example `.gusteau.yml` snippet:
|
154
|
+
|
155
|
+
```
|
156
|
+
before:
|
157
|
+
- bundle exec librarian-chef install
|
158
|
+
|
159
|
+
after:
|
160
|
+
- bundle exec rake spec
|
161
|
+
|
162
|
+
environments:
|
163
|
+
...
|
164
|
+
```
|
165
|
+
|
166
|
+
### Custom cookbooks path
|
167
|
+
|
168
|
+
By default, Gusteau uploads and sets Chef Solo up to use cookbooks from `./cookbooks` and `./site-cookbooks` directories. If it doesn't work for you, you can override these values in `.gusteau.yml`:
|
169
|
+
|
170
|
+
```
|
171
|
+
cookbooks_path: [ './my-cookbooks', '../something-else' ]
|
172
|
+
roles_path: './base-roles'
|
173
|
+
|
174
|
+
environments:
|
175
|
+
...
|
176
|
+
```
|
data/bootstrap/solo.rb
CHANGED
data/lib/gusteau/chef.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module Gusteau
|
2
2
|
class Chef
|
3
|
+
|
3
4
|
def initialize(server, platform = nil, dest_dir = '/etc/chef')
|
4
5
|
@server = server
|
5
6
|
@platform = platform || 'omnibus'
|
@@ -9,14 +10,13 @@ module Gusteau
|
|
9
10
|
def run(dna, opts)
|
10
11
|
@server.run "rm -rf #{@dest_dir} && mkdir #{@dest_dir} && mkdir -p /tmp/chef"
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
@server.run "cd #{@dest_dir} && mv `find . -type d -name bootstrap` #{@dest_dir}/"
|
13
|
+
with_src_files(dna[:path]) do |list|
|
14
|
+
@server.upload list, @dest_dir, :exclude => '.git/', :strip_c => 2
|
15
|
+
end
|
16
16
|
|
17
|
-
@server.run "sh /etc/chef/bootstrap
|
17
|
+
@server.run "sh /etc/chef/bootstrap.sh" if opts['bootstrap']
|
18
18
|
|
19
|
-
cmd = "chef-solo -c #{@dest_dir}/
|
19
|
+
cmd = "chef-solo -c #{@dest_dir}/solo.rb -j #{@dest_dir}/dna.json --color"
|
20
20
|
cmd << " -F #{opts['format']}" if opts['format']
|
21
21
|
cmd << " -l #{opts['log_level']}" if opts['log_level']
|
22
22
|
cmd << " -W" if opts['why-run']
|
@@ -25,13 +25,30 @@ module Gusteau
|
|
25
25
|
|
26
26
|
private
|
27
27
|
|
28
|
-
def
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
28
|
+
def with_src_files(dna_path)
|
29
|
+
tmp_dir = FileUtils.mkdir_p("/tmp/gusteau-#{Time.now.to_i}")[0]
|
30
|
+
bootstrap_dir = File.expand_path('../../../bootstrap', __FILE__)
|
31
|
+
|
32
|
+
bootstrap = Gusteau::Config.settings['bootstrap'] || "#{bootstrap_dir}/#{@platform}.sh"
|
33
|
+
|
34
|
+
{
|
35
|
+
dna_path => "dna.json",
|
36
|
+
bootstrap => "bootstrap.sh",
|
37
|
+
"#{bootstrap_dir}/solo.rb" => "solo.rb",
|
38
|
+
'data_bags' => "data_bags",
|
39
|
+
Gusteau::Config.settings['roles_path'] => "roles"
|
40
|
+
}.tap do |f|
|
41
|
+
Gusteau::Config.settings['cookbooks_path'].each_with_index do |path, i|
|
42
|
+
f[path] = "cookbooks-#{i}"
|
43
|
+
end
|
44
|
+
|
45
|
+
f.each_pair do |src, dest|
|
46
|
+
FileUtils.cp_r(src, "#{tmp_dir}/#{dest}") if File.exists?(src)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
yield [ tmp_dir ]
|
51
|
+
FileUtils.rm_rf(tmp_dir)
|
35
52
|
end
|
36
53
|
end
|
37
54
|
end
|
data/lib/gusteau/config.rb
CHANGED
@@ -44,7 +44,8 @@ module Gusteau
|
|
44
44
|
def settings
|
45
45
|
{
|
46
46
|
'cookbooks_path' => @config['cookbooks_path'] || ['cookbooks', 'site-cookbooks'],
|
47
|
-
'roles_path' => @config['roles_path'] || 'roles'
|
47
|
+
'roles_path' => @config['roles_path'] || 'roles',
|
48
|
+
'bootstrap' => @config['bootstrap']
|
48
49
|
}
|
49
50
|
end
|
50
51
|
|
data/lib/gusteau/server.rb
CHANGED
data/lib/gusteau/ssh.rb
CHANGED
@@ -33,9 +33,11 @@ module Gusteau
|
|
33
33
|
exit_code == 0
|
34
34
|
end
|
35
35
|
|
36
|
-
def send_files(files, dest_dir)
|
36
|
+
def send_files(files, dest_dir, strip_c = nil)
|
37
|
+
strip_arg = strip_c ? "--strip-components=#{strip_c}" : ''
|
38
|
+
|
37
39
|
conn.open_channel { |ch|
|
38
|
-
ch.exec(prepared_cmd "tar zxf - -C #{dest_dir}")
|
40
|
+
ch.exec(prepared_cmd "tar zxf - -C #{dest_dir} #{strip_arg}")
|
39
41
|
ch.send_data(compressed_tar_stream(files))
|
40
42
|
ch.eof!
|
41
43
|
}.wait
|
data/lib/gusteau/version.rb
CHANGED
@@ -17,7 +17,7 @@ describe Gusteau::Chef do
|
|
17
17
|
|
18
18
|
before do
|
19
19
|
server.expects(:upload)
|
20
|
-
server.expects(:run)
|
20
|
+
server.expects(:run)
|
21
21
|
end
|
22
22
|
|
23
23
|
context "bootstrap option is not specified" do
|
@@ -31,7 +31,7 @@ describe Gusteau::Chef do
|
|
31
31
|
let(:bootstrap) { true }
|
32
32
|
|
33
33
|
it "should run the bootstrap script and chef solo" do
|
34
|
-
server.expects(:run).with('sh /etc/chef/bootstrap
|
34
|
+
server.expects(:run).with('sh /etc/chef/bootstrap.sh')
|
35
35
|
expects_run_chef_solo
|
36
36
|
chef.run({ :path => '/tmp/node.json' }, opts)
|
37
37
|
end
|
@@ -40,9 +40,10 @@ describe Gusteau::Config do
|
|
40
40
|
describe "#settings" do
|
41
41
|
let(:settings) { Gusteau::Config.settings }
|
42
42
|
|
43
|
-
it "should have defaults for cookbooks_path, roles_path" do
|
43
|
+
it "should have defaults for cookbooks_path, roles_path, bootstrap" do
|
44
44
|
settings['cookbooks_path'].must_equal ['cookbooks', 'site-cookbooks']
|
45
45
|
settings['roles_path'].must_equal 'roles'
|
46
|
+
settings['bootstrap'].must_equal nil
|
46
47
|
end
|
47
48
|
|
48
49
|
context "settings defined in the config yml" do
|
@@ -61,7 +61,7 @@ describe Gusteau::Server do
|
|
61
61
|
after { FileUtils.rm_rf(pr) }
|
62
62
|
|
63
63
|
it "skips the excluded files" do
|
64
|
-
server.expects(:send_files).with(["#{pr}/cookbooks"], "/etc/chef")
|
64
|
+
server.expects(:send_files).with(["#{pr}/cookbooks"], "/etc/chef", nil)
|
65
65
|
server.upload(["#{pr}/cookbooks", "#{pr}/.git"], "/etc/chef", { :exclude => "#{pr}/.git" })
|
66
66
|
end
|
67
67
|
end
|
@@ -97,14 +97,18 @@ describe Gusteau::SSH do
|
|
97
97
|
before do
|
98
98
|
connector.user = 'root'
|
99
99
|
connector.expects(:compressed_tar_stream).returns(mock())
|
100
|
+
channel.expects(:send_data)
|
100
101
|
end
|
101
102
|
|
102
103
|
it "should execute the extraction command and send the data" do
|
103
|
-
channel.expects(:exec).with("tar zxf - -C /etc/chef")
|
104
|
-
channel.expects(:send_data)
|
105
|
-
|
104
|
+
channel.expects(:exec).with("tar zxf - -C /etc/chef ")
|
106
105
|
connector.send_files(%w{ a b }, '/etc/chef')
|
107
106
|
end
|
107
|
+
|
108
|
+
it "should strip tar components" do
|
109
|
+
channel.expects(:exec).with("tar zxf - -C /etc/chef --strip-components=3")
|
110
|
+
connector.send_files(%w{ c d }, '/etc/chef', 3)
|
111
|
+
end
|
108
112
|
end
|
109
113
|
end
|
110
114
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gusteau
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5.dev
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-07-
|
13
|
+
date: 2013-07-08 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: optitron
|
@@ -286,7 +286,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
286
286
|
version: '0'
|
287
287
|
segments:
|
288
288
|
- 0
|
289
|
-
hash:
|
289
|
+
hash: -3825904995135051259
|
290
290
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
291
291
|
none: false
|
292
292
|
requirements:
|