From ede6460b6856edc99ca828a6615a955fb9cd4ea5 Mon Sep 17 00:00:00 2001 From: Bohdan Astapov Date: Sun, 8 Oct 2017 18:45:52 +0300 Subject: [PATCH] Promote to v0.2.0 --- .rubocop.yml | 6 +++ .travis.yml | 1 - README.md | 53 +++++++++++++++---- lib/puppet/parser/functions/get_mirrors.rb | 17 +++--- manifests/init.pp | 6 ++- manifests/install.pp | 60 +++++++++++----------- manifests/preprovision.pp | 4 -- 7 files changed, 92 insertions(+), 55 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 72d2f75..6ef64fa 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -23,6 +23,12 @@ RSpec/BeforeAfterAll: RSpec/HookArgument: Description: Prefer explicit :each argument, matching existing module's style EnforcedStyle: each +Style/HashSyntax: + Description: >- + Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax + { :a => 1, :b => 2 }. + StyleGuide: '#hash-literals' + Enabled: false Style/BlockDelimiters: Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to be consistent then. diff --git a/.travis.yml b/.travis.yml index 4e25969..3ec8e0d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,4 +37,3 @@ deploy: on: tags: true all_branches: true - condition: "$DEPLOY_TO_FORGE = yes" diff --git a/README.md b/README.md index fb930f8..0e9bba3 100644 --- a/README.md +++ b/README.md @@ -22,10 +22,11 @@ This module installs, deploys and configures [Apache Guacomole](#https://guacamo ### What guacamole affects **OPTIONAL** * Install Guacamole required packages. -* Install Tomcat 8 and deploy Guacd to him. +* Build & Deploy guacd +* (OPTIONAL) Install Tomcat 8, deploy guacamole to him. * Configure unlimited amount of users with connection list. -### Setup Requirements **OPTIONAL** +### Setup Requirements Just install dependent modules. @@ -52,7 +53,8 @@ Just install dependent modules. }, } class { 'guacamole': - guacd_listen_port => '4822' + guacd_listen_port => '4822', + install_tomcat => true } # Create an user in Guacamole with available connections as $hashes guacamole::user { 'bohdan': @@ -64,18 +66,52 @@ Just install dependent modules. ## Reference For all usage you just need ::guacamole and ::guacamole::user. -Will finish this section later. - +#### guacamole +The base class sets defaults used by other defined types, such as `guacamole::install`. + +##### `guacd_listen_ip` +Specifies an IP for guacd to bind for. Basically, should be localhost, so you could omit this option. +##### `guacd_listen_port` +Same as above. +##### `server_version` +Specifies the version of Guacamole to build & install. Default to '0.9.13' but you could always change it to newer version from [here](https://guacamole.incubator.apache.org/releases/) +##### `install_tomcat` +Boolean. Specifies should this module install Tomcat 8 for you. Defaults to true. If you want to use your own installation of Tomcat you have to add something like this one to your modules: +``` +$closest_mirror = get_mirrors('https://www.apache.org/dyn/closer.cgi?as_json=1') +tomcat::war { 'guacamole.war': + catalina_base => '/opt/tomcat', + war_source => "${closest_mirror}incubator/guacamole/${server_version}-incubating/binary/guacamole-${server_version}-incubating.war", +} +``` +#### guacamole::user +Defined class that being used for creation of users and connections for them. Might be initiated as more as you need it. +##### Title +Title of the resource applies to username for new/exist user. +``` +guacamole::user { 'username' + ... +} +``` +##### `password` +Plain text password for user (might also be md5 encrypted with md5_encrypted variable) +##### `md5_encrypted` +Boolean. Sets password format as md5. Feel free to use [this](http://www.md5online.org/md5-encrypt.html) ## Limitations -By now this module applies only for CentOS7(6 maybe). +By now this module applies only for CentOS7 (and probably 6 version too). ## Development Feel free to fork, pull requests and so on. ## Release Notes/Contributors/Etc. - +``` +0.2.0: + - Added install_tomcat variable to use your own instances. + - Added determining of closest mirror to download tomcat / guacamole. + - Few small fixes. +``` ``` 0.1.0: - First version of this cute module. @@ -84,7 +120,6 @@ Feel free to fork, pull requests and so on. ## TODO ``` -- Implement usage of your own Tomcat instances. - Add Debian/Ubuntu support -- Add function to determine closest apache mirror. +- Implement md5 encryption from plain text. ``` diff --git a/lib/puppet/parser/functions/get_mirrors.rb b/lib/puppet/parser/functions/get_mirrors.rb index 633a74c..ba43ff3 100644 --- a/lib/puppet/parser/functions/get_mirrors.rb +++ b/lib/puppet/parser/functions/get_mirrors.rb @@ -1,10 +1,11 @@ -require 'rest-client' +require 'net/http' require 'json' +# Add func module Puppet::Parser::Functions - newfunction(:get_mirrors, :type => :rvalue) do - url = 'https://www.apache.org/dyn/closer.cgi?as_json=1' - res = RestClient.get(url) - data = JSON.parse(res.body) - data['preferred'] - end -end \ No newline at end of file + newfunction(:get_mirrors, :type => :rvalue) do |args| + url = args[0] + resp = Net::HTTP.get_response(URI.parse(url)) + data = resp.body + JSON.parse(data)['preferred'] + end +end diff --git a/manifests/init.pp b/manifests/init.pp index afb812d..be736e4 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -14,12 +14,14 @@ class guacamole ( String $server_version = '0.9.13', String $guacd_listen_ip = '127.0.0.1', - String $guacd_listen_port = '4822' + String $guacd_listen_port = '4822', + Boolean $install_tomcat = true, ) { class { '::guacamole::install': server_version => $server_version, guacd_listen_ip => $guacd_listen_ip, - guacd_listen_port => $guacd_listen_port + guacd_listen_port => $guacd_listen_port, + install_tomcat => $install_tomcat } include guacamole::preprovision Class['guacamole::preprovision'] -> Class['guacamole::install'] diff --git a/manifests/install.pp b/manifests/install.pp index 6c5215e..47f9474 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -5,24 +5,38 @@ class guacamole::install ( String $server_version = '0.9.13', String $guacd_listen_ip = '127.0.0.1', - String $guacd_listen_port = '4822' + String $guacd_listen_port = '4822', + Boolean $install_tomcat = true, ) { $tomcat_version = '8.5.23' - tomcat::install { '/opt/tomcat': - source_url => "http://${closest_mirror}tomcat/tomcat-8/v${tomcat_version}/bin/apache-tomcat-${tomcat_version}.tar.gz", - } - tomcat::instance { 'default': - catalina_home => '/opt/tomcat', - #manage_service => true, - } - # @TODO: Add function to determine closest mirror - if ! defined(Package['gnome-session-fallback']) { - package { 'gnome-session-fallback': - ensure => installed, + $closest_mirror = get_mirrors('https://www.apache.org/dyn/closer.cgi?as_json=1') + + if $install_tomcat { + tomcat::install { '/opt/tomcat': + source_url => "${closest_mirror}tomcat/tomcat-8/v${tomcat_version}/bin/apache-tomcat-${tomcat_version}.tar.gz", + } + tomcat::instance { 'default': + catalina_home => '/opt/tomcat', + #manage_service => true, + } + service { 'tomcat': + ensure => running, + start => '/opt/tomcat/bin/startup.sh', + stop => '/opt/tomcat/bin/shutdown.sh', + restart => '/opt/tomcat/bin/shutdown.sh && /opt/tomcat/bin/startup.sh', # genius + status => "ps aux | grep 'catalina.base=/opt/tomcat' | grep -v grep", + hasstatus => true, + hasrestart => true, + #require => Tomcat::Instance['default'], + #subscribe => File['/etc/guacamole/guacd.conf'] + } + File['/etc/guacamole/guacd.conf'] ~> Service['tomcat'] + tomcat::war { 'guacamole.war': + catalina_base => '/opt/tomcat', + war_source => "${closest_mirror}incubator/guacamole/${server_version}-incubating/binary/guacamole-${server_version}-incubating.war", + } } -} - $closest_mirror = get_mirrors() - #$closest_mirror = 'http://apache.volia.net' + file { [ '/etc/guacamole', '/etc/guacamole/extensions', '/etc/guacamole/lib', '/tmp/gcml' ]: ensure => directory @@ -50,22 +64,6 @@ line => 'GUACAMOLE_HOME=/etc/guacamole/', match => 'GUACAMOLE_HOME=', } - service { 'tomcat': - ensure => running, - #provider => 'init' - start => '/opt/tomcat/bin/startup.sh', - stop => '/opt/tomcat/bin/shutdown.sh', - restart => '/opt/tomcat/bin/shutdown.sh && /opt/tomcat/bin/startup.sh', # genius - status => "ps aux | grep 'catalina.base=/opt/tomcat' | grep -v grep", - hasstatus => true, - hasrestart => true, - #require => Tomcat::Instance['default'], - subscribe => File['/etc/guacamole/guacd.conf'] - } - tomcat::war { 'guacamole.war': - catalina_base => '/opt/tomcat', - war_source => "${closest_mirror}incubator/guacamole/${server_version}-incubating/binary/guacamole-${server_version}-incubating.war", - } file { '/etc/guacamole/guacd.conf': ensure => file, diff --git a/manifests/preprovision.pp b/manifests/preprovision.pp index fed29cc..0c0b027 100644 --- a/manifests/preprovision.pp +++ b/manifests/preprovision.pp @@ -16,10 +16,6 @@ ensure => present, provider => yum } - package { 'rest-client': - ensure => present, - provider => gem - } package { 'nux-dextop-release': ensure => present, provider => 'rpm',