itamae 1.0.0.beta24 → 1.0.0.beta25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/itamae/resource/user.rb +35 -1
- data/lib/itamae/version.txt +1 -1
- data/spec/integration/recipes/default.rb +8 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f605498020d0aeec34bafecc46b026c60d686034
|
4
|
+
data.tar.gz: 404ca611835437710e7bd838f3489fa1f9fe6385
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04a4ba33724549eb5f5bb80808bf3f0b05abe669d5c474387f69dd705b73ecb4151ad81267c2f7e5be3a1402e724780483ffa6ea65c645f991a382447e8eedc2
|
7
|
+
data.tar.gz: 7ca95a00ff582c363a78afbfeae79cc60f03ddb40951af7b6ab6948abf08735be08ed9331adb04c3454da5b16058d46345bc30ccf19364bb9a9d8f53dfdfd988
|
data/lib/itamae/resource/user.rb
CHANGED
@@ -11,9 +11,32 @@ module Itamae
|
|
11
11
|
define_attribute :system_user, type: [TrueClass, FalseClass]
|
12
12
|
define_attribute :uid, type: [String, Integer]
|
13
13
|
|
14
|
+
def set_current_attributes
|
15
|
+
@current_attributes[:exist?] = exist?
|
16
|
+
|
17
|
+
if @current_attributes[:exist?]
|
18
|
+
@current_attributes[:uid] = run_command(["id", "-u", username]).stdout.strip
|
19
|
+
@current_attributes[:gid] = run_command(["id", "-g", username]).stdout.strip
|
20
|
+
@current_attributes[:home] = run_command("echo ~#{shell_escape(username)}").stdout.strip
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
14
24
|
def create_action
|
15
25
|
if run_specinfra(:check_user_exists, username)
|
16
|
-
|
26
|
+
if uid && uid.to_s != @current_attributes[:uid]
|
27
|
+
run_command(["usermod", "-u", uid, username])
|
28
|
+
updated!
|
29
|
+
end
|
30
|
+
|
31
|
+
if gid && gid.to_s != @current_attributes[:gid]
|
32
|
+
run_command(["usermod", "-g", gid, username])
|
33
|
+
updated!
|
34
|
+
end
|
35
|
+
|
36
|
+
if password && password != current_password
|
37
|
+
run_command("echo #{shell_escape("#{username}:#{password}")} | chpasswd -e")
|
38
|
+
updated!
|
39
|
+
end
|
17
40
|
else
|
18
41
|
args = ["useradd"]
|
19
42
|
args << "-g" << gid if gid
|
@@ -23,8 +46,19 @@ module Itamae
|
|
23
46
|
args << "-u" << uid.to_s if uid
|
24
47
|
args << username
|
25
48
|
run_command(args)
|
49
|
+
|
50
|
+
updated!
|
26
51
|
end
|
27
52
|
end
|
53
|
+
|
54
|
+
private
|
55
|
+
def exist?
|
56
|
+
run_specinfra(:check_user_exists, username)
|
57
|
+
end
|
58
|
+
|
59
|
+
def current_password
|
60
|
+
run_command("cat /etc/shadow | grep -E ^itamae:").stdout.split(":")[1]
|
61
|
+
end
|
28
62
|
end
|
29
63
|
end
|
30
64
|
end
|
data/lib/itamae/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.0.
|
1
|
+
1.0.0.beta25
|
@@ -1,10 +1,15 @@
|
|
1
1
|
include_recipe "./included.rb"
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
user "create itamae user" do
|
4
|
+
uid 123
|
5
|
+
username "itamae"
|
6
|
+
password "$1$ltOY8bZv$iZ57f1KAp8jwKViNm3pze."
|
7
|
+
end
|
5
8
|
|
6
|
-
user "itamae" do
|
9
|
+
user "update itamae user" do
|
7
10
|
uid 1234
|
11
|
+
username "itamae"
|
12
|
+
password "$1$TQz9gPMl$nHYrsA5W2ZdZ0Yn021BQH1"
|
8
13
|
end
|
9
14
|
|
10
15
|
######
|