Skip to content

Commit

Permalink
Merge pull request #229 from KoenDierckx/master
Browse files Browse the repository at this point in the history
Use systemd on Ubuntu 16.04
  • Loading branch information
bastelfreak authored Nov 26, 2017
2 parents 5e47233 + 666ca4f commit a44ac70
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 61 deletions.
4 changes: 2 additions & 2 deletions examples/jira_postgres_nginx_install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
javahome => '/opt/java/latest',
proxy => {
scheme => 'http',
proxyName => $::fqdn,
proxyName => $facts['fqdn'],
proxyPort => '80',
},
}
Expand All @@ -32,7 +32,7 @@

nginx::resource::vhost { 'jira_vhost':
ensure => present,
server_name => [ $::ipaddress, $::fqdn, $hostname ],
server_name => [ $facts['ipaddress'], $facts['fqdn'], $facts['hostname'] ],
listen_port => '80',
proxy => 'http://jira',
proxy_read_timeout => '300',
Expand Down
4 changes: 2 additions & 2 deletions examples/jira_postgres_nginx_ssl_install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
javahome => '/opt/java/latest',
proxy => {
scheme => 'https',
proxyName => $::fqdn,
proxyName => $facts['fqdn'],
proxyPort => '443',
},
}
Expand All @@ -32,7 +32,7 @@

nginx::resource::vhost { 'jira_vhost':
ensure => present,
server_name => [ $::ipaddress, $::fqdn, $hostname ],
server_name => [ $facts['ipaddress'], $facts['fqdn'], $facts['hostname'] ],
proxy => 'http://jira',
proxy_read_timeout => '300',
rewrite_to_https => true,
Expand Down
18 changes: 9 additions & 9 deletions manifests/facts.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#
# class { 'jira::facts': }
#
class jira::facts(
class jira::facts (
$ensure = 'present',
$port = $jira::tomcat_port,
$contextpath = $jira::contextpath,
Expand All @@ -29,26 +29,26 @@

# Puppet Enterprise supplies its own ruby version if your using it.
# A modern ruby version is required to run the executable fact
if $::puppetversion =~ /Puppet Enterprise/ {
if $facts['puppetversion'] =~ /Puppet Enterprise/ {
$ruby_bin = '/opt/puppet/bin/ruby'
$dir = 'puppetlabs/'
$dir = 'puppetlabs/'
} else {
$ruby_bin = '/usr/bin/env ruby'
$dir = ''
$dir = ''
}

if ! defined(File["/etc/${dir}facter"]) {
if !defined(File["/etc/${dir}facter"]) {
file { "/etc/${dir}facter":
ensure => directory,
ensure => directory,
}
}
if ! defined(File["/etc/${dir}facter/facts.d"]) {
if !defined(File["/etc/${dir}facter/facts.d"]) {
file { "/etc/${dir}facter/facts.d":
ensure => directory,
ensure => directory,
}
}

if $::osfamily == 'RedHat' and $::puppetversion !~ /Puppet Enterprise/ {
if $facts['osfamily'] == 'RedHat' and $facts['puppetversion'] !~ /Puppet Enterprise/ {
package { $json_packages:
ensure => present,
}
Expand Down
89 changes: 50 additions & 39 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,67 @@
#
class jira::params {

Exec { path => [ '/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/' ] }
Exec { path => [ '/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/' ] }

case $::osfamily {
case $facts['osfamily'] {
/RedHat/: {
if versioncmp($::operatingsystemmajrelease, '7') >= 0 {
$json_packages = 'rubygem-json'
$service_file_location = '/usr/lib/systemd/system/jira.service'
$service_file_template = 'jira/jira.service.erb'
$service_lockfile = '/var/lock/subsys/jira'
$service_provider = 'systemd'
} elsif versioncmp($::operatingsystemmajrelease, '6') >= 0 or $::operatingsystem == 'Amazon'{
$json_packages = [ 'rubygem-json', 'ruby-json' ]
$service_file_location = '/etc/init.d/jira'
$service_file_template = 'jira/jira.initscript.erb'
$service_lockfile = '/var/lock/subsys/jira'
$service_provider = undef
if versioncmp($facts['operatingsystemmajrelease'], '7') >= 0 {
$json_packages = 'rubygem-json'
$service_file_location = '/usr/lib/systemd/system/jira.service'
$service_file_template = 'jira/jira.service.erb'
$service_lockfile = '/var/lock/subsys/jira'
$service_provider = 'systemd'
} elsif versioncmp($facts['operatingsystemmajrelease'], '6') >= 0 or $facts['operatingsystem'] == 'Amazon' {
$json_packages = [ 'rubygem-json', 'ruby-json' ]
$service_file_location = '/etc/init.d/jira'
$service_file_template = 'jira/jira.initscript.erb'
$service_lockfile = '/var/lock/subsys/jira'
$service_provider = undef
} else {
fail("\"${module_name}\" provides no service parameters
for \"${::osfamily}\" - \"${::operatingsystemmajrelease}\"")
for \"${::osfamily}\" - \"${$facts['operatingsystemmajrelease']}\"")
}
} /Debian/: {
}
/Debian/: {
case $::operatingsystem {
'Ubuntu': {
$json_packages = [ 'rubygem-json', 'ruby-json' ]
$service_file_location = '/etc/init.d/jira'
$service_file_template = 'jira/jira.initscript.erb'
$service_lockfile = '/var/lock/jira'
$service_provider = 'debian'
} default: {
if versioncmp($::operatingsystemmajrelease, '8') >= 0 {
$json_packages = 'ruby-json'
$service_file_location = '/lib/systemd/system/jira.service'
$service_file_template = 'jira/jira.service.erb'
$service_lockfile = '/var/lock/subsys/jira'
$service_provider = 'systemd'
if versioncmp($facts['operatingsystemmajrelease'], '15.04') >= 0 {
$json_packages = 'ruby-json'
$service_file_location = '/lib/systemd/system/jira.service'
$service_file_template = 'jira/jira.service.erb'
$service_lockfile = '/var/lock/subsys/jira'
$service_provider = 'systemd'
} else {
$json_packages = [ 'rubygem-json', 'ruby-json' ]
$service_file_location = '/etc/init.d/jira'
$service_file_template = 'jira/jira.initscript.erb'
$service_lockfile = '/var/lock/jira'
$service_provider = 'debian'
$json_packages = [ 'rubygem-json', 'ruby-json' ]
$service_file_location = '/etc/init.d/jira'
$service_file_template = 'jira/jira.initscript.erb'
$service_lockfile = '/var/lock/jira'
$service_provider = 'debian'
}
}
default: {
if versioncmp($facts['operatingsystemmajrelease'], '8') >= 0 {
$json_packages = 'ruby-json'
$service_file_location = '/lib/systemd/system/jira.service'
$service_file_template = 'jira/jira.service.erb'
$service_lockfile = '/var/lock/subsys/jira'
$service_provider = 'systemd'
} else {
$json_packages = [ 'rubygem-json', 'ruby-json' ]
$service_file_location = '/etc/init.d/jira'
$service_file_template = 'jira/jira.initscript.erb'
$service_lockfile = '/var/lock/jira'
$service_provider = 'debian'
}
}
}
} default: {
$json_packages = [ 'rubygem-json', 'ruby-json' ]
$service_file_location = '/etc/init.d/jira'
$service_file_template = 'jira/jira.initscript.erb'
$service_lockfile = '/var/lock/subsys/jira'
$service_provider = undef
}
default: {
$json_packages = [ 'rubygem-json', 'ruby-json' ]
$service_file_location = '/etc/init.d/jira'
$service_file_template = 'jira/jira.initscript.erb'
$service_lockfile = '/var/lock/subsys/jira'
$service_provider = undef
}
}
}
3 changes: 2 additions & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"12.04",
"14.04"
"14.04",
"16.04"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/default_parameters_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe 'jira postgresql', unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
it 'installs with defaults' do
pp = <<-EOS
if versioncmp($::puppetversion,'3.6.1') >= 0 {
if versioncmp($facts['puppetversion'],'3.6.1') >= 0 {
$allow_virtual_packages = hiera('allow_virtual_packages',false)
Package {
allow_virtual => $allow_virtual_packages,
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/mysql_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe 'jira mysql', unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
it 'installs with mysql database' do
pp = <<-EOS
if versioncmp($::puppetversion,'3.6.1') >= 0 {
if versioncmp($facts['puppetversion'],'3.6.1') >= 0 {
$allow_virtual_packages = hiera('allow_virtual_packages',false)
Package {
allow_virtual => $allow_virtual_packages,
Expand Down
30 changes: 26 additions & 4 deletions spec/classes/jira_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
end
if os == 'Debian'
context 'lockfile on Debian' do
let(:facts) do
{ osfamily: 'Debian' }
end

it { is_expected.to compile.with_all_deps }
it do
is_expected.to contain_file('/etc/init.d/jira').
Expand All @@ -47,9 +43,35 @@
if os =~ %r{ubuntu}
context 'default params' do
it { is_expected.to compile.with_all_deps }
end
end
if os =~ %r{ubuntu-12}
context 'default params' do
let(:facts) do
facts.merge(operatingsystem: 'Ubuntu', operatingsystemmajrelease: '12.04')
end

it { is_expected.not_to contain_file('/lib/systemd/system/jira.service') }
end
end
if os =~ %r{ubuntu-14}
context 'default params' do
let(:facts) do
facts.merge(operatingsystem: 'Ubuntu', operatingsystemmajrelease: '14.04')
end

it { is_expected.not_to contain_file('/lib/systemd/system/jira.service') }
end
end
if os =~ %r{ubuntu-16}
context 'default params' do
let(:facts) do
facts.merge(operatingsystem: 'Ubuntu', operatingsystemmajrelease: '16.04')
end

it { is_expected.to contain_file('/lib/systemd/system/jira.service') }
end
end
context 'overwriting service_manage param' do
let(:params) do
super().merge(service_manage: false)
Expand Down
4 changes: 2 additions & 2 deletions templates/jira-config.properties.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<% @merged_jira_config_properties.sort.each do |key,value| -%>
<%= key %> = <%= value %>
<% @merged_jira_config_properties.sort.each do |key,value| -%>
<%= key %> = <%= value %>
<% end -%>

0 comments on commit a44ac70

Please sign in to comment.