testlab 0.8.2 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/features/support/Labfile.local +2 -1
- data/features/support/Labfile.vagrant +2 -1
- data/lib/testlab/container/user.rb +3 -1
- data/lib/testlab/node/ssh.rb +1 -1
- data/lib/testlab/provisioners/chef/omni_bus.rb +1 -1
- data/lib/testlab/provisioners/chef/omni_truck.rb +1 -1
- data/lib/testlab/provisioners/chef/ruby_gem_client.rb +1 -1
- data/lib/testlab/provisioners/chef/ruby_gem_server.rb +1 -1
- data/lib/testlab/user.rb +1 -0
- data/lib/testlab/user/lifecycle.rb +8 -8
- data/lib/testlab/utility/logger.rb +3 -3
- data/lib/testlab/version.rb +1 -1
- data/spec/testlab_spec.rb +1 -0
- metadata +3 -3
|
@@ -15,10 +15,12 @@ class TestLab
|
|
|
15
15
|
if self.users.count == 0
|
|
16
16
|
case self.distro.downcase
|
|
17
17
|
when 'ubuntu' then
|
|
18
|
-
u = TestLab::User.new
|
|
18
|
+
u = TestLab::User.new do
|
|
19
|
+
username 'ubuntu'
|
|
19
20
|
password 'ubuntu'
|
|
20
21
|
end
|
|
21
22
|
u.container = self
|
|
23
|
+
u
|
|
22
24
|
end
|
|
23
25
|
elsif self.users.any?{ |u| u.primary == true }
|
|
24
26
|
self.users.find{ |u| u.primary == true }
|
data/lib/testlab/node/ssh.rb
CHANGED
|
@@ -31,7 +31,7 @@ class TestLab
|
|
|
31
31
|
|
|
32
32
|
c.host_name = container.ip
|
|
33
33
|
|
|
34
|
-
c.user = (options[:user] || container.primary_user.
|
|
34
|
+
c.user = (options[:user] || container.primary_user.username)
|
|
35
35
|
c.password = (options[:passwd] || container.primary_user.password)
|
|
36
36
|
c.keys = (options[:keys] || [container.primary_user.identity, @provider.identity].flatten.compact)
|
|
37
37
|
end
|
|
@@ -43,7 +43,7 @@ class TestLab
|
|
|
43
43
|
:chef_client_cli => chef_client_cli(container),
|
|
44
44
|
:chef_client_rb => chef_client_rb(container),
|
|
45
45
|
:validation_pem => validation_pem,
|
|
46
|
-
:sudo_user => container.primary_user.
|
|
46
|
+
:sudo_user => container.primary_user.username,
|
|
47
47
|
:sudo_uid => container.primary_user.uid,
|
|
48
48
|
:sudo_gid => container.primary_user.gid,
|
|
49
49
|
:home_dir => container.primary_user.home_dir
|
|
@@ -44,7 +44,7 @@ class TestLab
|
|
|
44
44
|
:chef_admin => '/etc/chef-server/admin.pem',
|
|
45
45
|
:local_user => ENV['USER'],
|
|
46
46
|
:default_password => "p@ssw01d",
|
|
47
|
-
:sudo_user => container.primary_user.
|
|
47
|
+
:sudo_user => container.primary_user.username,
|
|
48
48
|
:sudo_uid => container.primary_user.uid,
|
|
49
49
|
:sudo_gid => container.primary_user.gid,
|
|
50
50
|
:home_dir => container.primary_user.home_dir
|
|
@@ -44,7 +44,7 @@ class TestLab
|
|
|
44
44
|
:chef_client_cli => chef_client_cli(container),
|
|
45
45
|
:chef_client_rb => chef_client_rb(container),
|
|
46
46
|
:validation_pem => validation_pem,
|
|
47
|
-
:sudo_user => container.primary_user.
|
|
47
|
+
:sudo_user => container.primary_user.username,
|
|
48
48
|
:sudo_uid => container.primary_user.uid,
|
|
49
49
|
:sudo_gid => container.primary_user.gid,
|
|
50
50
|
:home_dir => container.primary_user.home_dir
|
|
@@ -42,7 +42,7 @@ class TestLab
|
|
|
42
42
|
:chef_admin => '/etc/chef/admin.pem',
|
|
43
43
|
:default_password => "p@ssw01d",
|
|
44
44
|
:local_user => ENV['USER'],
|
|
45
|
-
:sudo_user => container.primary_user.
|
|
45
|
+
:sudo_user => container.primary_user.username,
|
|
46
46
|
:sudo_uid => container.primary_user.uid,
|
|
47
47
|
:sudo_gid => container.primary_user.gid,
|
|
48
48
|
:home_dir => container.primary_user.home_dir,
|
data/lib/testlab/user.rb
CHANGED
|
@@ -7,28 +7,28 @@ class TestLab
|
|
|
7
7
|
#
|
|
8
8
|
# @return [Boolean] True if successful.
|
|
9
9
|
def setup
|
|
10
|
-
@ui.logger.debug { "User Create: #{self.
|
|
10
|
+
@ui.logger.debug { "User Create: #{self.username} " }
|
|
11
11
|
|
|
12
12
|
node_home_dir = ((self.container.node.user == "root") ? %(/root) : %(/home/#{self.container.node.user}))
|
|
13
13
|
node_authkeys = File.join(node_home_dir, ".ssh", "authorized_keys")
|
|
14
14
|
|
|
15
15
|
# ensure the container user exists
|
|
16
16
|
container_passwd_file = File.join(self.container.fs_root, "etc", "passwd")
|
|
17
|
-
if self.container.node.ssh.exec(%(sudo grep "#{self.
|
|
17
|
+
if self.container.node.ssh.exec(%(sudo grep "#{self.username}" #{container_passwd_file}), :ignore_exit_status => true).exit_code != 0
|
|
18
18
|
|
|
19
19
|
if !self.gid.nil?
|
|
20
|
-
groupadd_command = %(groupadd --gid #{self.gid} #{self.
|
|
20
|
+
groupadd_command = %(groupadd --gid #{self.gid} #{self.username})
|
|
21
21
|
self.container.node.ssh.exec(%(sudo chroot #{self.container.fs_root} /bin/bash -c '#{groupadd_command}'))
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
useradd_command = %W(useradd --create-home --shell /bin/bash --groups sudo)
|
|
25
25
|
useradd_command << "--uid #{self.uid}" if !self.uid.nil?
|
|
26
26
|
useradd_command << "--gid #{self.gid}" if !self.gid.nil?
|
|
27
|
-
useradd_command << self.
|
|
27
|
+
useradd_command << self.username
|
|
28
28
|
useradd_command = useradd_command.flatten.compact.join(' ')
|
|
29
29
|
|
|
30
30
|
self.container.lxc.attach(%(-- /bin/bash -c '#{useradd_command}'))
|
|
31
|
-
self.container.lxc.attach(%(-- /bin/bash -c 'echo "#{self.
|
|
31
|
+
self.container.lxc.attach(%(-- /bin/bash -c 'echo "#{self.username}:#{self.password}" | chpasswd'))
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
# ensure the user user gets our node user key
|
|
@@ -62,8 +62,8 @@ class TestLab
|
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
# ensure the container user home directory is owned by them
|
|
65
|
-
home_dir = self.container.lxc.attach(%(-- /bin/bash -c 'grep #{self.
|
|
66
|
-
self.container.lxc.attach(%(-- /bin/bash -c 'sudo chown -Rv $(id -u #{self.
|
|
65
|
+
home_dir = self.container.lxc.attach(%(-- /bin/bash -c 'grep #{self.username} /etc/passwd | cut -d ":" -f6')).strip
|
|
66
|
+
self.container.lxc.attach(%(-- /bin/bash -c 'sudo chown -Rv $(id -u #{self.username}):$(id -g #{self.username}) #{home_dir}'))
|
|
67
67
|
|
|
68
68
|
# ensure the sudo user group can do passwordless sudo
|
|
69
69
|
self.container.lxc.attach(%(-- /bin/bash -c 'grep "sudo\tALL=\(ALL:ALL\) ALL" /etc/sudoers && sed -i "s/sudo\tALL=\(ALL:ALL\) ALL/sudo\tALL=\(ALL:ALL\) NOPASSWD: ALL/" /etc/sudoers'))
|
|
@@ -77,7 +77,7 @@ class TestLab
|
|
|
77
77
|
#
|
|
78
78
|
# @return [String] The users home directory.
|
|
79
79
|
def home_dir(name=nil)
|
|
80
|
-
username = (name || self.
|
|
80
|
+
username = (name || self.username)
|
|
81
81
|
if (username == "root")
|
|
82
82
|
"/root"
|
|
83
83
|
else
|
|
@@ -46,9 +46,9 @@ class TestLab
|
|
|
46
46
|
"ruby_platform" => RUBY_PLATFORM.inspect
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
defined?(RUBY_ENGINE) and dependencies.merge!("ruby_engine" => RUBY_ENGINE)
|
|
50
|
-
defined?(RUBY_DESCRIPTION) and dependencies.merge!("ruby_description" => RUBY_DESCRIPTION)
|
|
51
|
-
defined?(RUBY_RELEASE_DATE) and dependencies.merge!("ruby_release_date" => RUBY_RELEASE_DATE)
|
|
49
|
+
defined?(RUBY_ENGINE) and dependencies.merge!("ruby_engine" => RUBY_ENGINE.inspect)
|
|
50
|
+
defined?(RUBY_DESCRIPTION) and dependencies.merge!("ruby_description" => RUBY_DESCRIPTION.inspect)
|
|
51
|
+
defined?(RUBY_RELEASE_DATE) and dependencies.merge!("ruby_release_date" => RUBY_RELEASE_DATE.inspect)
|
|
52
52
|
|
|
53
53
|
dependencies
|
|
54
54
|
end
|
data/lib/testlab/version.rb
CHANGED
data/spec/testlab_spec.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: testlab
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.3
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -329,7 +329,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
329
329
|
version: '0'
|
|
330
330
|
segments:
|
|
331
331
|
- 0
|
|
332
|
-
hash:
|
|
332
|
+
hash: 1734275304878040822
|
|
333
333
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
334
334
|
none: false
|
|
335
335
|
requirements:
|
|
@@ -338,7 +338,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
338
338
|
version: '0'
|
|
339
339
|
segments:
|
|
340
340
|
- 0
|
|
341
|
-
hash:
|
|
341
|
+
hash: 1734275304878040822
|
|
342
342
|
requirements: []
|
|
343
343
|
rubyforge_project:
|
|
344
344
|
rubygems_version: 1.8.25
|