From b08a9b908b9c9677fa7886a353d975481f1fd28f Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Mon, 30 Sep 2013 18:17:23 -0700 Subject: [PATCH] add selenium::install class with simple download support --- .fixtures.yml | 3 ++ Modulefile | 1 + Rakefile | 2 +- manifests/install.pp | 62 +++++++++++++++++++++++++++ manifests/params.pp | 5 ++- manifests/server.pp | 6 +-- spec/classes/selenium_install_spec.rb | 14 ++++++ 7 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 manifests/install.pp create mode 100644 spec/classes/selenium_install_spec.rb diff --git a/.fixtures.yml b/.fixtures.yml index b81c645..c90b371 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -3,5 +3,8 @@ fixtures: "stdlib": repo: "git://github.com/puppetlabs/puppetlabs-stdlib.git" ref: "3.0.0" + "wget": + repo: "git://github.com/maestrodev/puppet-wget.git" + ref: "v1.2.2" symlinks: "selenium": "#{source_dir}" diff --git a/Modulefile b/Modulefile index ca1a4b1..812ce2e 100644 --- a/Modulefile +++ b/Modulefile @@ -8,3 +8,4 @@ source 'https://github.com/jhoblitt/puppet-selenium.git' summary 'module skeleton' description 'module skeleton' dependency 'puppetlabs/stdlib', '>= 3.0.0' +dependency 'maestrodev/wget', '>= 0.0.1' diff --git a/Rakefile b/Rakefile index 29b1a33..69909fe 100644 --- a/Rakefile +++ b/Rakefile @@ -4,7 +4,7 @@ require 'puppet-syntax/tasks/puppet-syntax' require 'puppet-lint/tasks/puppet-lint' PuppetSyntax.exclude_paths = ["spec/fixtures/**/*"] -#PuppetLint.configuration.send("disable_class_inherits_from_params_class") +PuppetLint.configuration.send("disable_class_inherits_from_params_class") #PuppetLint.configuration.send("disable_variable_scope") PuppetLint.configuration.ignore_paths = ['pkg/**/*.pp', 'spec/**/*.pp', 'tests/**/*.pp'] diff --git a/manifests/install.pp b/manifests/install.pp new file mode 100644 index 0000000..8e6f316 --- /dev/null +++ b/manifests/install.pp @@ -0,0 +1,62 @@ +# == Class: megaraid::lsiget +# +# installs the `lsiget` utility for LSI MegaRAID controllers +# +# See: http://mycusthelp.info/LSI/_cs/AnswerDetail.aspx?inc=8264 +# +# +# === Parameters +# +# Accepts no parameters. +# +# +# === Examples +# +# class{ 'megaraid::lsiget': } +# +# +# === Authors +# +# Joshua Hoblitt +# +# +class selenium::install( + $version = '2.35.0', + $url = undef, +) inherits selenium::server { + validate_string($version) + validate_string($url) + + include wget + + $jar_name = "selenium-server-standalone-${version}.jar" + + if $url { + $jar_url = $url + } else { + $jar_url = "https://selenium.googlecode.com/files/${jar_name}" + } + + File { + owner => $selenium::server::user, + group => $selenium::server::group, + } + + file { $selenium::server::install_path: + ensure => directory, + } + + $jar_path = "${selenium::server::install_path}/jars" + + file { $jar_path: + ensure => directory, + } + + wget::fetch { 'selenium-server-standalone': + source => $jar_url, + destination => "${selenium::server::jar_path}/${jar_name}", + timeout => 30, + require => File[$jar_path], + } + +} diff --git a/manifests/params.pp b/manifests/params.pp index 87027da..bb4e0c0 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -4,8 +4,9 @@ # # class selenium::params { - $user = 'selenium' - $group = $user + $user = 'selenium' + $group = $user + $install_path = '/opt/selenium' case $::osfamily { 'redhat': {} diff --git a/manifests/server.pp b/manifests/server.pp index 11a5020..6b567a2 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -7,14 +7,14 @@ # include selenium::server # class selenium::server( - $user = $selenium::params::user, - $group = $selenium::params::group, + $user = $selenium::params::user, + $group = $selenium::params::group, + $install_path = $selenium::params::install_path, ) inherits selenium::params { validate_string($user) validate_string($group) user { $user: - managehome => true, gid => [$group], } group { $group: } diff --git a/spec/classes/selenium_install_spec.rb b/spec/classes/selenium_install_spec.rb new file mode 100644 index 0000000..5c1ccb4 --- /dev/null +++ b/spec/classes/selenium_install_spec.rb @@ -0,0 +1,14 @@ +require 'spec_helper' + +describe 'selenium::install' do + let(:title) { 'redhat' } + let(:facts) {{ :osfamily=> 'RedHat' }} + + it do + should include_class('wget') + should contain_class('selenium::install').with_version('2.35.0') + should contain_file('/opt/selenium').with_ensure('directory') + should contain_wget__fetch('selenium-server-standalone') + end + +end