Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ db2::install { '11.1':
* `instance_user_uid`: UID of the instance user
* `instance_user_gid`: GID of the instance user
* `instance_user_home`: Home directory of the instance user
* `groups`: An array of supplementary groups for instance and fence users (optional, default: undef)
* `type`: Type of product this instance is for (default: ese)
* `auth`: Type of auth for this instance (default: server)
* `users_forcelocal`: Force the creation of instance and fence users to be local, true or false. (default: undef)
Expand Down
17 changes: 17 additions & 0 deletions manifests/instance.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
$instance_user_uid = undef,
$instance_user_gid = undef,
$instance_user_home = undef,
$groups = undef,
$users_forcelocal = undef,
$port = undef,
$type = 'ese',
Expand All @@ -32,6 +33,14 @@
home => $fence_user_home,
forcelocal => $users_forcelocal,
managehome => true,
groups => $groups,
}
}
if $groups {
$groups.each |$group| {
Group <| title == $group |> {
members +> $fence_user,
}
}
}
}
Expand All @@ -43,6 +52,14 @@
home => $instance_user_home,
forcelocal => $users_forcelocal,
managehome => true,
groups => $groups,
}
if $groups {
$groups.each |$group| {
Group <| title == $group |> {
members +> $instance_user,
}
}
}
}

Expand Down
53 changes: 41 additions & 12 deletions spec/defines/instance_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
end
end
context "when declared with fence user" do
let(:params) {{
let(:params) {{
:installation_root => '/opt/ibm/db2/V11.1',
:fence_user => 'db2fence'
}}
Expand All @@ -60,7 +60,7 @@
end
end
context "when declaring user attributes" do
let(:params) {{
let(:params) {{
:installation_root => '/opt/ibm/db2/V11.1',
:fence_user => 'db2fence',
:instance_user_uid => '1001',
Expand All @@ -69,25 +69,28 @@
:fence_user_uid => '1002',
:fence_user_gid => 'db2fencg',
:fence_user_home => '/db2/fence',
:groups => 'db2group',
}}
it do
is_expected.to contain_user('db2inst').with(
:uid => '1001',
:gid => 'db2instg',
:home => '/db2/inst'
:home => '/db2/inst',
:groups => 'db2group',
)
end
it do
is_expected.to contain_user('db2fence').with(
:uid => '1002',
:gid => 'db2fencg',
:home => '/db2/fence',
:groups => 'db2group',
)
end
end

context "when declaring with manage_instance_user falsified" do
let(:params) {{
let(:params) {{
:installation_root => '/opt/ibm/db2/V11.1',
:fence_user => 'db2fence',
:manage_instance_user => false,
Expand All @@ -108,7 +111,7 @@
end

context "when declaring with manage_fence_user falsified" do
let(:params) {{
let(:params) {{
:installation_root => '/opt/ibm/db2/V11.1',
:fence_user => 'db2fence',
:manage_fence_user => false,
Expand All @@ -129,7 +132,7 @@
end

context "when setting the installation type and auth options" do
let(:params) {{
let(:params) {{
:installation_root => '/opt/ibm/db2/V11.1',
:fence_user => 'db2fence',
:type => 'standalone',
Expand All @@ -145,7 +148,7 @@
end

context "when setting the port option" do
let(:params) {{
let(:params) {{
:installation_root => '/opt/ibm/db2/V11.1',
:fence_user => 'db2fence',
:type => 'standalone',
Expand All @@ -162,11 +165,37 @@
end
end



context "when the group is not defined" do
let(:params) {{
:installation_root => '/opt/ibm/db2/V11.1',
:fence_user => 'db2fence',
:manage_fence_user => true,
:instance_user => 'db2inst',
:manage_instance_user => true,
:groups => ['db2group'],
}}
it do
is_expected.to_not contain_group('db2group').with(
:members => ['bob', 'db2fence', 'db2inst'],
)
end
end

context "when the group is already defined" do
let(:pre_condition) {"group {'db2group': members => ['bob']}"}
let(:params) {{
:installation_root => '/opt/ibm/db2/V11.1',
:fence_user => 'db2fence',
:manage_fence_user => true,
:instance_user => 'db2inst',
:manage_instance_user => true,
:groups => ['db2group'],
}}
it do
is_expected.to contain_group('db2group').with(
:members => ['bob', 'db2fence', 'db2inst'],
)
end
end

end