Skip to content

Commit 9f67977

Browse files
authored
Merge pull request voxpupuli#368 from oranenj/systemd-cleanup
Depend on camptocamp/systemd and clean up service handling
2 parents 6c13afe + ff21403 commit 9f67977

7 files changed

Lines changed: 31 additions & 45 deletions

File tree

.fixtures.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
fixtures:
22
repositories:
33
archive: "https://github.com/voxpupuli/puppet-archive.git"
4+
systemd: "https://github.com/camptocamp/puppet-systemd.git"
45
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git"

manifests/params.pp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
class jira::params {
66
Exec { path => ['/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/'] }
77

8-
$service_file_location = '/lib/systemd/system/jira.service'
9-
$service_file_template = 'jira/jira.service.erb'
10-
$service_file_mode = '0644'
11-
128
$json_packages = $facts['os']['family'] ? {
139
'RedHat' => ['rubygem-json'],
1410
'Debian' => ['ruby-json'],

manifests/service.pp

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,22 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#-----------------------------------------------------------------------------
16-
class jira::service (
16+
class jira::service {
17+
assert_private()
1718

18-
Boolean $service_manage = $jira::service_manage,
19-
String $service_ensure = $jira::service_ensure,
20-
Boolean $service_enable = $jira::service_enable,
21-
$service_notify = $jira::service_notify,
22-
$service_subscribe = $jira::service_subscribe,
23-
$service_file_location = $jira::params::service_file_location,
24-
$service_file_template = $jira::params::service_file_template,
25-
$service_file_mode = $jira::params::service_file_mode,
26-
27-
) inherits jira::params {
28-
file { $service_file_location:
29-
content => template($service_file_template),
30-
mode => $service_file_mode,
19+
systemd::unit_file { 'jira.service':
20+
ensure => 'present',
21+
content => epp('jira/jira.service.epp'),
3122
}
3223

33-
if $service_manage {
34-
exec { 'refresh_systemd':
35-
command => 'systemctl daemon-reload',
36-
refreshonly => true,
37-
subscribe => File[$service_file_location],
38-
before => Service['jira'],
39-
}
24+
if $jira::service_manage {
25+
Systemd::Unit_file['jira.service'] ~> Service['jira']
4026

4127
service { 'jira':
42-
ensure => $service_ensure,
43-
enable => $service_enable,
44-
require => File[$service_file_location],
45-
notify => $service_notify,
46-
subscribe => $service_subscribe,
28+
ensure => $jira::service_ensure,
29+
enable => $jira::service_enable,
30+
notify => $jira::service_notify,
31+
subscribe => $jira::service_subscribe,
4732
}
4833
}
4934
}

metadata.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
"jira"
1313
],
1414
"dependencies": [
15+
{
16+
"name": "camptocamp/systemd",
17+
"version_requirement": ">= 3.0.0 < 4.0.0"
18+
},
1519
{
1620
"name": "puppetlabs/stdlib",
1721
"version_requirement": ">= 4.25.0 < 8.0.0"

spec/classes/jira_service_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@
1919
it { is_expected.to compile.with_all_deps }
2020

2121
it do
22-
is_expected.to contain_file('/lib/systemd/system/jira.service').
22+
is_expected.to contain_file('/etc/systemd/system/jira.service').
2323
with_content(%r{Atlassian Systemd Jira Service})
2424
end
25-
it { is_expected.to contain_exec('refresh_systemd') }
2625
it { is_expected.to contain_service('jira') }
2726
end
2827

templates/jira.service.epp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# THIS FILE IS MANAGED BY PUPPET
2+
[Unit]
3+
Description=Atlassian Systemd Jira Service
4+
After=syslog.target network.target
5+
6+
[Service]
7+
Type=forking
8+
Environment="JAVA_HOME=<%= $jira::javahome %>"
9+
User=<%= $jira::user %>
10+
ExecStart=<%= $jira::webappdir %>/bin/start-jira.sh
11+
ExecStop=<%= $jira::webappdir %>/bin/stop-jira.sh
12+
13+
[Install]
14+
WantedBy=multi-user.target

templates/jira.service.erb

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)