From f4d53aa070adc8fb3d287e615e1023ac09cceef9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Sat, 17 Jan 2015 16:26:57 +0100 Subject: [PATCH] Possibility to specify custom principal for statistics. Always create environment file due to limitation in puppet. --- manifests/accounting.pp | 54 ++++++++++++++++++++---------- manifests/init.pp | 20 ++--------- templates/accounting/hadoop-accounting.erb | 3 ++ templates/accounting/hdfs.sh.erb | 2 +- 4 files changed, 43 insertions(+), 36 deletions(-) diff --git a/manifests/accounting.pp b/manifests/accounting.pp index 0b9d897..c1ec1e2 100644 --- a/manifests/accounting.pp +++ b/manifests/accounting.pp @@ -9,12 +9,12 @@ # include stdlib # # class{'site_hadoop': -# db_password => 'accpass', -# email => 'mail@example.com', # stage => 'setup', # } # # class{'site_hadoop::accountig': +# db_password => 'accpass', +# email => 'mail@example.com', # hdfs => '0,30 * * *', # } # @@ -31,12 +31,42 @@ # # === Parameters # +# ####`db_name` +# = undef (system default is *accounting*) +# +# Database name for statistics. +# +# ####`db_user` +# = undef (system default is *accounting*) +# +# Database user for statistics. +# +# ####`db_password` +# = undef +# +# Database password for statistics. +# +# ####`email` +# = undef +# +# Email address to send errors from cron. +# # [*hdfs*] undef # # Enable storing global HDFS disk and data statistics. The value is time in the cron format. See *man 5 crontab*. # +# ####`principal` +# = undef +# +# Kerberos principal to access Hadoop. +# class site_hadoop::accounting( + $db_name = undef, + $db_user = undef, + $db_password = undef, + $email = undef, $hdfs = undef, + $principal = undef, ) { file {'/usr/local/bin/accounting-hdfs': owner => 'root', @@ -66,23 +96,13 @@ class site_hadoop::accounting( source => 'puppet:///modules/site_hadoop/accounting/create.sql', } - $db_name = $site_hadoop::db_name - $db_user = $site_hadoop::db_user - $db_password = $site_hadoop::db_password - if $db_name or $db_user or $db_password { - file{"${site_hadoop::defaultconfdir}/hadoop-accounting": - owner => 'hdfs', - group => 'hdfs', - mode => '0400', - content => template('site_hadoop/accounting/hadoop-accounting.erb'), - } - } else { - file{"${site_hadoop::defaultconfdir}/hadoop-accounting": - ensure => 'absent', - } + file{"${site_hadoop::defaultconfdir}/hadoop-accounting": + owner => 'hdfs', + group => 'hdfs', + mode => '0400', + content => template('site_hadoop/accounting/hadoop-accounting.erb'), } - $email = $site_hadoop::email if $hdfs { file{'/etc/cron.d/accounting-hdfs': owner => 'root', diff --git a/manifests/init.pp b/manifests/init.pp index 41b9cea..cae77ac 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -4,21 +4,6 @@ # # ##Parameters # -# ####`db_name` -# = undef (system default is *accounting*) -# -# Database name for statistics. -# -# ####`db_user` -# = undef (system default is *accounting*) -# -# Database user for statistics. -# -# ####`db_password` -# = undef -# -# Database password for statistics. -# # ####`email` = undef # = undef # @@ -33,10 +18,9 @@ # * **cloudera** # * **scientific** # +# Kerberos realm to use. It needs to be specified, when security is enabled. +# class site_hadoop ( - $db_name = undef, - $db_user = undef, - $db_password = undef, $email = undef, $mirror = $site_hadoop::params::mirror, ) inherits site_hadoop::params { diff --git a/templates/accounting/hadoop-accounting.erb b/templates/accounting/hadoop-accounting.erb index 314e728..9b729af 100644 --- a/templates/accounting/hadoop-accounting.erb +++ b/templates/accounting/hadoop-accounting.erb @@ -7,3 +7,6 @@ MYSQL_USER='<%= @db_user -%>' <% if @db_password -%> MYSQL_PASSWORD='<%= @db_password -%>' <% end -%> +<% if @principal != nil -%> +PRINCIPAL='<%= @principal -%>' +<% end -%> diff --git a/templates/accounting/hdfs.sh.erb b/templates/accounting/hdfs.sh.erb index 7739754..a50c78c 100755 --- a/templates/accounting/hdfs.sh.erb +++ b/templates/accounting/hdfs.sh.erb @@ -6,7 +6,7 @@ export KRB5CCNAME='FILE:/tmp/krb5cc_hdfs_stat' KEYTAB='FILE:/etc/security/keytab/nn.service.keytab' PRINCIPAL="nn/`hostname -f`" MYSQL_DB='accounting' -MYSQL_USER='root' +MYSQL_USER='accounting' MYSQL_PASSWORD='' if test -f ${DEFAULTDIR}/hadoop-accounting; then -- 1.8.2.3