automateit 0.71021 → 0.71030
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/CHANGES.txt +10 -0
- data/Hoe.rake +5 -3
- data/README.txt +1 -1
- data/Rakefile +12 -2
- data/TODO.txt +14 -9
- data/TUTORIAL.txt +1 -1
- data/lib/automateit.rb.orig +65 -0
- data/lib/automateit/account_manager.rb +18 -10
- data/lib/automateit/account_manager/base.rb +133 -0
- data/lib/automateit/account_manager/{portable.rb → etc.rb} +9 -8
- data/lib/automateit/account_manager/nscd.rb +28 -0
- data/lib/automateit/account_manager/passwd_expect.rb +40 -0
- data/lib/automateit/account_manager/passwd_pty.rb +67 -0
- data/lib/automateit/account_manager/posix.rb +126 -0
- data/lib/automateit/project.rb +43 -10
- data/lib/automateit/root.rb +1 -1
- data/spec/integration/account_manager_spec.rb +128 -43
- metadata +14 -10
- metadata.gz.sig +0 -0
- data/lib/automateit/account_manager/linux.rb +0 -173
- data/lib/automateit/account_manager/passwd.rb +0 -70
metadata
CHANGED
@@ -3,15 +3,15 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: automateit
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: "0.
|
7
|
-
date: 2007-10-
|
8
|
-
summary: AutomateIt is an open
|
6
|
+
version: "0.71030"
|
7
|
+
date: 2007-10-31 00:00:00 -07:00
|
8
|
+
summary: AutomateIt is an open source tool for automating the setup and maintenance of servers, applications and their dependencies.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
11
|
email: igal@pragmaticraft.com
|
12
12
|
homepage: http://automateit.org/
|
13
13
|
rubyforge_project: automateit
|
14
|
-
description: AutomateIt is an open
|
14
|
+
description: AutomateIt is an open source tool for automating the setup and maintenance of servers, applications and their dependencies.
|
15
15
|
autorequire:
|
16
16
|
default_executable:
|
17
17
|
bindir: bin
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- lib/tempster.rb
|
84
84
|
- lib/queued_logger.rb
|
85
85
|
- lib/helpful_erb.rb
|
86
|
+
- lib/automateit.rb.orig
|
86
87
|
- lib/nested_error.rb
|
87
88
|
- lib/automateit/tag_manager.rb
|
88
89
|
- lib/automateit/service_manager.rb
|
@@ -115,9 +116,12 @@ files:
|
|
115
116
|
- lib/automateit/service_manager/sysv.rb
|
116
117
|
- lib/automateit/service_manager/chkconfig.rb
|
117
118
|
- lib/automateit/service_manager/update_rcd.rb
|
118
|
-
- lib/automateit/account_manager/
|
119
|
-
- lib/automateit/account_manager/
|
120
|
-
- lib/automateit/account_manager/
|
119
|
+
- lib/automateit/account_manager/nscd.rb
|
120
|
+
- lib/automateit/account_manager/base.rb
|
121
|
+
- lib/automateit/account_manager/passwd_expect.rb
|
122
|
+
- lib/automateit/account_manager/posix.rb
|
123
|
+
- lib/automateit/account_manager/passwd_pty.rb
|
124
|
+
- lib/automateit/account_manager/etc.rb
|
121
125
|
- lib/automateit/platform_manager/debian.rb
|
122
126
|
- lib/automateit/platform_manager/struct.rb
|
123
127
|
- lib/automateit/platform_manager/windows.rb
|
@@ -128,13 +132,13 @@ files:
|
|
128
132
|
- lib/automateit/platform_manager/darwin.rb
|
129
133
|
- lib/automateit/platform_manager/freebsd.rb
|
130
134
|
- lib/automateit/platform_manager/sunos.rb
|
131
|
-
- lib/automateit/address_manager/
|
135
|
+
- lib/automateit/address_manager/bsd.rb
|
132
136
|
- lib/automateit/address_manager/portable.rb
|
133
137
|
- lib/automateit/address_manager/sunos.rb
|
134
138
|
- lib/automateit/address_manager/linux.rb
|
135
139
|
- lib/automateit/address_manager/base.rb
|
136
|
-
- lib/automateit/address_manager/bsd.rb
|
137
140
|
- lib/automateit/address_manager/freebsd.rb
|
141
|
+
- lib/automateit/address_manager/openbsd.rb
|
138
142
|
- lib/automateit/shell_manager/portable.rb
|
139
143
|
- lib/automateit/shell_manager/which.rb
|
140
144
|
- lib/automateit/shell_manager/symlink.rb
|
@@ -217,7 +221,7 @@ rdoc_options:
|
|
217
221
|
- --accessor
|
218
222
|
- class_inheritable_accessor=R
|
219
223
|
- --title
|
220
|
-
- AutomateIt
|
224
|
+
- "AutomateIt: Open source server automation"
|
221
225
|
- - lib
|
222
226
|
- docs
|
223
227
|
extra_rdoc_files:
|
metadata.gz.sig
CHANGED
Binary file
|
@@ -1,173 +0,0 @@
|
|
1
|
-
# == AccountManager::Linux
|
2
|
-
#
|
3
|
-
# A Linux-specific driver for the AccountManager.
|
4
|
-
class ::AutomateIt::AccountManager::Linux < ::AutomateIt::AccountManager::Portable
|
5
|
-
depends_on \
|
6
|
-
:programs => %w(uname useradd usermod userdel groupadd groupmod groupdel),
|
7
|
-
:callbacks => [lambda{
|
8
|
-
`uname -s`.match(/linux/i) && AutomateIt::AccountManager::Portable.has_etc?
|
9
|
-
}]
|
10
|
-
|
11
|
-
def suitability(method, *args) # :nodoc:
|
12
|
-
# Level must be higher than Portable
|
13
|
-
return available? ? 2 : 0
|
14
|
-
end
|
15
|
-
|
16
|
-
def setup(*args) # :nodoc:
|
17
|
-
super(*args)
|
18
|
-
end
|
19
|
-
|
20
|
-
# Is "nscd" available on this platform?
|
21
|
-
def nscd?
|
22
|
-
@nscd ||= interpreter.which("nscd")
|
23
|
-
end
|
24
|
-
|
25
|
-
#.......................................................................
|
26
|
-
|
27
|
-
# See AccountManager#add_user
|
28
|
-
def add_user(username, opts={})
|
29
|
-
return false if has_user?(username)
|
30
|
-
cmd = "useradd"
|
31
|
-
cmd << " --comment #{opts[:description] || username}"
|
32
|
-
cmd << " --home #{opts[:home]}" if opts[:home]
|
33
|
-
cmd << " --create-home" unless opts[:create_home] == false
|
34
|
-
cmd << " --groups #{opts[:groups].join(' ')}" if opts[:groups]
|
35
|
-
cmd << " --shell #{opts[:shell] || "/bin/bash"}"
|
36
|
-
cmd << " --uid #{opts[:uid]}" if opts[:uid]
|
37
|
-
cmd << " --gid #{opts[:gid]}" if opts[:gid]
|
38
|
-
cmd << " #{username} < /dev/null"
|
39
|
-
cmd << " > /dev/null" if opts[:quiet]
|
40
|
-
interpreter.sh(cmd)
|
41
|
-
interpreter.sh("nscd --invalidate passwd") if nscd?
|
42
|
-
|
43
|
-
unless opts[:group] == false
|
44
|
-
groupname = opts[:group] || username
|
45
|
-
unless has_group?(groupname)
|
46
|
-
opts = {:members => [username]}
|
47
|
-
# In preview mode, user doesn't exist and has no UID
|
48
|
-
opts[:gid] = users[username].uid if writing?
|
49
|
-
add_group(groupname, opts)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
interpreter.account_manager.passwd(username, opts[:passwd]) if opts[:passwd]
|
54
|
-
|
55
|
-
return users[username]
|
56
|
-
end
|
57
|
-
|
58
|
-
# TODO AccountManager#update_user -- implement
|
59
|
-
### def update_user(username, opts={}) dispatch(username, opts) end
|
60
|
-
|
61
|
-
# See AccountManager#remove_user
|
62
|
-
def remove_user(username, opts={})
|
63
|
-
return false unless has_user?(username)
|
64
|
-
# Options: -r -- remove the home directory and mail spool
|
65
|
-
cmd = "userdel"
|
66
|
-
cmd << " -r" unless opts[:remove_home] == false
|
67
|
-
cmd << " #{username}"
|
68
|
-
cmd << " > /dev/null" if opts[:quiet]
|
69
|
-
interpreter.sh(cmd)
|
70
|
-
interpreter.sh("nscd --invalidate passwd") if nscd?
|
71
|
-
remove_group(username) if has_group?(username)
|
72
|
-
return true
|
73
|
-
end
|
74
|
-
|
75
|
-
# See AccountManager#add_groups_to_user
|
76
|
-
def add_groups_to_user(groups, username)
|
77
|
-
groups = [groups].flatten
|
78
|
-
present = groups_for_user(username)
|
79
|
-
missing = groups - present
|
80
|
-
return false if missing.empty?
|
81
|
-
|
82
|
-
cmd = "usermod -a -G #{missing.join(',')} #{username}"
|
83
|
-
interpreter.sh(cmd)
|
84
|
-
interpreter.sh("nscd --invalidate group") if nscd?
|
85
|
-
return missing
|
86
|
-
end
|
87
|
-
|
88
|
-
# See AccountManager#remove_groups_from_user
|
89
|
-
def remove_groups_from_user(groups, username)
|
90
|
-
groups = [groups].flatten
|
91
|
-
present = groups_for_user(username)
|
92
|
-
removeable = groups & present
|
93
|
-
return false if removeable.empty?
|
94
|
-
|
95
|
-
cmd = "usermod -G #{(present-groups).join(',')} #{username}"
|
96
|
-
interpreter.sh(cmd)
|
97
|
-
interpreter.sh("nscd --invalidate group") if nscd?
|
98
|
-
return removeable
|
99
|
-
end
|
100
|
-
|
101
|
-
#.......................................................................
|
102
|
-
|
103
|
-
# See AccountManager#add_group
|
104
|
-
def add_group(groupname, opts={})
|
105
|
-
return false if has_group?(groupname)
|
106
|
-
cmd = "groupadd"
|
107
|
-
cmd << " -g #{opts[:gid]}" if opts[:gid]
|
108
|
-
cmd << " #{groupname}"
|
109
|
-
interpreter.sh(cmd)
|
110
|
-
interpreter.sh("nscd --invalidate group") if nscd?
|
111
|
-
add_users_to_group(opts[:members], groupname) if opts[:members]
|
112
|
-
return groups[groupname]
|
113
|
-
end
|
114
|
-
|
115
|
-
# TODO AccountManager#update_group -- implement
|
116
|
-
### def update_group(groupname, opts={}) dispatch(groupname, opts) end
|
117
|
-
|
118
|
-
# See AccountManager#remove_group
|
119
|
-
def remove_group(groupname, opts={})
|
120
|
-
return false unless has_group?(groupname)
|
121
|
-
cmd = "groupdel #{groupname}"
|
122
|
-
interpreter.sh(cmd)
|
123
|
-
interpreter.sh("nscd --invalidate group") if nscd?
|
124
|
-
return true
|
125
|
-
end
|
126
|
-
|
127
|
-
# See AccountManager#add_users_to_group
|
128
|
-
def add_users_to_group(users, groupname)
|
129
|
-
users = [users].flatten
|
130
|
-
# XXX Include pwent.gid?
|
131
|
-
grent = groups[groupname]
|
132
|
-
missing = \
|
133
|
-
if writing? and not grent
|
134
|
-
raise ArgumentError.new("no such group: #{groupname}")
|
135
|
-
elsif writing? or grent
|
136
|
-
users - grent.mem
|
137
|
-
else
|
138
|
-
users
|
139
|
-
end
|
140
|
-
return false if missing.empty?
|
141
|
-
|
142
|
-
for username in missing
|
143
|
-
cmd = "usermod -a -G #{groupname} #{username}"
|
144
|
-
interpreter.sh(cmd)
|
145
|
-
end
|
146
|
-
interpreter.sh("nscd --invalidate group") if nscd?
|
147
|
-
return missing
|
148
|
-
end
|
149
|
-
|
150
|
-
# See AccountManager#remove_users_from_group
|
151
|
-
def remove_users_from_group(users, groupname)
|
152
|
-
users = [users].flatten
|
153
|
-
grent = groups[groupname]
|
154
|
-
present = \
|
155
|
-
if writing? and not grent
|
156
|
-
raise ArgumentError.new("no such group: #{groupname}")
|
157
|
-
elsif writing? or grent
|
158
|
-
grent.mem & users
|
159
|
-
else
|
160
|
-
users
|
161
|
-
end
|
162
|
-
return false if present.empty?
|
163
|
-
|
164
|
-
u2g = users_to_groups
|
165
|
-
for username in present
|
166
|
-
user_groups = u2g[username]
|
167
|
-
cmd = "usermod -G #{(user_groups.to_a-[groupname]).join(',')} #{username}"
|
168
|
-
interpreter.sh(cmd)
|
169
|
-
end
|
170
|
-
interpreter.sh("nscd --invalidate group") if nscd?
|
171
|
-
return present
|
172
|
-
end
|
173
|
-
end
|
@@ -1,70 +0,0 @@
|
|
1
|
-
# == AccountManager::Passwd
|
2
|
-
#
|
3
|
-
# An AccountManager driver for the +passwd+ command found on Unix-like systems.
|
4
|
-
class ::AutomateIt::AccountManager::Passwd < ::AutomateIt::AccountManager::BaseDriver
|
5
|
-
depends_on \
|
6
|
-
:programs => %w(passwd),
|
7
|
-
:libraries => %w(open3 expect pty)
|
8
|
-
|
9
|
-
def suitability(method, *args) # :nodoc:
|
10
|
-
# Level must be higher than Linux
|
11
|
-
return available? ? 3 : 0
|
12
|
-
end
|
13
|
-
|
14
|
-
# See AccountManager#passwd
|
15
|
-
def passwd(user, password, opts={})
|
16
|
-
users = interpreter.account_manager.users
|
17
|
-
|
18
|
-
unless users[user]
|
19
|
-
if preview?
|
20
|
-
log.info(PNOTE+"Setting password for user: #{user}")
|
21
|
-
return true
|
22
|
-
else
|
23
|
-
raise ArgumentError.new("No such user: #{user}")
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
case user
|
28
|
-
when Symbol: user = user.to_s
|
29
|
-
when Integer: user = users[user]
|
30
|
-
when String: # leave it alone
|
31
|
-
else raise TypeError.new("Unknown user type: #{user.class}")
|
32
|
-
end
|
33
|
-
|
34
|
-
tries = 5
|
35
|
-
exitstatus = nil
|
36
|
-
begin
|
37
|
-
exitstruct = _passwd_raw(user, password, opts)
|
38
|
-
if exitstatus and not exitstruct.exitstatus.zero?
|
39
|
-
# FIXME AccountManager::Linux#passwd -- The `passwd` command randomly returns exit status 10 even when it succeeds. What does this mean and how to deal with it?! Temporary workaround is to throw an error and force a retry.
|
40
|
-
raise Errno::EPIPE.new("bad exitstatus %s" % exitstruct.exitstatus)
|
41
|
-
end
|
42
|
-
rescue Errno::EPIPE => e
|
43
|
-
# FIXME AccountManager::Linux#passwd -- EPIPE exception randomly thrown even when `passwd` succeeds. How to eliminate it? How to differentiate between this false error and a real one?
|
44
|
-
if tries <= 0
|
45
|
-
raise e
|
46
|
-
else
|
47
|
-
tries -= 1
|
48
|
-
retry
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
return exitstruct.exitstatus.zero?
|
53
|
-
end
|
54
|
-
|
55
|
-
def _passwd_raw(user, password, opts={})
|
56
|
-
quiet = (opts[:quiet] or not log.info?)
|
57
|
-
|
58
|
-
require 'open4'
|
59
|
-
return Open4::popen4("passwd %s 2>&1" % user) do |pid, sin, sout, serr|
|
60
|
-
$expect_verbose = ! quiet
|
61
|
-
2.times do
|
62
|
-
sout.expect(/:/)
|
63
|
-
sleep 0.1 # Reduce chance of passwd thinking we're a robot :(
|
64
|
-
sin.puts password
|
65
|
-
puts "*" * 12 unless quiet
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
protected :_passwd_raw
|
70
|
-
end
|