Skip to content

Commit

Permalink
Merge pull request #99 from dlanza1/master
Browse files Browse the repository at this point in the history
Provide option to remove host and realm from Kerberos principal
  • Loading branch information
deric authored Aug 22, 2017
2 parents 191d40b + 8291d0b commit 39a6ff4
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
6 changes: 5 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@
$realm = $::zookeeper::params::realm,
$store_key = $::zookeeper::params::store_key,
$use_keytab = $::zookeeper::params::use_keytab,
$use_ticket_cache = $::zookeeper::params::use_ticket_cache
$use_ticket_cache = $::zookeeper::params::use_ticket_cache,
$remove_host_principal = $::zookeeper::params::remove_host_principal,
$remove_realm_principal = $::zookeeper::params::remove_realm_principal,
) inherits ::zookeeper::params {

# validations are not necessary on Puppet 4
Expand All @@ -93,6 +95,8 @@
validate_bool($initialize_datastore)
validate_bool($manage_service)
validate_bool($use_sasl_auth)
validate_bool($remove_host_principal)
validate_bool($remove_realm_principal)
validate_hash($archive_checksum)
validate_integer($id)
validate_integer($init_limit)
Expand Down
2 changes: 2 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,6 @@
$store_key = true
$use_keytab = true
$use_ticket_cache = false
$remove_host_principal = false
$remove_realm_principal = false
}
36 changes: 36 additions & 0 deletions spec/classes/sasl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,40 @@
).with_content(/JAVA_OPTS="\${JAVA_OPTS} -Djava.security.auth.login.config=\/etc\/zookeeper\/conf\/jaas.conf"/)
end
end

context 'remove host and realm from principal' do
let(:facts) do
{
:operatingsystem => 'Debian',
:osfamily => 'Debian',
:operatingsystemmajrelease => '8',
:lsbdistcodename => 'jessie',
:puppetversion => Puppet.version,
}
end

let :pre_condition do
'class {"zookeeper":
use_sasl_auth => true,
remove_host_principal => true,
remove_realm_principal => true,
}'
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_class('zookeeper::sasl') }

it do
should contain_file(
'/etc/zookeeper/conf/zoo.cfg'
).with_content(/kerberos.removeHostFromPrincipal=true/)
end

it do
should contain_file(
'/etc/zookeeper/conf/zoo.cfg'
).with_content(/kerberos.removeRealmFromPrincipal=true/)
end

end
end
6 changes: 6 additions & 0 deletions templates/conf/zoo.cfg.erb
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,10 @@ maxSessionTimeout=<%= scope.lookupvar("zookeeper::max_session_timeout") %>
# Enable SASL authentication and use the default provider/renew provided by cloudera
authProvider.1=org.apache.zookeeper.server.auth.SASLAuthenticationProvider
jaasLoginRenew=3600000
<% if scope.lookupvar("zookeeper::remove_host_principal") -%>
kerberos.removeHostFromPrincipal=true
<% end -%>
<% if scope.lookupvar("zookeeper::remove_realm_principal") -%>
kerberos.removeRealmFromPrincipal=true
<% end -%>
<% end -%>

0 comments on commit 39a6ff4

Please sign in to comment.