itamae 1.3.6 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/itamae/backend.rb +4 -3
- data/lib/itamae/resource/base.rb +3 -1
- data/lib/itamae/resource/execute.rb +1 -2
- data/lib/itamae/resource/file.rb +1 -1
- data/lib/itamae/version.txt +1 -1
- data/spec/integration/default_spec.rb +1 -1
- data/spec/integration/recipes/default.rb +7 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fddee080e3424d311b0bcac35fcd5f91b2da227
|
4
|
+
data.tar.gz: 17283f41482ec965cd35a615f21074cbd9609a04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f7a9211a591f1a5cff1171da061bfc899ffe653759a76beb41aba25171820c808c60cec3107f1c8461cd08f748c7dc5b495ff791f49e3b89356320a4a4107e5
|
7
|
+
data.tar.gz: bb9325ae57e1a3358566bb9aa43cce58a6837d683b5aa985d8c738cf2d6ad7b8be7f65b3c64dbce38e8503bc5e13d8d6ae30f448ea3a99d3067efa9bacd475d2
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
## v1.4.0
|
2
|
+
|
3
|
+
Improvements
|
4
|
+
|
5
|
+
- Make `cwd` a common attribute. (idea by @tacahilo)
|
6
|
+
- It was an attribute for execute resource
|
7
|
+
- When `user` attribute is set, change directory to the user's home directory. (idea by @tacahilo)
|
8
|
+
- even if cd command fail, it will be ignored
|
9
|
+
- directory specified by cwd will take precedence over this
|
10
|
+
|
1
11
|
## v1.3.6
|
2
12
|
|
3
13
|
Bugfixes
|
data/lib/itamae/backend.rb
CHANGED
@@ -163,7 +163,7 @@ module Itamae
|
|
163
163
|
def build_command(commands, options)
|
164
164
|
if commands.is_a?(Array)
|
165
165
|
command = commands.map do |cmd|
|
166
|
-
|
166
|
+
cmd.shellescape
|
167
167
|
end.join(' ')
|
168
168
|
else
|
169
169
|
command = commands
|
@@ -171,12 +171,13 @@ module Itamae
|
|
171
171
|
|
172
172
|
cwd = options[:cwd]
|
173
173
|
if cwd
|
174
|
-
command = "cd #{
|
174
|
+
command = "cd #{cwd.shellescape} && #{command}"
|
175
175
|
end
|
176
176
|
|
177
177
|
user = options[:user]
|
178
178
|
if user
|
179
|
-
command = "
|
179
|
+
command = "cd ~#{user.shellescape} ; #{command}"
|
180
|
+
command = "sudo -H -u #{user.shellescape} -- /bin/sh -c #{command.shellescape}"
|
180
181
|
end
|
181
182
|
|
182
183
|
command
|
data/lib/itamae/resource/base.rb
CHANGED
@@ -91,6 +91,7 @@ module Itamae
|
|
91
91
|
|
92
92
|
define_attribute :action, type: [Symbol, Array], required: true
|
93
93
|
define_attribute :user, type: String
|
94
|
+
define_attribute :cwd, type: String
|
94
95
|
|
95
96
|
attr_reader :recipe
|
96
97
|
attr_reader :resource_name
|
@@ -286,6 +287,7 @@ module Itamae
|
|
286
287
|
end
|
287
288
|
|
288
289
|
args.last[:user] ||= attributes.user
|
290
|
+
args.last[:cwd] ||= attributes.cwd
|
289
291
|
|
290
292
|
backend.run_command(*args)
|
291
293
|
end
|
@@ -311,7 +313,7 @@ module Itamae
|
|
311
313
|
end
|
312
314
|
|
313
315
|
def shell_escape(str)
|
314
|
-
|
316
|
+
str.shellescape
|
315
317
|
end
|
316
318
|
|
317
319
|
def updated!
|
@@ -5,7 +5,6 @@ module Itamae
|
|
5
5
|
class Execute < Base
|
6
6
|
define_attribute :action, default: :run
|
7
7
|
define_attribute :command, type: String, default_name: true
|
8
|
-
define_attribute :cwd, type: String
|
9
8
|
|
10
9
|
def pre_action
|
11
10
|
case @current_action
|
@@ -19,7 +18,7 @@ module Itamae
|
|
19
18
|
end
|
20
19
|
|
21
20
|
def action_run(options)
|
22
|
-
run_command(attributes.command
|
21
|
+
run_command(attributes.command)
|
23
22
|
updated!
|
24
23
|
end
|
25
24
|
end
|
data/lib/itamae/resource/file.rb
CHANGED
data/lib/itamae/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.4.0
|
@@ -116,7 +116,7 @@ end
|
|
116
116
|
describe file('/tmp/created_by_itamae_user') do
|
117
117
|
it { should be_file }
|
118
118
|
it { should be_owned_by 'itamae' }
|
119
|
-
its(:content) { should eq(
|
119
|
+
its(:content) { should eq("/home/itamae\n/home/itamae") }
|
120
120
|
end
|
121
121
|
|
122
122
|
describe file('/tmp/created_in_default2') do
|
@@ -26,6 +26,12 @@ user "update itamae user" do
|
|
26
26
|
shell '/bin/dash'
|
27
27
|
end
|
28
28
|
|
29
|
+
directory "/home/itamae" do
|
30
|
+
mode "755"
|
31
|
+
owner "itamae"
|
32
|
+
group "itamae"
|
33
|
+
end
|
34
|
+
|
29
35
|
user "create itamae2 user with create home directory" do
|
30
36
|
username "itamae2"
|
31
37
|
create_home true
|
@@ -218,7 +224,7 @@ end
|
|
218
224
|
|
219
225
|
#####
|
220
226
|
|
221
|
-
execute "echo -n $HOME > /tmp/created_by_itamae_user" do
|
227
|
+
execute "echo -n \"$HOME\n$(pwd)\" > /tmp/created_by_itamae_user" do
|
222
228
|
user "itamae"
|
223
229
|
end
|
224
230
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itamae
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryota Arai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|