Puppet Class: bigtop::hue

Defined in:
modules/bigtop/manifests/hue.pp

Overview

SPDX-License-Identifier: Apache-2.0

Class bigtop::hue

Installs hue, sets up the hue.ini file and ensures that hue server is running. This requires that bigtop::hadoop is included.

If bigtop::hive is included on this node, hue will be configured to interface with hive.

Parameters

$http_host - IP for webservice to bind. $http_port - Port for webservice to bind. $secret_key - Secret key used for session hashing. $app_blacklist - Array of application names that Hue should not load.

Default: hbase, impala, search, spark, rdbms, zookeeper

$hive_server_host - FQDN of host running hive-server2

$proxy_whitelist - Comma-separated regular expressions,

which match 'host:port' of requested proxy target.
Default: (localhost|127\.0\.0\.1):(50030|50070|50060|50075|8088|8042|19888|11001)

$proxy_blacklist - Comma-separated regular expressions,

which match any prefix of 'host:port/path' of requested
proxy target.  Default: undef

$smtp_host - SMTP host for email notifications.

Default: undef, SMTP will not be configured.

$smtp_port - SMTP port. Default: 25 $smtp_from_email - Sender email address of notifications. Default: undef $smtp_username - Username for SMTP authentication. Default: undef $smtp_password - Password for SMTP authentication. Default: undef

$httpfs_enabled - If true, Hue will be configured to interact with HDFS via

HttpFS rather than the default WebHDFS.  You must
manually configure HttpFS on your namenode.

$webhdfs_enabled - If true, Hue will be configured to interact with HDFS

using WebHDFS.

$ssl_private_key - Path to SSL private key. Default: /etc/hue/hue.key $ssl_certificate - Path to SSL certificate. Default: /etc/hue/hue.cert

If ssl_private_key and ssl_certificate are set to the defaults,
a self-signed certificate will be generated automatically for you.

$secure_proxy_ssl_header - Django support for HTTPS termination at the load-balancer

level with SECURE_PROXY_SSL_HEADER.
See: https://github.com/cloudera/hue/pull/68
Default: false

$use_(yarn|hdfs|mapred)_ssl_config - Use the SSL/TLS ports for the Yarn/HDFS/MapRed config

in hue.ini

$ssl_cacerts - Path to the .pem certificate related to the trusted TLS CA.

Database parameters:

The default DB is Sqlite, but it is possible to configure a external database. Database schema/username/tables creation is not handled by puppet but it is expected to be there before proceeding. INFO: www.cloudera.com/documentation/enterprise/5-5-x/topics/cdh_ig_hue_database.html

$database_username - Database username. Default: undef $database_password - Database password. Default: undef $database_host - Database hostname. Default: undef $database_port - Database port. Default: undef $database_engine - Database type. Default: sqlite3 $database_name - Database name. Default: /var/lib/hue/desktop.db

LDAP parameters:

See hue.ini comments for documentation. By default these are undefined.

$ldap_url $ldap_cert $ldap_nt_domain $ldap_bind_dn $ldap_base_dn $ldap_bind_password $ldap_username_pattern $ldap_user_filter $ldap_user_name_attr $ldap_group_filter $ldap_group_name_attr $ldap_group_member_attr $ldap_create_users_on_login - Default: true

Parameters:

  • http_host (Any) (defaults to: '0.0.0.0')
  • http_port (Any) (defaults to: 8888)
  • secret_key (Any) (defaults to: undef)
  • app_blacklist (Any) (defaults to: ['hbase', 'impala', 'search', 'spark', 'rdbms', 'zookeeper'])
  • hive_server_host (Any) (defaults to: undef)
  • proxy_whitelist (Any) (defaults to: undef)
  • proxy_blacklist (Any) (defaults to: undef)
  • smtp_host (Any) (defaults to: 'localhost')
  • smtp_port (Any) (defaults to: 25)
  • smtp_user (Any) (defaults to: undef)
  • smtp_password (Any) (defaults to: undef)
  • smtp_from_email (Any) (defaults to: undef)
  • ssl_cacerts (Any) (defaults to: undef)
  • ssl_private_key (Any) (defaults to: '/etc/ssl/private/hue.key')
  • ssl_certificate (Any) (defaults to: '/etc/ssl/certs/hue.cert')
  • secure_proxy_ssl_header (Any) (defaults to: false)
  • use_yarn_ssl_config (Any) (defaults to: false)
  • use_hdfs_ssl_config (Any) (defaults to: false)
  • use_mapred_ssl_config (Any) (defaults to: false)
  • ldap_url (Any) (defaults to: undef)
  • ldap_cert (Any) (defaults to: undef)
  • ldap_nt_domain (Any) (defaults to: undef)
  • ldap_bind_dn (Any) (defaults to: undef)
  • ldap_base_dn (Any) (defaults to: undef)
  • ldap_bind_password (Any) (defaults to: undef)
  • ldap_username_pattern (Any) (defaults to: undef)
  • ldap_user_filter (Any) (defaults to: undef)
  • ldap_user_name_attr (Any) (defaults to: undef)
  • ldap_group_filter (Any) (defaults to: undef)
  • ldap_group_name_attr (Any) (defaults to: undef)
  • ldap_group_member_attr (Any) (defaults to: undef)
  • ldap_create_users_on_login (Any) (defaults to: true)
  • hue_ini_template (Any) (defaults to: 'bigtop/hue/hue.ini.erb')
  • hue_log4j_template (Any) (defaults to: 'bigtop/hue/log4j.properties.erb')
  • hue_log_conf_template (Any) (defaults to: 'bigtop/hue/log.conf.erb')
  • database_host (Any) (defaults to: undef)
  • database_port (Any) (defaults to: undef)
  • database_user (Any) (defaults to: undef)
  • database_password (Any) (defaults to: undef)
  • database_name (Any) (defaults to: '/var/lib/hue/desktop.db')
  • database_engine (Any) (defaults to: 'sqlite3')
  • kerberos_keytab (Any) (defaults to: undef)
  • kerberos_principal (Any) (defaults to: undef)
  • kerberos_kinit_path (Any) (defaults to: undef)
  • use_hue4_settings (Any) (defaults to: false)
  • auth_backend (Any) (defaults to: 'ldap')
  • hive_thrift_version (Any) (defaults to: undef)


82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
# File 'modules/bigtop/manifests/hue.pp', line 82

class bigtop::hue(
    $http_host                  = '0.0.0.0',
    $http_port                  = 8888,
    $secret_key                 = undef,
    $app_blacklist              = ['hbase', 'impala', 'search', 'spark', 'rdbms', 'zookeeper'],

    $hive_server_host           = undef,

    $proxy_whitelist            = undef,
    $proxy_blacklist            = undef,

    $smtp_host                  = 'localhost',
    $smtp_port                  = 25,
    $smtp_user                  = undef,
    $smtp_password              = undef,
    $smtp_from_email            = undef,

    $ssl_cacerts                = undef,
    $ssl_private_key            = '/etc/ssl/private/hue.key',
    $ssl_certificate            = '/etc/ssl/certs/hue.cert',
    $secure_proxy_ssl_header    = false,

    $use_yarn_ssl_config        = false,
    $use_hdfs_ssl_config        = false,
    $use_mapred_ssl_config      = false,

    $ldap_url                   = undef,
    $ldap_cert                  = undef,
    $ldap_nt_domain             = undef,
    $ldap_bind_dn               = undef,
    $ldap_base_dn               = undef,
    $ldap_bind_password         = undef,
    $ldap_username_pattern      = undef,
    $ldap_user_filter           = undef,
    $ldap_user_name_attr        = undef,
    $ldap_group_filter          = undef,
    $ldap_group_name_attr       = undef,
    $ldap_group_member_attr     = undef,
    $ldap_create_users_on_login = true,

    $hue_ini_template           = 'bigtop/hue/hue.ini.erb',
    $hue_log4j_template         = 'bigtop/hue/log4j.properties.erb',
    $hue_log_conf_template      = 'bigtop/hue/log.conf.erb',

    $database_host              = undef,
    $database_port              = undef,
    $database_user              = undef,
    $database_password          = undef,
    $database_name              = '/var/lib/hue/desktop.db',
    $database_engine            = 'sqlite3',

    $kerberos_keytab            = undef,
    $kerberos_principal         = undef,
    $kerberos_kinit_path        = undef,

    $use_hue4_settings          = false,
    $auth_backend               = 'ldap',

    $hive_thrift_version        = undef,

) {
    Class['bigtop::hadoop'] -> Class['bigtop::hue']

    # The Hue 4.x package is not provided by CDH, but it is packaged
    # internally by us. Some options are different, including the config
    # paths under /etc/hue.
    if $use_hue4_settings {
        $config_directory = '/etc/hue'
        $gunicorn_work_class = 'sync'
    } else {
        $gunicorn_work_class = undef
        $config_directory = "/etc/hue/conf.${bigtop::hadoop::cluster_name}"
    }

    $namenode_hosts = $bigtop::hadoop::namenode_hosts
    $yarn_rm_http_protocol = $use_yarn_ssl_config ? {
        true    => 'https',
        default => 'http',
    }
    $yarn_rm_port = $use_yarn_ssl_config ? {
        true    => '8090',
        default => '8088',
    }
    $yarn_nm_port = $use_yarn_ssl_config ? {
        true    => '8044',
        default => '8042',
    }
    $hdfs_nn_http_protocol = $use_hdfs_ssl_config ? {
        true    => 'https',
        default => 'http',
    }
    $hdfs_nn_port = $use_hdfs_ssl_config ? {
        true    => '50470',
        default => '50070',
    }
    $hdfs_dn_port = $use_hdfs_ssl_config ? {
        true    => '50475',
        default => '50075',
    }
    $mapred_history_http_protocol = $use_mapred_ssl_config ? {
        true    => 'https',
        default => 'http',
    }
    $mapred_history_port = $use_mapred_ssl_config ? {
        true    => '19890',
        default => '19888',
    }
    if $proxy_whitelist {
        $proxy_whitelist_final = $proxy_whitelist
    } else {
        $proxy_whitelist_final = [
            # namenode + resourcemanager + history server host and ports
            inline_template("(<%= @namenode_hosts.join('|') %>):(<%= @yarn_rm_port %>|<%= @hdfs_nn_port %>|<%= @mapred_history_port %>)"),
            # No way to determine DataNode or NodeManager hostname defaults.
            # If you want to restrict this, make sure you override $proxy_whitelist parameter.
            ".+:(${hdfs_dn_port}| ${yarn_nm_port})",
        ]
    }

    # If httpfs is enabled, the default httpfs port
    # will be used, instead of the webhdfs port.
    $httpfs_enabled = $bigtop::hadoop::httpfs_enabled
    $webhdfs_enabled = $bigtop::hadoop::webhdfs_enabled

    package { 'hue':
        ensure => 'installed'
    }

    # Needed to support Kerberos with GSS-API and SASLß
    package { 'libsasl2-modules-gssapi-mit': }

    # Create the $cluster_name based $config_directory.
    file { $config_directory:
        ensure  => 'directory',
        require => Package['hue'],
    }
    bigtop::alternative { 'hue-conf':
        link => '/etc/hue/conf',
        path => $config_directory,
    }

    # Managing the hue user here so we can add
    # it to the hive group if hive-site.xml is
    # not world readable.
    user { 'hue':
        gid        => 'hue',
        comment    => 'Hue daemon',
        home       => '/usr/lib/hue',
        shell      => '/bin/false',
        managehome => false,
        system     => true,
        require    => Package['hue'],
    }
    # hive-site.xml might not be world readable.
    if defined(Class['bigtop::hive']) {
        # Below, if hive is enabled, the hue
        # user will be added to the hive group.
        # It isn't added here because Puppet only
        # allows group addtions to a User once,
        # and we might also have to add the ssl-cert group.
        $hive_enabled = true

        # make sure bigtop::hive is applied before bigtop::hue.
        Class['bigtop::hive']  -> Class['bigtop::hue']
    }

    # If SSL file paths are given, configure Hue to use SSL.
    if ($ssl_private_key and $ssl_certificate) {
        # Below, if ssl is enabled, the hue
        # user will be added to the ssl-cert group.
        # It isn't added here because Puppet only
        # allows group addtions to a User once,
        # and we might also have to add the hive group.
        # Adding the ssl-cert group allows hue to read
        # files in /etc/ssl/private.
        $ssl_enabled = true
        if (!defined(Package['openssl'])) {
            package { 'openssl':
                ensure => 'installed',
                before => User['hue'],
            }
        }
        if (!defined(Package['ssl-cert'])) {
            package { 'ssl-cert':
                ensure => 'installed',
                before => User['hue'],
            }
        }
        if (!defined(Package['python-openssl'])) {
            package { 'python-openssl':
                ensure => 'installed',
            }
        }

        # If the SSL settings are left at the defaults,
        # then generate a default self-signed certificate.
        if (($ssl_private_key == '/etc/ssl/private/hue.key') and
            ($ssl_certificate == '/etc/ssl/certs/hue.cert')) {

            exec { 'generate_hue_ssl_private_key':
                command => "/usr/bin/openssl genrsa 2048 > ${ssl_private_key}",
                creates => $ssl_private_key,
                require => [Package['openssl'], User['hue']],
                notify  => Service['hue'],
                before  => File[$ssl_private_key],
            }
            exec { 'generate_hue_ssl_certificate':
                command => "/usr/bin/openssl req -new -x509 -nodes -sha1 -subj '/C=US/ST=Denial/L=Nonya/O=Dis/CN=www.example.com' -key ${ssl_private_key} -out ${ssl_certificate}",
                creates => $ssl_certificate,
                require => Exec['generate_hue_ssl_private_key'],
                notify  => Service['hue'],
                before  => File[$ssl_certificate],
            }
        }

        # Ensure SSL files have proper permissions.
        file { $ssl_private_key:
            mode   => '0440',
            owner  => 'root',
            group  => 'hue',
            before => Service['hue'],
        }
        file { $ssl_certificate:
            mode   => '0444',
            owner  => 'root',
            group  => 'hue',
            before => Service['hue'],
        }
    } else {
        $ssl_enabled = false
    }

    # Stupid Puppet hack:  Need to select all
    # of the groups we are going to add the
    # hue user to before we actually do it.

    # add hue to the proper groups based on hive
    # and ssl usage.
    if ($hive_enabled and $ssl_enabled) {
        $hue_groups = ['hive', 'ssl-cert']
    }
    elsif ($hive_enabled) {
        $hue_groups = ['hive']
    }
    elsif($ssl_enabled) {
        $hue_groups = ['ssl-cert']
    }

    if ($hue_groups) {
        # Add the hue user to the hive group.
        User['hue'] { groups +> $hue_groups }
    }

    $namenode_host = $::bigtop::hadoop::primary_namenode_host
    file { "${config_directory}/hue.ini":
        content => template($hue_ini_template),
        require => Package['hue'],
    }
    file { "${config_directory}/log4j.properties":
        content => template($hue_log4j_template),
        require => Package['hue'],
    }
    file { "${config_directory}/log.conf":
        content => template($hue_log_conf_template),
        require => Package['hue'],
    }

    service { 'hue':
        ensure     => 'running',
        enable     => true,
        hasrestart => true,
        hasstatus  => true,
        subscribe  => File["${config_directory}/hue.ini"],
        require    => [Package['hue'], User['hue']],
    }
}