diff --git a/files/ubuntu_sonar.service b/files/ubuntu_sonar.service new file mode 100644 index 00000000..05875c47 --- /dev/null +++ b/files/ubuntu_sonar.service @@ -0,0 +1,27 @@ +# Automatically generated by systemd-sysv-generator + +[Unit] +Documentation=man:systemd-sysv-generator(8) +SourcePath=/etc/init.d/sonar +Description=LSB: Sonar +Before=multi-user.target +Before=multi-user.target +Before=multi-user.target +Before=graphical.target +Before=shutdown.target +After=remote-fs.target +After=systemd-journald-dev-log.socket +Conflicts=shutdown.target + +[Service] +Type=forking +Restart=no +TimeoutSec=5min +IgnoreSIGPIPE=no +KillMode=process +GuessMainPID=no +RemainAfterExit=yes +ExecStart=/etc/init.d/sonar start +ExecStop=/etc/init.d/sonar stop +User=sonar +LimitNOFILE=65536 diff --git a/manifests/init.pp b/manifests/init.pp index 3a96b781..8ad625e7 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -190,12 +190,32 @@ ensure => directory, } - service { 'sonarqube': - ensure => running, - name => $service, - hasrestart => true, - hasstatus => true, - enable => true, - require => File["/etc/init.d/${service}"], + if $::operatingsystem == 'Ubuntu' and + versioncmp($::operatingsystemrelease, '16.04') >= 0 { + + # Install systemd unit for sonar + + file { + '/etc/systemd/system/sonar.service': + content => file('sonarqube/ubuntu_sonar.service'), + require => File["/etc/init.d/${service}"] + } -> service { 'sonarqube': + ensure => running, + name => $service, + hasrestart => true, + hasstatus => true, + enable => true + } + + } else { + service { 'sonarqube': + ensure => running, + name => $service, + hasrestart => true, + hasstatus => true, + enable => true, + require => File["/etc/init.d/${service}"], + } } + } diff --git a/metadata.json b/metadata.json index f83cd37e..2ec2cf03 100644 --- a/metadata.json +++ b/metadata.json @@ -19,7 +19,7 @@ }, { "name": "puppetlabs/stdlib", - "version_requirement": ">=2.3.0 <5.0.0" + "version_requirement": ">=2.3.0 <7.0.0" } ], "operatingsystem_support": [