Skip to content

Commit

Permalink
Promote to v0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Bohdan Astapov committed Oct 8, 2017
1 parent c980781 commit ede6460
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 55 deletions.
6 changes: 6 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,3 @@ deploy:
on:
tags: true
all_branches: true
condition: "$DEPLOY_TO_FORGE = yes"
53 changes: 44 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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':
Expand All @@ -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.
Expand All @@ -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.
```
17 changes: 9 additions & 8 deletions lib/puppet/parser/functions/get_mirrors.rb
Original file line number Diff line number Diff line change
@@ -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
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
6 changes: 4 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
60 changes: 29 additions & 31 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 0 additions & 4 deletions manifests/preprovision.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
ensure => present,
provider => yum
}
package { 'rest-client':
ensure => present,
provider => gem
}
package { 'nux-dextop-release':
ensure => present,
provider => 'rpm',
Expand Down

0 comments on commit ede6460

Please sign in to comment.