From 9e9fe655d577a09728a497f7b851deb304302292 Mon Sep 17 00:00:00 2001 From: "bastian.jeske" Date: Mon, 22 Aug 2016 14:44:50 +0200 Subject: [PATCH 1/6] systemd_compatibility --- manifests/service.pp | 47 ++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/manifests/service.pp b/manifests/service.pp index db5851c3..8e46e9eb 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -5,20 +5,37 @@ # class gitlab::service { if $::gitlab::service_manage { - file { "/etc/init.d/${::gitlab::service_name}": - ensure => 'link', - target => $::gitlab::service_exec, - } -> - service { $::gitlab::service_name: - ensure => $::gitlab::service_ensure, - enable => $::gitlab::service_enable, - restart => $::gitlab::service_restart, - start => $::gitlab::service_start, - stop => $::gitlab::service_stop, - status => $::gitlab::service_status, - hasstatus => $::gitlab::service_hasstatus, - hasrestart => $::gitlab::service_hasrestart, + if ($::operatingsystem == 'Ubuntu' and $::operatingsystemrelease in ['15.04','15.10','16.04','16.10']) or ($::operatingsystem == 'Debian' and $::operatingsystemrelease == '8') { + file { "/etc/systemd/system/basic.target.wants/${::gitlab::service_name}.service": + ensure => 'link', + target => "/usr/lib/systemd/system/${::gitlab::service_name}.service", + } -> + service { $::gitlab::service_name: + ensure => $::gitlab::service_ensure, + enable => $::gitlab::service_enable, + restart => $::gitlab::service_restart, + start => $::gitlab::service_start, + stop => $::gitlab::service_stop, + status => $::gitlab::service_status, + hasstatus => $::gitlab::service_hasstatus, + hasrestart => $::gitlab::service_hasrestart, + } + } + else{ + file { "/etc/init.d/${::gitlab::service_name}": + ensure => 'link', + target => $::gitlab::service_exec, + } -> + service { $::gitlab::service_name: + ensure => $::gitlab::service_ensure, + enable => $::gitlab::service_enable, + restart => $::gitlab::service_restart, + start => $::gitlab::service_start, + stop => $::gitlab::service_stop, + status => $::gitlab::service_status, + hasstatus => $::gitlab::service_hasstatus, + hasrestart => $::gitlab::service_hasrestart, + } + } } - } - } From d77f74499059b21139cdd47e2858e4fef15992a1 Mon Sep 17 00:00:00 2001 From: "bastian.jeske" Date: Mon, 22 Aug 2016 17:01:27 +0200 Subject: [PATCH 2/6] Ensure absent softlink in init.d for operating systems with systemd. --- manifests/params.pp | 6 ++++++ manifests/service.pp | 47 ++++++++++++++------------------------------ 2 files changed, 21 insertions(+), 32 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index 8cf93ba6..a8efc1ba 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -31,6 +31,12 @@ $service_enable = true } + if ($::operatingsystem == 'Ubuntu' and $::operatingsystemrelease in ['15.04','15.10','16.04','16.10']) or ($::operatingsystem == 'Debian' and $::operatingsystemrelease == '8') { + $service_initd_ensure = 'absent' + } else { + $service_initd_ensure = 'link' + } + # gitlab specific $config_manage = true $config_file = '/etc/gitlab/gitlab.rb' diff --git a/manifests/service.pp b/manifests/service.pp index 8e46e9eb..2fbc7d2d 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -5,37 +5,20 @@ # class gitlab::service { if $::gitlab::service_manage { - if ($::operatingsystem == 'Ubuntu' and $::operatingsystemrelease in ['15.04','15.10','16.04','16.10']) or ($::operatingsystem == 'Debian' and $::operatingsystemrelease == '8') { - file { "/etc/systemd/system/basic.target.wants/${::gitlab::service_name}.service": - ensure => 'link', - target => "/usr/lib/systemd/system/${::gitlab::service_name}.service", - } -> - service { $::gitlab::service_name: - ensure => $::gitlab::service_ensure, - enable => $::gitlab::service_enable, - restart => $::gitlab::service_restart, - start => $::gitlab::service_start, - stop => $::gitlab::service_stop, - status => $::gitlab::service_status, - hasstatus => $::gitlab::service_hasstatus, - hasrestart => $::gitlab::service_hasrestart, - } - } - else{ - file { "/etc/init.d/${::gitlab::service_name}": - ensure => 'link', - target => $::gitlab::service_exec, - } -> - service { $::gitlab::service_name: - ensure => $::gitlab::service_ensure, - enable => $::gitlab::service_enable, - restart => $::gitlab::service_restart, - start => $::gitlab::service_start, - stop => $::gitlab::service_stop, - status => $::gitlab::service_status, - hasstatus => $::gitlab::service_hasstatus, - hasrestart => $::gitlab::service_hasrestart, - } - } + file { "/etc/init.d/${::gitlab::service_name}": + ensure => $::gitlab::service_initd_ensure, + target => $::gitlab::service_exec, + } -> + service { $::gitlab::service_name: + ensure => $::gitlab::service_ensure, + enable => $::gitlab::service_enable, + restart => $::gitlab::service_restart, + start => $::gitlab::service_start, + stop => $::gitlab::service_stop, + status => $::gitlab::service_status, + hasstatus => $::gitlab::service_hasstatus, + hasrestart => $::gitlab::service_hasrestart, } + } + } From f294ef785503addba2d028ab0cc0b97581fa7f3e Mon Sep 17 00:00:00 2001 From: "bastian.jeske" Date: Mon, 22 Aug 2016 17:41:25 +0200 Subject: [PATCH 3/6] New parameter documentation --- manifests/init.pp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/manifests/init.pp b/manifests/init.pp index 31e5fc8a..27d608b3 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -28,6 +28,12 @@ # Default: true # Run the system service on boot. # +# [*service_initd_ensure*] +# Default for 'Ubuntu 15.04, 15.10, 16.04, 16.10' or 'Debian 8': "absent" +# Else: "link" +# Sets "ensure => 'absent'" or "ensure => 'link'" on init.d softlink +# depending on systems OS to avoid conflicts with systemd. +# # [*service_exec*] # Default: '/usr/bin/gitlab-ctl' # The service executable path. @@ -253,6 +259,7 @@ $package_pin = $::gitlab::params::package_pin, # system service configuration $service_enable = $::gitlab::params::service_enable, + $service_initd_ensure = $::gitlab::params::service_initd_ensure, $service_ensure = $::gitlab::params::service_ensure, $service_group = $::gitlab::params::service_group, $service_hasrestart = $::gitlab::params::service_hasrestart, From bc452944a76cd6f323d2446d60d20cbac7eb5207 Mon Sep 17 00:00:00 2001 From: "bastian.jeske" Date: Tue, 23 Aug 2016 13:35:32 +0200 Subject: [PATCH 4/6] Added custome fact gitlab_systemd (duplicates fact systemd) --- lib/facter/gitlab_systemd.rb | 18 ++++++++++++++++++ manifests/params.pp | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 lib/facter/gitlab_systemd.rb diff --git a/lib/facter/gitlab_systemd.rb b/lib/facter/gitlab_systemd.rb new file mode 100644 index 00000000..17456058 --- /dev/null +++ b/lib/facter/gitlab_systemd.rb @@ -0,0 +1,18 @@ +# Fact: gitlab_systemd +# +# Purpose: +# Determine whether SystemD is the init system on the node +# +# Resolution: +# Check the name of the process 1 (ps -p 1) +# +# Caveats: +# Duplicates the fact "systemd" from camptocamp/puppet-systemd +# + +Facter.add(:gitlab_systemd) do + confine :kernel => :linux + setcode do + %x{ps -p 1 -o comm=}.gsub("\n",'') == 'systemd' + end +end diff --git a/manifests/params.pp b/manifests/params.pp index a8efc1ba..2a83a5e6 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -31,7 +31,7 @@ $service_enable = true } - if ($::operatingsystem == 'Ubuntu' and $::operatingsystemrelease in ['15.04','15.10','16.04','16.10']) or ($::operatingsystem == 'Debian' and $::operatingsystemrelease == '8') { + if ($::gitlab_systemd) { $service_initd_ensure = 'absent' } else { $service_initd_ensure = 'link' From 3a9b7c0072d8b451a8d12feb98a4edc7ddcf0a35 Mon Sep 17 00:00:00 2001 From: "bastian.jeske" Date: Tue, 23 Aug 2016 14:17:42 +0200 Subject: [PATCH 5/6] Replaced %x exec with Facter::Util::Resolution.exec in gitlab_systemd Fact. --- lib/facter/gitlab_systemd.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/facter/gitlab_systemd.rb b/lib/facter/gitlab_systemd.rb index 17456058..d42ba8b2 100644 --- a/lib/facter/gitlab_systemd.rb +++ b/lib/facter/gitlab_systemd.rb @@ -13,6 +13,6 @@ Facter.add(:gitlab_systemd) do confine :kernel => :linux setcode do - %x{ps -p 1 -o comm=}.gsub("\n",'') == 'systemd' + Facter::Util::Resolution.exec('ps -p 1 -o comm=') == 'systemd' end end From 92eb4ad5e4d515b7e1916a3a75d8c409902ad49d Mon Sep 17 00:00:00 2001 From: "bastian.jeske" Date: Tue, 23 Aug 2016 14:57:11 +0200 Subject: [PATCH 6/6] Updated init.pp description of "service_initd_ensure" to reflect recent changes. --- manifests/init.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 27d608b3..36937263 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -29,10 +29,10 @@ # Run the system service on boot. # # [*service_initd_ensure*] -# Default for 'Ubuntu 15.04, 15.10, 16.04, 16.10' or 'Debian 8': "absent" +# Default for systemd systems, as determined by the $::gitlab_systemd fact: "absent" # Else: "link" # Sets "ensure => 'absent'" or "ensure => 'link'" on init.d softlink -# depending on systems OS to avoid conflicts with systemd. +# depending on the $::gitlab_systemd fact to avoid conflicts with systemd. # # [*service_exec*] # Default: '/usr/bin/gitlab-ctl'