Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
devcfgc committed Mar 1, 2018
0 parents commit 49dda5a
Show file tree
Hide file tree
Showing 10 changed files with 541 additions and 0 deletions.
138 changes: 138 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# hue

#### Table of Contents

1. [Overview](#overview)
2. [Module Description - What the module does and why it is useful](#module-description)
3. [Setup - The basics of getting started with hue](#setup)
* [What hue affects](#what-hue-affects)
4. [Usage - Configuration options and additional functionality](#usage)
5. [Reference - An under-the-hood peek at what the module is doing and how](#reference)
5. [Limitations - OS compatibility, etc.](#limitations)
6. [Development - Guide for contributing to the module](#development)

## Overview

Module to install and configure Cloudera's Hue in your cluster. It has been
tested on CentOS7 with an Ambari Distribution.

## Module Description

If applicable, this section should have a brief description of the technology
the module integrates with and what that integration enables. This section
should answer the questions: "What does this module *do*?" and "Why would I use
it?"

If your module has a range of functionality (installation, configuration,
management, etc.) this is the time to mention it.

## Setup

### Pre-requisites

A Java Development Kit must be installed.

### What hue affects

The following packages will be installed by this module :
* wget
* ant
* gcc
* make
* maven
* asciidoc
* cyrus-sasl-devel
* cyrus-sasl-gssapi
* cyrus-sasl-plain
* gcc-c++
* rb5-devel
* libxml2-devel
* libxslt-devel
* mariadb-devel
* openldap-devel
* python-devel
* sqlite-devel
* openssl-devel
* gmp-devel


## Usage

To install hue simply include the hue class, it will install it and configure
it to be pointing at a localhost cluster.
```
class {'hue': }
```

### There are several parameters you can use to customize the installation:

* **$hue_log_dir:** By default hue stores it's logs in the installation folder which
is not the most desirable option, and this parameter puts the log folder in the
location specified.

* **$hue_user:** User that will be runinng hue services (hue by default).

* **$hue_group:** Group for the hue user (hue by default).

* **$hue_install_dir:** Root path where hue will be installed (/home/$hue_user by default).
**Note:** Hue will be installed in a "hue" subdir under $hue_install_dir folder.

* **$config_values:** Here you can set the config for the different services, the
default one is provided as an example
```
$config_values = {
'hadoop' => {
'fs_defaultfs' => 'hdfs://node-1.cluster:8020',
'webhdfs_url' => "http://${::fqdn}:50070/webhdfs/v1",
'resourcemanager_host' => $::fqdn,
'resourcemanager_api_url' => "http://${::fqdn}:8088",
'proxy_api_url' => "http://${::fqdn}:8088",
'history_server_api_url' => "http://${::fqdn}:19888",
},
'desktop' => {
'app_blacklist' => 'impala ',
'secret_key' => 'GFDSKgf90i54opjge809t5uy4jogi9n9v9vp4528mv90pu459vgfd$',
},
'liboozie' => { 'oozie_url' => "http://${::fqdn}:11000/oozie", },
'beeswax' => { 'hive_server_host' => $::fqdn, },
'sqoop' => { 'server_url' => "http://${::fqdn}:12000/sqoop", },
'hbase' => { 'hbase_clusters' => "(${::fqdn}|${::ipaddress}:9090)", },
'zookeeper' => { 'host_ports' => "${::fqdn}:2181", },
'spark' => { 'livy_server_host' => "http://${::fqdn}:8090", },
}
```
**The following parameters are provided just in case you want to install another
hue version in order to be able to "adapt" to that version changes (tarball name
, config directories, etc...):**

* **$hue_config_file:** Full path to the hue.ini file
("${hue_install_dir}/hue/desktop/conf/hue.ini" by default)

* **$hue_bin_dir:** Full path to the hue's bin folder ("${hue_install_dir}/hue/build/env/bin" by default)

* **$hue_releases_archive_url:** Hue release tarball's url

* **$hue_release_package_file:** Tarball filename

* **$hue_release_package_folder:** Subfolder created by the tarball's uncompression.

* **common_packages:**

* **os_specific_packages:**

## Reference

Here, list the classes, types, providers, facts, etc contained in your module.
This section should include all of the under-the-hood workings of your module so
people know what the module is touching on their system but don't need to mess
with things. (We are working on automating this section!)

## Limitations

Right now it works with CentOS7, but integration with other OS's should be
fairly simple, just using the appropriate packages for each OS.

## Development

Feel free to add any extra functionality to the module.
# puppet-hue
41 changes: 41 additions & 0 deletions lib/puppet/parser/functions/ini_settings.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module Puppet::Parser::Functions
newfunction(:ini_settings, :type => :rvalue, :doc => <<-EOS
Creates a hue.ini sections and subsections from a hash:
$settings = { section1 => {
setting1 => val1
},
section2 => {
setting2 => val2,
subsection1 => {
setting3 => val3
}
}
}
[section1]
setting1=val1
[section2]
setting2=val2
[[subsection1]]
setting3=val3
EOS
) do |arguments|
raise(Puppet::ParseError, "ini_settings(): Wrong number of arguments") if arguments.size != 1
raise(Puppet::ParseError, "ini_settings(): Not an hash") if !arguments[0].is_a?(Hash)

return ini_section(arguments[0])
end
end

def ini_section(section, n=1)
ini = []
section.each do |k,v|
if v.is_a?(Hash)
ini << (" " * n) + ("[" * n) + k + ("]" * n)
ini << ini_section(v, n + 1)
else
ini << (" " * (n + 1)) + "#{k}=#{v}"
end
end
return ini.join("\n") + "\n"
end

20 changes: 20 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class hue::config (
$hue_config_file,
$config_values,
){
if $caller_module_name != $module_name {
fail("Use of private class ${name} by ${caller_module_name}")
}

$hue_config = deep_merge($hue::config_defaults, $config_values)

file { $hue_config_file:
ensure => file,
content => template('hue/conf/hue.ini.erb'),
mode => '0644',
owner => 'hue',
group => 'hue',
notify => Service[ $hue::service_name ],
require => Exec[ 'install_hue' ],
}
}
48 changes: 48 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# == Class: hue
#
# This class will download, install and configure Cloudera's HUE
#
# === Authors
#
# Alejandro Montero <[email protected]>
#
class hue (
$version = $hue::params::version,
$mirror_url = $hue::params::mirror_url,
$config_values = $hue::params::config_values,
$hue_log_dir = $hue::params::hue_log_dir,
$hue_install_dir = $hue::params::hue_install_dir,
$hue_config_file = $hue::params::hue_config_file,
$hue_bin_dir = $hue::params::hue_bin_dir,
$common_packages = $hue::params::common_packages,
$os_specific_packages = $hue::params::os_specific_packages,
$hue_user = $hue::params::hue_user,
$hue_group = $hue::params::hue_group,
$service_name = $hue::params::service_name,
$extra_classpath = $hue::params::extra_classpath,
) inherits hue::params {

$hue_release_package_file = "hue-${version}.tgz"
$hue_releases_archive_url = "${mirror_url}/${version}"
$hue_release_package_folder = "hue-${version}"

anchor { 'hue::begin': } ->
class { '::hue::install':
hue_install_dir => $hue_install_dir,
hue_releases_archive_url => $hue_releases_archive_url,
hue_release_package_file => $hue_release_package_file,
hue_release_package_folder => $hue_release_package_folder,
hue_log_dir => $hue_log_dir,
common_packages => $common_packages,
os_specific_packages => $os_specific_packages,
hue_user => $hue_user,
hue_group => $hue_group,
} ->
class { '::hue::config':
hue_config_file => $hue_config_file,
config_values => $config_values,
} ~>
class { '::hue::service': } ->
anchor { 'hue::end': }

}
78 changes: 78 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
class hue::install(
$hue_releases_archive_url,
$hue_release_package_file,
$hue_release_package_folder,
$hue_install_dir,
$hue_log_dir,
$common_packages,
$os_specific_packages,
$hue_user,
$hue_group,
) {
if $caller_module_name != $module_name {
fail("Use of private class ${name} by ${caller_module_name}")
}

$working_dir = '/tmp'
$local_repo_dir = "${working_dir}/hue"

ensure_resource('Package', $common_packages, { ensure => present } )
ensure_resource('Package', $os_specific_packages, {ensure => present} )

# Rsync must be checked this way or will complain about re-definition :-(
if !defined (Package['rsync']) {
package { 'rsync':
ensure => present,
before => Exec[ 'install_hue' ],
}
}

user { $hue_user:
ensure => present,
name => $hue_user,
managehome => true,
shell => '/bin/bash',
}

exec { 'download_hue_package':
command => "/usr/bin/wget ${hue_releases_archive_url}/${hue_release_package_file}",
cwd => $working_dir,
user => $hue_user,
creates => "${working_dir}/${hue_release_package_file}",
require => User[$hue_user],
}

exec { 'decompress_hue_package':
command => "/usr/bin/tar -zxvf ${hue_release_package_file}",
cwd => $working_dir,
user => $hue_user,
creates => "${working_dir}/${hue_release_package_folder}",
require => Exec['download_hue_package'],
}

exec { 'install_hue':
command => "/usr/bin/make install PREFIX=${hue_install_dir}",
cwd => "${working_dir}/${hue_release_package_folder}",
creates => "${hue_install_dir}/hue",
user => $hue_user,
timeout => '0',
require => [ Exec['decompress_hue_package'], Package[ $common_packages, $os_specific_packages ]],
}

file { $hue_log_dir:
ensure => directory,
owner => $hue_user,
group => $hue_group,
require => Exec['install_hue'],
}

# Change the logs dir to our desired path
file { "${hue_install_dir}/hue/logs":
ensure => 'link',
owner => $hue_user,
group => $hue_group,
force => true,
target => $hue_log_dir,
require => File[$hue_log_dir],
}
}
Loading

0 comments on commit 49dda5a

Please sign in to comment.