diff --git a/manifests/params.pp b/manifests/params.pp index 223e0e1c..a2b9c26e 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -5,49 +5,13 @@ class jira::params { Exec { path => ['/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/'] } - case $facts['os']['family'] { - /RedHat/: { - if $facts['os']['name'] == 'Amazon' and $facts['os']['release']['major'] =='2018' { - $json_packages = ['rubygem-json'] - $service_file_location = '/etc/init.d/jira' - $service_file_template = 'jira/jira.initscript.erb' - $service_file_mode = '0755' - $service_lockfile = '/var/lock/subsys/jira' - $service_provider = undef - } elsif versioncmp($facts['os']['release']['major'], '7') >= 0 { - $json_packages = ['rubygem-json'] - $service_file_location = '/usr/lib/systemd/system/jira.service' - $service_file_template = 'jira/jira.service.erb' - $service_file_mode = '0644' - $service_lockfile = '/var/lock/subsys/jira' - $service_provider = 'systemd' - } elsif versioncmp($facts['os']['release']['major'], '6') >= 0 { - $json_packages = ['rubygem-json', 'ruby-json'] - $service_file_location = '/etc/init.d/jira' - $service_file_template = 'jira/jira.initscript.erb' - $service_file_mode = '0755' - $service_lockfile = '/var/lock/subsys/jira' - $service_provider = undef - } else { - fail("\"${module_name}\" provides no service parameters - for \"${facts['os']['family']}\" - \"${$facts['os']['release']['major']}\"") - } - } - /Debian/: { - $json_packages = ['ruby-json'] - $service_file_location = '/lib/systemd/system/jira.service' - $service_file_template = 'jira/jira.service.erb' - $service_file_mode = '0644' - $service_lockfile = '/var/lock/subsys/jira' - $service_provider = 'systemd' - } - default: { - $json_packages = ['rubygem-json', 'ruby-json'] - $service_file_location = '/etc/init.d/jira' - $service_file_template = 'jira/jira.initscript.erb' - $service_file_mode = '0755' - $service_lockfile = '/var/lock/subsys/jira' - $service_provider = undef - } + $service_file_location = '/usr/lib/systemd/system/jira.service' + $service_file_template = 'jira/jira.service.erb' + $service_file_mode = '0644' + + $json_packages = $facts['os']['family'] ? { + 'RedHat' => ['rubygem-json'], + 'Debian' => ['ruby-json'], + default => [], } } diff --git a/manifests/service.pp b/manifests/service.pp index bc86ba7c..0d43df1c 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -23,8 +23,6 @@ $service_file_location = $jira::params::service_file_location, $service_file_template = $jira::params::service_file_template, $service_file_mode = $jira::params::service_file_mode, - $service_lockfile = $jira::params::service_lockfile, - $service_provider = $jira::params::service_provider, ) inherits jira::params { file { $service_file_location: @@ -33,13 +31,11 @@ } if $service_manage { - if $service_provider == 'systemd' { - exec { 'refresh_systemd': - command => 'systemctl daemon-reload', - refreshonly => true, - subscribe => File[$service_file_location], - before => Service['jira'], - } + exec { 'refresh_systemd': + command => 'systemctl daemon-reload', + refreshonly => true, + subscribe => File[$service_file_location], + before => Service['jira'], } service { 'jira': @@ -48,7 +44,6 @@ require => File[$service_file_location], notify => $service_notify, subscribe => $service_subscribe, - provider => $service_provider, } } } diff --git a/metadata.json b/metadata.json index 170c063a..5bdcf1a3 100644 --- a/metadata.json +++ b/metadata.json @@ -35,28 +35,24 @@ { "operatingsystem": "RedHat", "operatingsystemrelease": [ - "6", "7" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ - "6", "7" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ - "6", "7" ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ - "6", "7" ] }, diff --git a/spec/classes/jira_service_spec.rb b/spec/classes/jira_service_spec.rb index d6429e50..8dbf5460 100644 --- a/spec/classes/jira_service_spec.rb +++ b/spec/classes/jira_service_spec.rb @@ -15,35 +15,14 @@ 'package { "jdk": }' end - case facts[:os]['family'] - when 'RedHat' - service_file_location = if facts['service_provider'] == 'systemd' - '/usr/lib/systemd/system/jira.service' - else - '/etc/init.d/jira' - end - when 'Debian' - service_file_location = '/lib/systemd/system/jira.service' - end - context 'with defaults for all parameters' do it { is_expected.to compile.with_all_deps } - case facts['service_provider'] - when 'systemd' - it do - is_expected.to contain_file(service_file_location). - with_content(%r{Atlassian Systemd Jira Service}) - end - it { is_expected.to contain_exec('refresh_systemd') } - when 'redhat' - it do - is_expected.to contain_file(service_file_location). - with_content(%r{Short-Description: Start up JIRA}). - with_content(%r{lockfile=/var/lock/subsys/jira}) - end + it do + is_expected.to contain_file('/lib/systemd/system/jira.service'). + with_content(%r{Atlassian Systemd Jira Service}) end - + it { is_expected.to contain_exec('refresh_systemd') } it { is_expected.to contain_service('jira') } end diff --git a/templates/jira.initscript.erb b/templates/jira.initscript.erb deleted file mode 100644 index 61c4c411..00000000 --- a/templates/jira.initscript.erb +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/bash -#----------------------------------------------------------------------------- -# Copyright (c) 2012 Bryce Johnson -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#----------------------------------------------------------------------------- -### BEGIN INIT INFO -# Provides: jira -# Required-Start: -# Required-Stop: -# Should-Start: -# Should-Stop: -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Start up JIRA -# Description: Atlassian JIRA Issue Tracking and Project Management -# This service starts up the tomcat webapp. -### END INIT INFO -ACTION=$1 -SERVICE=jira -lockfile=<%= @service_lockfile %> -export JAVA_HOME=<%= scope.lookupvar('jira::javahome') %> -export CATALINA_HOME=<%= scope.lookupvar('jira::webappdir') %> - - -function restart() { - stop - start -} - -function stop() { - echo -n $"Shutting down $SERVICE: " - <%= scope.lookupvar('jira::webappdir') %>/bin/stop-jira.sh - RETVAL=$? - echo - - #If all is well remove the lockfile - [ $RETVAL -eq 0 ] && rm -f $lockfile - return $RETVAL -} - -function start() { - echo -n $"Starting $SERVICE: " - <%= scope.lookupvar('jira::webappdir') %>/bin/start-jira.sh - RETVAL=$? - echo - - #If all is well touch the lock file - [ $RETVAL -eq 0 ] && touch $lockfile - return $RETVAL -} - -function status() { - -STATUS=$( pgrep -F <%= scope.lookupvar('jira::webappdir') %>/work/catalina.pid ) || STATUS=0 - if [ $STATUS -ne 0 ];then - echo "$SERVICE is running" - return 0 - else - echo "$SERVICE is stopped" - return 1 - fi - -} - -function execute() { - case "$ACTION" in - start) - start - ;; - stop) - stop - ;; - status) - status - ;; - restart) - restart - ;; - *) - echo "Usage: $0 {start|stop|status|restart}" - exit 1 - esac -} - -execute