Skip to content

Commit

Permalink
cleanup init.d template variable interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Hoblitt committed Oct 2, 2013
1 parent 45e77c2 commit 2aeebe7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
2 changes: 2 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#
class selenium::config {

$options = '-Dwebdriver.enable.native.events=1'

file { '/etc/init.d/selenium':
ensure => 'file',
owner => 'root',
Expand Down
16 changes: 9 additions & 7 deletions spec/classes/selenium_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
describe 'selenium::config', :type => :class do
let(:title) { 'redhat' }
let(:facts) {{ :osfamily=> 'RedHat' }}
let :pre_condition do
"class { 'selenium::server': display => 'foo' }"
end

context 'no params' do
let :pre_condition do
"class { 'selenium::server': }"
end

it do
should contain_class('selenium::config')
should contain_file('/etc/init.d/selenium').with({
Expand All @@ -16,10 +17,11 @@
'group' => 'root',
'mode' => '0755',
}).
with_content(/selenium-server-standalone/).
with_content(/SLNM_INSTALL_PATH=\/opt\/selenium/)
with_content(/SLNM_DISPLAY=:0/)
with_content(/SLNM_USER=selenium/)
with_content(/SLNM_DISPLAY=':0'/).
with_content(/SLNM_USER='selenium'/).
with_content(/SLNM_INSTALL_PATH='\/opt\/selenium'/).
with_content(/SLNM_JAR_NAME='selenium-server-standalone-2.35.0.jar'/).
with_content(/SLNM_OPTIONS='-Dwebdriver.enable.native.events=1'/)
end
end

Expand Down
12 changes: 7 additions & 5 deletions templates/init.d/selenium.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
# Source function library.
. /etc/rc.d/init.d/functions

SLNM_INSTALL_PATH=<% scope.lookupvar('selenium::server::install_path') %>
SLNM_DISPLAY=<% scope.lookupvar('selenium::server::display') %>
SLNM_USER=<%= scope.lookupvar('selenium::server::user') %>
SLNM_DISPLAY='<%= scope.lookupvar('selenium::server::display') %>'
SLNM_USER='<%= scope.lookupvar('selenium::server::user') %>'
SLNM_INSTALL_PATH='<%= scope.lookupvar('selenium::server::install_path') %>'
SLNM_JAR_NAME='<%= scope.lookupvar('selenium::install::jar_name') %>'
SLNM_OPTIONS='<%= scope.lookupvar('selenium::config::options') %>'

SLNM_LOG="${SLNM_INSTALL_PATH}/log/server.log"
SLNM_ERROR_LOG="${SLNM_INSTALL_PATH}/log/error.log"
SLNM_JAR="${SLNM_INSTALL_PATH}/opt/selenium/jars/selenium-server-standalone-2.35.0.jar"
SLNM_OPTIONS='-Dwebdriver.enable.native.events=1'
SLNM_JAR="${SLNM_INSTALL_PATH}/jars/${SLNM_JAR_NAME}"

prog="selenium"
#config="<path to major config file>"
Expand Down

0 comments on commit 2aeebe7

Please sign in to comment.