Skip to content
This repository has been archived by the owner on Dec 31, 2024. It is now read-only.

Commit

Permalink
add warning() when an instance is defined but base class is set to ab…
Browse files Browse the repository at this point in the history
…sent
  • Loading branch information
Joshua Hoblitt committed Jan 29, 2014
1 parent 546cba1 commit bb7c059
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 20 deletions.
45 changes: 26 additions & 19 deletions manifests/instance.pp
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,31 @@
},
}

# disable bucketting since the .inf file contains password information
file { $setup_inf_name:
ensure => file,
path => $setup_inf_path,
owner => $::port389::user,
group => $::port389::group,
mode => '0600',
content => template("${module_name}/inf.erb"),
backup => false,
} ->
# /usr/sbin/setup-ds-admin.pl needs:
# /bin/{grep, cat, uname, sleep, ...}
# /sbin/service
# /usr/bin/env
exec { "setup-ds-admin.pl_${title}":
path => [ '/bin', '/sbin', '/usr/bin', '/usr/sbin' ],
command => "setup-ds-admin.pl --file=${setup_inf_path} --silent",
unless => "/usr/bin/test -e /etc/dirsrv/slapd-${title}",
logoutput => true,
case $::port389::ensure {
'present', 'latest': {
# disable bucketting since the .inf file contains password information
file { $setup_inf_name:
ensure => file,
path => $setup_inf_path,
owner => $::port389::user,
group => $::port389::group,
mode => '0600',
content => template("${module_name}/inf.erb"),
backup => false,
} ->
# /usr/sbin/setup-ds-admin.pl needs:
# /bin/{grep, cat, uname, sleep, ...}
# /sbin/service
# /usr/bin/env
exec { "setup-ds-admin.pl_${title}":
path => [ '/bin', '/sbin', '/usr/bin', '/usr/sbin' ],
command => "setup-ds-admin.pl --file=${setup_inf_path} --silent",
unless => "/usr/bin/test -e /etc/dirsrv/slapd-${title}",
logoutput => true,
}
}
default: {
warning("it is meaningless to declare Port389::Instance[${name}] while Class[port389]{ ensure => 'absent|purged' }")
}
}
}
30 changes: 29 additions & 1 deletion spec/defines/port389_instance_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,34 @@
end

end # schema_file =>
end
end # setup.inf

context 'class { port389: ensure => ... }' do
let(:title) { 'ldap1' }

%w{ present latest }.each do |state|
context state do
let(:pre_condition) do <<-EOS
class { 'port389': ensure => #{state} }
EOS
end

it { should contain_file('setup_ldap1.inf') }
it { should contain_exec('setup-ds-admin.pl_ldap1') }
end
end

%w{ absent purged }.each do |state|
context state do
let(:pre_condition) do <<-EOS
class { 'port389': ensure => #{state} }
EOS
end

it { should_not contain_file('setup_ldap1.inf') }
it { should_not contain_exec('setup-ds-admin.pl_ldap1') }
end
end
end # class { port389: ensure => ... }

end

0 comments on commit bb7c059

Please sign in to comment.