Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit cb01b35

Browse files
committed
Adding cwd param to all exec types and fixing rspec and beaker tests
1 parent 1aefefd commit cb01b35

File tree

4 files changed

+56
-4
lines changed

4 files changed

+56
-4
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,9 @@ Sets the user that will install NVM.
155155

156156
#### `home`
157157

158-
Indicates the user's home. Only used when `manage_user` is set to `true`.
158+
Indicates the user's home. It needs to be an existing directory if the `manage_user` is not set to `true`.
159159

160-
Default: `/home/${user}`.
160+
Default: `/home/${user}` (or `/root` if the user is `root`).
161161

162162
#### `nvm_dir`
163163

@@ -257,7 +257,7 @@ This module is CI tested against [open source Puppet](http://docs.puppetlabs.com
257257
- Ubuntu 12.04 and 14.04
258258
- Debian 7
259259

260-
This module has been tested in a production OpenLogic7 (Centos7) server in Azure.
260+
This module has been tested in several production servers (OpenLogic7 (Centos7) and Ubuntu 14.04) in Azure.
261261

262262
This module should also work properly in other distributions and operating systems, such as FreeBSD, Gentoo, and Amazon Linux, but is not formally tested on them.
263263

manifests/init.pp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
$install_node = $nvm::params::install_node,
1414
) inherits ::nvm::params {
1515

16-
if $home == undef {
16+
if $home == undef and $user == 'root' {
17+
$final_home = '/root'
18+
}
19+
elsif $home == undef {
1720
$final_home = "/home/${user}"
1821
}
1922
else {
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
require 'spec_helper_acceptance'
2+
3+
describe 'nvm::node::install define' do
4+
5+
describe 'running puppet code' do
6+
pp = <<-EOS
7+
class { 'nvm':
8+
user => 'foo',
9+
manage_user => true,
10+
}
11+
12+
nvm::node::install { '4.3.1':
13+
user => 'foo',
14+
default => true,
15+
}
16+
17+
nvm::node::install { '0.10.40':
18+
user => 'foo',
19+
}
20+
EOS
21+
let(:manifest) { pp }
22+
23+
it 'should work with no errors' do
24+
apply_manifest(manifest, :catch_failures => true)
25+
end
26+
27+
it 'should be idempotent' do
28+
apply_manifest(manifest, :catch_changes => true)
29+
end
30+
31+
describe command('su - foo -c ". /home/foo/.nvm/nvm.sh && nvm --version" -s /bin/bash') do
32+
its(:exit_status) { should eq 0 }
33+
its(:stdout) { should match /0.29.0/ }
34+
end
35+
36+
describe command('su - foo -c ". /home/foo/.nvm/nvm.sh && node --version" -s /bin/bash') do
37+
its(:exit_status) { should eq 0 }
38+
its(:stdout) { should match /4.3.1/ }
39+
end
40+
41+
describe command('su - foo -c ". /home/foo/.nvm/nvm.sh && nvm ls" -s /bin/bash') do
42+
its(:exit_status) { should eq 0 }
43+
its(:stdout) { should match /0.10.40/ }
44+
end
45+
46+
end
47+
48+
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
pp = <<-EOS
77
class { 'nvm':
88
user => 'root',
9+
home => '/root',
910
nvm_dir => '/opt/nvm',
1011
version => 'v0.29.0',
1112
profile_path => '/etc/profile.d/nvm.sh',

0 commit comments

Comments
 (0)