itamae 1.0.0.beta41 → 1.0.0.beta42
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/itamae/notification.rb +5 -1
- data/lib/itamae/resource/base.rb +73 -45
- data/lib/itamae/resource/directory.rb +15 -15
- data/lib/itamae/resource/execute.rb +1 -1
- data/lib/itamae/resource/file.rb +24 -25
- data/lib/itamae/resource/git.rb +7 -8
- data/lib/itamae/resource/link.rb +6 -6
- data/lib/itamae/resource/local_ruby_block.rb +1 -1
- data/lib/itamae/resource/package.rb +6 -7
- data/lib/itamae/resource/remote_file.rb +2 -1
- data/lib/itamae/resource/service.rb +12 -12
- data/lib/itamae/resource/template.rb +2 -2
- data/lib/itamae/resource/user.rb +21 -21
- data/lib/itamae/version.txt +1 -1
- data/spec/unit/lib/itamae/resource/base_spec.rb +1 -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: 34cf3ba583fc7e11e18f615f1d4d299806e1e555
|
4
|
+
data.tar.gz: 4a96e5ab9eee853a7938c91154f3f1d213d7b565
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2def3d8aed7a2d2d1326f1cb5465df7389630723f365fec1527b127a4d185946ebd9506a5bbd5bee2411ef3c7e60c35077a4506a521e0e5607c20c0c5ce4d0fa
|
7
|
+
data.tar.gz: 0a52f599858557e16deccd6389e778131b1761bf1a97a27e9425d0ce099cd3f91ab63db5b216054e7eea88bc77e61da73f1878804dd6df4f481062d72be76196
|
data/lib/itamae/notification.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'itamae'
|
2
2
|
|
3
3
|
module Itamae
|
4
|
-
class Notification < Struct.new(:
|
4
|
+
class Notification < Struct.new(:defined_in_resource, :action, :target_resource_desc, :timing)
|
5
5
|
def resource
|
6
6
|
runner.children.find_resource_by_description(target_resource_desc)
|
7
7
|
end
|
@@ -13,6 +13,10 @@ module Itamae
|
|
13
13
|
def action_resource
|
14
14
|
resource
|
15
15
|
end
|
16
|
+
|
17
|
+
def runner
|
18
|
+
defined_in_resource.recipe.runner
|
19
|
+
end
|
16
20
|
end
|
17
21
|
|
18
22
|
class Subscription < Notification
|
data/lib/itamae/resource/base.rb
CHANGED
@@ -1,9 +1,64 @@
|
|
1
1
|
require 'itamae'
|
2
2
|
require 'shellwords'
|
3
|
+
require 'hashie'
|
3
4
|
|
4
5
|
module Itamae
|
5
6
|
module Resource
|
6
7
|
class Base
|
8
|
+
class EvalContext
|
9
|
+
attr_reader :attributes
|
10
|
+
attr_reader :notifications
|
11
|
+
attr_reader :subscriptions
|
12
|
+
attr_reader :only_if_command
|
13
|
+
attr_reader :not_if_command
|
14
|
+
|
15
|
+
def initialize(resource)
|
16
|
+
@resource = resource
|
17
|
+
|
18
|
+
@attributes = Hashie::Mash.new
|
19
|
+
@notifications = []
|
20
|
+
@subscriptions = []
|
21
|
+
end
|
22
|
+
|
23
|
+
def respond_to_missing?(method, include_private = false)
|
24
|
+
@resource.class.defined_attributes.has_key?(method) || super
|
25
|
+
end
|
26
|
+
|
27
|
+
def method_missing(method, *args, &block)
|
28
|
+
if @resource.class.defined_attributes[method]
|
29
|
+
if args.size == 1
|
30
|
+
return @attributes[method] = args.first
|
31
|
+
elsif args.size == 0 && block_given?
|
32
|
+
return @attributes[method] = block
|
33
|
+
elsif args.size == 0
|
34
|
+
return @attributes[method]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
super
|
39
|
+
end
|
40
|
+
|
41
|
+
def notifies(action, resource_desc, timing = :delay)
|
42
|
+
@notifications << Notification.new(@resource, action, resource_desc, timing)
|
43
|
+
end
|
44
|
+
|
45
|
+
def subscribes(action, resource_desc, timing = :delay)
|
46
|
+
@subscriptions << Subscription.new(@resource, action, resource_desc, timing)
|
47
|
+
end
|
48
|
+
|
49
|
+
def only_if(command)
|
50
|
+
@only_if_command = command
|
51
|
+
end
|
52
|
+
|
53
|
+
def not_if(command)
|
54
|
+
@not_if_command = command
|
55
|
+
end
|
56
|
+
|
57
|
+
def node
|
58
|
+
@resource.runner.node
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
7
62
|
@defined_attributes ||= {}
|
8
63
|
|
9
64
|
class << self
|
@@ -32,17 +87,22 @@ module Itamae
|
|
32
87
|
attr_reader :current_attributes
|
33
88
|
attr_reader :subscriptions
|
34
89
|
attr_reader :notifications
|
90
|
+
attr_reader :updated
|
35
91
|
|
36
92
|
def initialize(recipe, resource_name, &block)
|
37
|
-
@
|
38
|
-
@current_attributes = {}
|
93
|
+
@current_attributes = Hashie::Mash.new
|
39
94
|
@recipe = recipe
|
40
95
|
@resource_name = resource_name
|
41
|
-
@notifications = []
|
42
|
-
@subscriptions = []
|
43
96
|
@updated = false
|
44
97
|
|
45
|
-
|
98
|
+
EvalContext.new(self).tap do |context|
|
99
|
+
context.instance_eval(&block) if block
|
100
|
+
@attributes = context.attributes
|
101
|
+
@notifications = context.notifications
|
102
|
+
@subscriptions = context.subscriptions
|
103
|
+
@only_if_command = context.only_if_command
|
104
|
+
@not_if_command = context.not_if_command
|
105
|
+
end
|
46
106
|
|
47
107
|
process_attributes
|
48
108
|
end
|
@@ -60,7 +120,7 @@ module Itamae
|
|
60
120
|
return
|
61
121
|
end
|
62
122
|
|
63
|
-
[specific_action || action].flatten.each do |action|
|
123
|
+
[specific_action || attributes.action].flatten.each do |action|
|
64
124
|
run_action(action, options)
|
65
125
|
end
|
66
126
|
|
@@ -91,6 +151,8 @@ module Itamae
|
|
91
151
|
|
92
152
|
private
|
93
153
|
|
154
|
+
alias_method :current, :current_attributes
|
155
|
+
|
94
156
|
def run_action(action, options)
|
95
157
|
@current_action = action
|
96
158
|
|
@@ -116,24 +178,6 @@ module Itamae
|
|
116
178
|
@current_action = nil
|
117
179
|
end
|
118
180
|
|
119
|
-
def respond_to_missing?(method, include_private = false)
|
120
|
-
self.class.defined_attributes.has_key?(method) || super
|
121
|
-
end
|
122
|
-
|
123
|
-
def method_missing(method, *args, &block)
|
124
|
-
if self.class.defined_attributes[method]
|
125
|
-
if args.size == 1
|
126
|
-
return @attributes[method] = args.first
|
127
|
-
elsif args.size == 0 && block_given?
|
128
|
-
return @attributes[method] = block
|
129
|
-
elsif args.size == 0
|
130
|
-
return @attributes[method]
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
super
|
135
|
-
end
|
136
|
-
|
137
181
|
def pre_action
|
138
182
|
# do nothing
|
139
183
|
end
|
@@ -193,14 +237,6 @@ module Itamae
|
|
193
237
|
backend.send_file(src, dst)
|
194
238
|
end
|
195
239
|
|
196
|
-
def only_if(command)
|
197
|
-
@only_if_command = command
|
198
|
-
end
|
199
|
-
|
200
|
-
def not_if(command)
|
201
|
-
@not_if_command = command
|
202
|
-
end
|
203
|
-
|
204
240
|
def do_not_run_because_of_only_if?
|
205
241
|
@only_if_command &&
|
206
242
|
run_command(@only_if_command, error: false).exit_status != 0
|
@@ -211,32 +247,24 @@ module Itamae
|
|
211
247
|
run_command(@not_if_command, error: false).exit_status == 0
|
212
248
|
end
|
213
249
|
|
214
|
-
def
|
215
|
-
|
250
|
+
def backend
|
251
|
+
Backend.instance
|
216
252
|
end
|
217
253
|
|
218
|
-
def
|
219
|
-
|
254
|
+
def runner
|
255
|
+
recipe.runner
|
220
256
|
end
|
221
257
|
|
222
258
|
def node
|
223
259
|
runner.node
|
224
260
|
end
|
225
261
|
|
226
|
-
def backend
|
227
|
-
Backend.instance
|
228
|
-
end
|
229
|
-
|
230
|
-
def runner
|
231
|
-
@recipe.runner
|
232
|
-
end
|
233
|
-
|
234
262
|
def run_command(*args)
|
235
263
|
unless args.last.is_a?(Hash)
|
236
264
|
args << {}
|
237
265
|
end
|
238
266
|
|
239
|
-
args.last[:user] ||= user
|
267
|
+
args.last[:user] ||= attributes.user
|
240
268
|
|
241
269
|
backend.run_command(*args)
|
242
270
|
end
|
@@ -12,34 +12,34 @@ module Itamae
|
|
12
12
|
def pre_action
|
13
13
|
case @current_action
|
14
14
|
when :create
|
15
|
-
|
15
|
+
attributes.exist = true
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
def set_current_attributes
|
20
|
-
exist = run_specinfra(:check_file_is_directory, path)
|
21
|
-
|
20
|
+
exist = run_specinfra(:check_file_is_directory, attributes.path)
|
21
|
+
current.exist = exist
|
22
22
|
|
23
23
|
if exist
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
current.mode = run_specinfra(:get_file_mode, attributes.path).stdout.chomp
|
25
|
+
current.owner = run_specinfra(:get_file_owner_user, attributes.path).stdout.chomp
|
26
|
+
current.group = run_specinfra(:get_file_owner_group, attributes.path).stdout.chomp
|
27
27
|
else
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
current.mode = nil
|
29
|
+
current.owner = nil
|
30
|
+
current.group = nil
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
def action_create(options)
|
35
|
-
if !run_specinfra(:check_file_is_directory, path)
|
36
|
-
run_specinfra(:create_file_as_directory, path)
|
35
|
+
if !run_specinfra(:check_file_is_directory, attributes.path)
|
36
|
+
run_specinfra(:create_file_as_directory, attributes.path)
|
37
37
|
end
|
38
|
-
if attributes
|
39
|
-
run_specinfra(:change_file_mode, path, attributes
|
38
|
+
if attributes.mode
|
39
|
+
run_specinfra(:change_file_mode, attributes.path, attributes.mode)
|
40
40
|
end
|
41
|
-
if attributes
|
42
|
-
run_specinfra(:change_file_owner, path, attributes
|
41
|
+
if attributes.owner || attributes.group
|
42
|
+
run_specinfra(:change_file_owner, attributes.path, attributes.owner, attributes.group)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
data/lib/itamae/resource/file.rb
CHANGED
@@ -13,11 +13,11 @@ module Itamae
|
|
13
13
|
|
14
14
|
def pre_action
|
15
15
|
begin
|
16
|
-
src = if content_file
|
17
|
-
::File.expand_path(content_file, ::File.dirname(@recipe.path))
|
16
|
+
src = if attributes.content_file
|
17
|
+
::File.expand_path(attributes.content_file, ::File.dirname(@recipe.path))
|
18
18
|
else
|
19
19
|
f = Tempfile.open('itamae')
|
20
|
-
f.write(content)
|
20
|
+
f.write(attributes.content)
|
21
21
|
f.close
|
22
22
|
f.path
|
23
23
|
end
|
@@ -30,30 +30,29 @@ module Itamae
|
|
30
30
|
|
31
31
|
case @current_action
|
32
32
|
when :create
|
33
|
-
|
33
|
+
attributes.exist = true
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
def set_current_attributes
|
38
|
-
exist = run_specinfra(:check_file_is_file, path)
|
39
|
-
@current_attributes[:exist?] = exist
|
38
|
+
current.exist = run_specinfra(:check_file_is_file, attributes.path)
|
40
39
|
|
41
|
-
if exist
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
if current.exist
|
41
|
+
current.mode = run_specinfra(:get_file_mode, attributes.path).stdout.chomp
|
42
|
+
current.owner = run_specinfra(:get_file_owner_user, attributes.path).stdout.chomp
|
43
|
+
current.group = run_specinfra(:get_file_owner_group, attributes.path).stdout.chomp
|
45
44
|
else
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
current.mode = nil
|
46
|
+
current.owner = nil
|
47
|
+
current.group = nil
|
49
48
|
end
|
50
49
|
end
|
51
50
|
|
52
51
|
def show_differences
|
53
52
|
super
|
54
53
|
|
55
|
-
if
|
56
|
-
diff = run_command(["diff", "-u", path, @temppath], error: false)
|
54
|
+
if current.exist
|
55
|
+
diff = run_command(["diff", "-u", attributes.path, @temppath], error: false)
|
57
56
|
if diff.exit_status == 0
|
58
57
|
# no change
|
59
58
|
Logger.debug "file content will not change"
|
@@ -67,17 +66,17 @@ module Itamae
|
|
67
66
|
end
|
68
67
|
|
69
68
|
def action_create(options)
|
70
|
-
if mode
|
71
|
-
run_specinfra(:change_file_mode, @temppath, mode)
|
69
|
+
if attributes.mode
|
70
|
+
run_specinfra(:change_file_mode, @temppath, attributes.mode)
|
72
71
|
end
|
73
|
-
if owner || group
|
74
|
-
run_specinfra(:change_file_owner, @temppath, owner, group)
|
72
|
+
if attributes.owner || attributes.group
|
73
|
+
run_specinfra(:change_file_owner, @temppath, attributes.owner, attributes.group)
|
75
74
|
end
|
76
75
|
|
77
|
-
if run_specinfra(:check_file_is_file, path)
|
78
|
-
run_specinfra(:copy_file, path, "#{path}.bak")
|
76
|
+
if run_specinfra(:check_file_is_file, attributes.path)
|
77
|
+
run_specinfra(:copy_file, attributes.path, "#{attributes.path}.bak")
|
79
78
|
|
80
|
-
unless check_command(["diff", "-q", @temppath, path])
|
79
|
+
unless check_command(["diff", "-q", @temppath, attributes.path])
|
81
80
|
# the file is modified
|
82
81
|
updated!
|
83
82
|
end
|
@@ -86,12 +85,12 @@ module Itamae
|
|
86
85
|
updated!
|
87
86
|
end
|
88
87
|
|
89
|
-
run_specinfra(:move_file, @temppath, path)
|
88
|
+
run_specinfra(:move_file, @temppath, attributes.path)
|
90
89
|
end
|
91
90
|
|
92
91
|
def action_delete(options)
|
93
|
-
if run_specinfra(:check_file_is_file, path)
|
94
|
-
run_specinfra(:remove_file, path)
|
92
|
+
if run_specinfra(:check_file_is_file, attributes.path)
|
93
|
+
run_specinfra(:remove_file, attributes.path)
|
95
94
|
end
|
96
95
|
end
|
97
96
|
end
|
data/lib/itamae/resource/git.rb
CHANGED
@@ -13,13 +13,12 @@ module Itamae
|
|
13
13
|
def pre_action
|
14
14
|
case @current_action
|
15
15
|
when :sync
|
16
|
-
|
16
|
+
attributes.exist = true
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
def set_current_attributes
|
21
|
-
exist = run_specinfra(:check_file_is_directory, destination)
|
22
|
-
@current_attributes[:exist?] = exist
|
21
|
+
current.exist = run_specinfra(:check_file_is_directory, attributes.destination)
|
23
22
|
end
|
24
23
|
|
25
24
|
def action_sync(options)
|
@@ -27,15 +26,15 @@ module Itamae
|
|
27
26
|
|
28
27
|
new_repository = false
|
29
28
|
|
30
|
-
if run_specinfra(:check_file_is_directory, destination)
|
29
|
+
if run_specinfra(:check_file_is_directory, attributes.destination)
|
31
30
|
run_command_in_repo(['git', 'fetch', 'origin'])
|
32
31
|
else
|
33
|
-
run_command(['git', 'clone', repository, destination])
|
32
|
+
run_command(['git', 'clone', attributes.repository, attributes.destination])
|
34
33
|
new_repository = true
|
35
34
|
end
|
36
35
|
|
37
|
-
target = if revision
|
38
|
-
get_revision(revision)
|
36
|
+
target = if attributes.revision
|
37
|
+
get_revision(attributes.revision)
|
39
38
|
else
|
40
39
|
run_command_in_repo("git ls-remote origin HEAD | cut -f1").stdout.strip
|
41
40
|
end
|
@@ -65,7 +64,7 @@ module Itamae
|
|
65
64
|
end
|
66
65
|
|
67
66
|
def run_command_in_repo(*args)
|
68
|
-
run_command(*args, cwd: destination)
|
67
|
+
run_command(*args, cwd: attributes.destination)
|
69
68
|
end
|
70
69
|
|
71
70
|
def current_branch
|
data/lib/itamae/resource/link.rb
CHANGED
@@ -10,21 +10,21 @@ module Itamae
|
|
10
10
|
def pre_action
|
11
11
|
case @current_action
|
12
12
|
when :create
|
13
|
-
|
13
|
+
attributes.exist = true
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
def set_current_attributes
|
18
|
-
|
18
|
+
current.exist = run_specinfra(:check_file_is_link, attributes.link)
|
19
19
|
|
20
|
-
if
|
21
|
-
|
20
|
+
if current.exist
|
21
|
+
current.to = run_specinfra(:get_file_link_target, attributes.link).stdout.strip
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
def action_create(options)
|
26
|
-
unless run_specinfra(:check_file_is_linked_to, link, to)
|
27
|
-
run_specinfra(:link_file_to, link, to)
|
26
|
+
unless run_specinfra(:check_file_is_linked_to, attributes.link, attributes.to)
|
27
|
+
run_specinfra(:link_file_to, attributes.link, attributes.to)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -11,22 +11,21 @@ module Itamae
|
|
11
11
|
def pre_action
|
12
12
|
case @current_action
|
13
13
|
when :install
|
14
|
-
|
14
|
+
attributes.installed = true
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
def set_current_attributes
|
19
|
-
installed = run_specinfra(:check_package_is_installed, name)
|
20
|
-
@current_attributes[:installed?] = installed
|
19
|
+
current.installed = run_specinfra(:check_package_is_installed, attributes.name)
|
21
20
|
|
22
|
-
if installed
|
23
|
-
|
21
|
+
if current.installed
|
22
|
+
current.version = run_specinfra(:get_package_version, attributes.name).stdout.strip
|
24
23
|
end
|
25
24
|
end
|
26
25
|
|
27
26
|
def action_install(action_options)
|
28
|
-
unless run_specinfra(:check_package_is_installed, name, version)
|
29
|
-
run_specinfra(:install_package, name, version, options)
|
27
|
+
unless run_specinfra(:check_package_is_installed, attributes.name, attributes.version)
|
28
|
+
run_specinfra(:install_package, attributes.name, attributes.version, attributes.options)
|
30
29
|
updated!
|
31
30
|
end
|
32
31
|
end
|
@@ -6,7 +6,8 @@ module Itamae
|
|
6
6
|
define_attribute :source, type: String, required: true
|
7
7
|
|
8
8
|
def pre_action
|
9
|
-
content_file
|
9
|
+
attributes.content_file =
|
10
|
+
::File.expand_path(attributes.source, ::File.dirname(@recipe.path))
|
10
11
|
|
11
12
|
super
|
12
13
|
end
|
@@ -9,43 +9,43 @@ module Itamae
|
|
9
9
|
def pre_action
|
10
10
|
case @current_action
|
11
11
|
when :start, :restart
|
12
|
-
|
12
|
+
attributes.running = true
|
13
13
|
when :stop
|
14
|
-
|
14
|
+
attributes.running = false
|
15
15
|
when :enable
|
16
|
-
|
16
|
+
attributes.enabled = true
|
17
17
|
when :disable
|
18
|
-
|
18
|
+
attributes.enabled = false
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
def set_current_attributes
|
23
|
-
|
24
|
-
|
23
|
+
current.running = run_specinfra(:check_service_is_running, attributes.name)
|
24
|
+
current.enabled = run_specinfra(:check_service_is_enabled, attributes.name)
|
25
25
|
end
|
26
26
|
|
27
27
|
def action_start(options)
|
28
|
-
run_specinfra(:start_service, name)
|
28
|
+
run_specinfra(:start_service, attributes.name)
|
29
29
|
end
|
30
30
|
|
31
31
|
def action_stop(options)
|
32
|
-
run_specinfra(:stop_service, name)
|
32
|
+
run_specinfra(:stop_service, attributes.name)
|
33
33
|
end
|
34
34
|
|
35
35
|
def action_restart(options)
|
36
|
-
run_specinfra(:restart_service, name)
|
36
|
+
run_specinfra(:restart_service, attributes.name)
|
37
37
|
end
|
38
38
|
|
39
39
|
def action_reload(options)
|
40
|
-
run_specinfra(:reload_service, name)
|
40
|
+
run_specinfra(:reload_service, attributes.name)
|
41
41
|
end
|
42
42
|
|
43
43
|
def action_enable(options)
|
44
|
-
run_specinfra(:enable_service, name)
|
44
|
+
run_specinfra(:enable_service, attributes.name)
|
45
45
|
end
|
46
46
|
|
47
47
|
def action_disable(options)
|
48
|
-
run_specinfra(:disable_service, name)
|
48
|
+
run_specinfra(:disable_service, attributes.name)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -8,8 +8,8 @@ module Itamae
|
|
8
8
|
define_attribute :source, type: String, required: true
|
9
9
|
|
10
10
|
def pre_action
|
11
|
-
src = ::File.expand_path(source, ::File.dirname(@recipe.path))
|
12
|
-
content
|
11
|
+
src = ::File.expand_path(attributes.source, ::File.dirname(@recipe.path))
|
12
|
+
attributes.content = ERB.new(::File.read(src), nil, '-').result(binding)
|
13
13
|
|
14
14
|
super
|
15
15
|
end
|
data/lib/itamae/resource/user.rb
CHANGED
@@ -12,42 +12,42 @@ module Itamae
|
|
12
12
|
define_attribute :uid, type: [String, Integer]
|
13
13
|
|
14
14
|
def set_current_attributes
|
15
|
-
|
15
|
+
current.exist = exist?
|
16
16
|
|
17
|
-
if
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
if current.exist
|
18
|
+
current.uid = run_specinfra(:get_user_uid, attributes.username).stdout.strip
|
19
|
+
current.gid = run_specinfra(:get_user_gid, attributes.username).stdout.strip
|
20
|
+
current.home = run_specinfra(:get_user_home_directory, attributes.username).stdout.strip
|
21
|
+
current.password = current_password
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
def action_create(options)
|
26
|
-
if run_specinfra(:check_user_exists, username)
|
27
|
-
if uid && uid.to_s !=
|
28
|
-
run_specinfra(:update_user_uid, username, uid)
|
26
|
+
if run_specinfra(:check_user_exists, attributes.username)
|
27
|
+
if attributes.uid && attributes.uid.to_s != current.uid
|
28
|
+
run_specinfra(:update_user_uid, attributes.username, attributes.uid)
|
29
29
|
updated!
|
30
30
|
end
|
31
31
|
|
32
|
-
if gid && gid.to_s !=
|
33
|
-
run_specinfra(:update_user_gid, username, gid)
|
32
|
+
if attributes.gid && attributes.gid.to_s != current.gid
|
33
|
+
run_specinfra(:update_user_gid, attributes.username, attributes.gid)
|
34
34
|
updated!
|
35
35
|
end
|
36
36
|
|
37
|
-
if password && password != current_password
|
38
|
-
run_specinfra(:update_user_encrypted_password, username, password)
|
37
|
+
if attributes.password && attributes.password != current_password
|
38
|
+
run_specinfra(:update_user_encrypted_password, attributes.username, attributes.password)
|
39
39
|
updated!
|
40
40
|
end
|
41
41
|
else
|
42
42
|
options = {
|
43
|
-
gid: gid,
|
44
|
-
home_directory: home,
|
45
|
-
password: password,
|
46
|
-
system_user: system_user,
|
47
|
-
uid: uid,
|
43
|
+
gid: attributes.gid,
|
44
|
+
home_directory: attributes.home,
|
45
|
+
password: attributes.password,
|
46
|
+
system_user: attributes.system_user,
|
47
|
+
uid: attributes.uid,
|
48
48
|
}
|
49
49
|
|
50
|
-
run_specinfra(:add_user, username, options)
|
50
|
+
run_specinfra(:add_user, attributes.username, options)
|
51
51
|
|
52
52
|
updated!
|
53
53
|
end
|
@@ -55,11 +55,11 @@ module Itamae
|
|
55
55
|
|
56
56
|
private
|
57
57
|
def exist?
|
58
|
-
run_specinfra(:check_user_exists, username)
|
58
|
+
run_specinfra(:check_user_exists, attributes.username)
|
59
59
|
end
|
60
60
|
|
61
61
|
def current_password
|
62
|
-
result = run_specinfra(:get_user_encrypted_password, username)
|
62
|
+
result = run_specinfra(:get_user_encrypted_password, attributes.username)
|
63
63
|
if result.success?
|
64
64
|
result.stdout.strip
|
65
65
|
else
|
data/lib/itamae/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.0.
|
1
|
+
1.0.0.beta42
|
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.0.0.
|
4
|
+
version: 1.0.0.beta42
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryota Arai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|