yyuu-capistrano-chef-solo 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 +2 -2
- data/lib/capistrano-chef-solo.rb +26 -18
- data/lib/capistrano-chef-solo/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -6,7 +6,7 @@ a capistrano recipe to invoke `chef-solo`.
|
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
gem 'capistrano-chef-solo'
|
9
|
+
gem 'yyuu-capistrano-chef-solo'
|
10
10
|
|
11
11
|
And then execute:
|
12
12
|
|
@@ -14,7 +14,7 @@ And then execute:
|
|
14
14
|
|
15
15
|
Or install it yourself as:
|
16
16
|
|
17
|
-
$ gem install capistrano-chef-solo
|
17
|
+
$ gem install yyuu-capistrano-chef-solo
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
data/lib/capistrano-chef-solo.rb
CHANGED
@@ -67,7 +67,7 @@ module Capistrano
|
|
67
67
|
|
68
68
|
task(:update_cookbooks) {
|
69
69
|
tmpdir = Dir.mktmpdir()
|
70
|
-
remote_tmpdir =
|
70
|
+
remote_tmpdir = capture("mktemp -d").chomp
|
71
71
|
destination = File.join(tmpdir, 'cookbooks')
|
72
72
|
remote_destination = File.join(chef_solo_path, 'cookbooks')
|
73
73
|
filename = File.join(tmpdir, 'cookbooks.tar.gz')
|
@@ -77,37 +77,37 @@ module Capistrano
|
|
77
77
|
run("mkdir -p #{remote_tmpdir}")
|
78
78
|
distribute_cookbooks(filename, remote_filename, remote_destination)
|
79
79
|
ensure
|
80
|
-
run("rm -rf #{remote_tmpdir}")
|
81
|
-
run_locally("rm -rf #{tmpdir}")
|
80
|
+
run("rm -rf #{remote_tmpdir}") rescue nil
|
81
|
+
run_locally("rm -rf #{tmpdir}") rescue nil
|
82
82
|
end
|
83
83
|
}
|
84
84
|
|
85
|
-
|
86
|
-
|
85
|
+
# s/cookbook/&s/g for backward compatibility with releases older than 0.0.2.
|
86
|
+
# they will be removed in future releases.
|
87
|
+
_cset(:chef_solo_cookbook_repository) {
|
87
88
|
logger.info("WARNING: `chef_solo_cookbook_repository' has been deprecated. use `chef_solo_cookbooks_repository' instead.")
|
88
|
-
chef_solo_cookbook_repository
|
89
|
+
abort("chef_solo_cookbook_repository not set")
|
89
90
|
}
|
90
|
-
_cset(:chef_solo_cookbook_revision
|
91
|
-
_cset(:chef_solo_cookbooks_revision) {
|
91
|
+
_cset(:chef_solo_cookbook_revision) {
|
92
92
|
logger.info("WARNING: `chef_solo_cookbook_revision' has been deprecated. use `chef_solo_cookbooks_revision' instead.")
|
93
|
-
|
93
|
+
"HEAD"
|
94
94
|
}
|
95
|
-
_cset(:chef_solo_cookbook_subdir
|
96
|
-
_cset(:chef_solo_cookbooks_subdir) {
|
95
|
+
_cset(:chef_solo_cookbook_subdir) {
|
97
96
|
logger.info("WARNING: `chef_solo_cookbook_subdir' has been deprecated. use `chef_solo_cookbooks_subdir' instead.")
|
98
|
-
|
97
|
+
"/"
|
99
98
|
}
|
100
99
|
_cset(:chef_solo_cookbooks_exclude, %w(.hg .git .svn))
|
101
100
|
|
102
101
|
# special variable to set multiple cookbooks repositories.
|
103
102
|
# by default, it will build from :chef_solo_cookbooks_* variables.
|
104
103
|
_cset(:chef_solo_cookbooks) {
|
105
|
-
|
104
|
+
repository = fetch(:chef_solo_cookbooks_repository, fetch(:chef_solo_cookbook_repository, nil))
|
105
|
+
name = File.basename(repository, File.extname(repository))
|
106
106
|
{
|
107
107
|
name => {
|
108
|
-
:repository =>
|
109
|
-
:revision => chef_solo_cookbooks_revision,
|
110
|
-
:cookbooks => chef_solo_cookbooks_subdir,
|
108
|
+
:repository => repository,
|
109
|
+
:revision => fetch(:chef_solo_cookbooks_revision, fetch(:chef_solo_cookbook_revision, nil)),
|
110
|
+
:cookbooks => fetch(:chef_solo_cookbooks_subdir, fetch(:chef_solo_cookbook_subdir, nil)),
|
111
111
|
:cookbooks_exclude => chef_solo_cookbooks_exclude,
|
112
112
|
}
|
113
113
|
}
|
@@ -171,18 +171,26 @@ module Capistrano
|
|
171
171
|
a.merge(b, &f)
|
172
172
|
end
|
173
173
|
|
174
|
+
def _json(x)
|
175
|
+
if fetch(:chef_solo_pretty_json, true)
|
176
|
+
JSON.pretty_generate(x)
|
177
|
+
else
|
178
|
+
JSON.generate(x)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
174
182
|
_cset(:chef_solo_attributes, {})
|
175
183
|
_cset(:chef_solo_host_attributes, {})
|
176
184
|
task(:update_attributes) {
|
177
185
|
attributes = _deep_merge(chef_solo_attributes, {'run_list' => fetch(:chef_solo_run_list, [])})
|
178
186
|
to = File.join(chef_solo_path, 'config', 'solo.json')
|
179
187
|
if chef_solo_host_attributes.empty?
|
180
|
-
put(attributes
|
188
|
+
put(_json(attributes), to)
|
181
189
|
else
|
182
190
|
execute_on_servers { |servers|
|
183
191
|
servers.each { |server|
|
184
192
|
host_attributes = _deep_merge(attributes, chef_solo_host_attributes.fetch(server.host, {}))
|
185
|
-
Capistrano::Transfer.process(:up, StringIO.new(host_attributes
|
193
|
+
Capistrano::Transfer.process(:up, StringIO.new(_json(host_attributes)), to, [sessions[server]], :logger => logger)
|
186
194
|
}
|
187
195
|
}
|
188
196
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yyuu-capistrano-chef-solo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
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: 2012-
|
12
|
+
date: 2012-12-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|