Skip to content

Commit

Permalink
Merge pull request voxpupuli#368 from oranenj/systemd-cleanup
Browse files Browse the repository at this point in the history
Depend on camptocamp/systemd and clean up service handling
  • Loading branch information
oranenj authored Apr 20, 2021
2 parents 5cb9b00 + 50cfaf4 commit 7fd53fb
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 45 deletions.
1 change: 1 addition & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
fixtures:
repositories:
archive: "https://github.com/voxpupuli/puppet-archive.git"
systemd: "https://github.com/camptocamp/puppet-systemd.git"
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
4 changes: 0 additions & 4 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
class jira::params {
Exec { path => ['/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/'] }

$service_file_location = '/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'],
Expand Down
37 changes: 11 additions & 26 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#-----------------------------------------------------------------------------
class jira::service (
class jira::service {
assert_private()

Boolean $service_manage = $jira::service_manage,
String $service_ensure = $jira::service_ensure,
Boolean $service_enable = $jira::service_enable,
$service_notify = $jira::service_notify,
$service_subscribe = $jira::service_subscribe,
$service_file_location = $jira::params::service_file_location,
$service_file_template = $jira::params::service_file_template,
$service_file_mode = $jira::params::service_file_mode,

) inherits jira::params {
file { $service_file_location:
content => template($service_file_template),
mode => $service_file_mode,
systemd::unit_file { 'jira.service':
ensure => 'present',
content => epp('jira/jira.service.epp'),
}

if $service_manage {
exec { 'refresh_systemd':
command => 'systemctl daemon-reload',
refreshonly => true,
subscribe => File[$service_file_location],
before => Service['jira'],
}
if $jira::service_manage {
Systemd::Unit_file['jira.service'] ~> Service['jira']

service { 'jira':
ensure => $service_ensure,
enable => $service_enable,
require => File[$service_file_location],
notify => $service_notify,
subscribe => $service_subscribe,
ensure => $jira::service_ensure,
enable => $jira::service_enable,
notify => $jira::service_notify,
subscribe => $jira::service_subscribe,
}
}
}
4 changes: 4 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
"jira"
],
"dependencies": [
{
"name": "camptocamp/systemd",
"version_requirement": ">= 3.0.0 < 4.0.0"
},
{
"name": "puppetlabs/stdlib",
"version_requirement": ">= 4.25.0 < 8.0.0"
Expand Down
3 changes: 1 addition & 2 deletions spec/classes/jira_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
it { is_expected.to compile.with_all_deps }

it do
is_expected.to contain_file('/lib/systemd/system/jira.service').
is_expected.to contain_file('/etc/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

Expand Down
14 changes: 14 additions & 0 deletions templates/jira.service.epp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# THIS FILE IS MANAGED BY PUPPET
[Unit]
Description=Atlassian Systemd Jira Service
After=syslog.target network.target

[Service]
Type=forking
Environment="JAVA_HOME=<%= $jira::javahome %>"
User=<%= $jira::user %>
ExecStart=<%= $jira::webappdir %>/bin/start-jira.sh
ExecStop=<%= $jira::webappdir %>/bin/stop-jira.sh

[Install]
WantedBy=multi-user.target
13 changes: 0 additions & 13 deletions templates/jira.service.erb

This file was deleted.

0 comments on commit 7fd53fb

Please sign in to comment.