Add debian infrastructure for puppet

Add debian packaging directory to build puppet 5.5.22 for starlingx.

Story: 2009101
Task: 43247

Signed-off-by: Charles Short <charles.short@windriver.com>
Change-Id: If2f36cd2781f4d1485f1b47c510f415014ad2d43
This commit is contained in:
Charles Short 2021-09-09 14:08:48 -04:00
parent edef047a87
commit 99e0438c90
8 changed files with 248 additions and 0 deletions

View File

@ -0,0 +1,6 @@
---
debname: puppet
debver: 5.5.22-2
revision:
dist: $STX_DIST
PKG_GITREVCOUNT: true

View File

@ -0,0 +1,25 @@
From 4a8d9f391a00c2eb3090eecd5f3c0ba1677b436f Mon Sep 17 00:00:00 2001
From: Don Penney <don.penney@windriver.com>
Date: Fri, 30 Dec 2016 11:01:22 -0500
Subject: [PATCH 1/5] Add timestamps to logs
---
lib/puppet/util/log/destinations.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/puppet/util/log/destinations.rb b/lib/puppet/util/log/destinations.rb
index 1d0ae78..00af4a8 100644
--- a/lib/puppet/util/log/destinations.rb
+++ b/lib/puppet/util/log/destinations.rb
@@ -158,7 +158,7 @@ Puppet::Util::Log.newdesttype :console do
str = msg.source == "Puppet" ? str : "#{msg.source}: #{str}"
level = levels[msg.level]
- level[:stream].puts colorize(level[:color], "#{level[:name]}: #{str}")
+ level[:stream].puts colorize(level[:color], "#{level[:name]}: #{msg.time} #{str}")
end
end
--
2.16.6

View File

@ -0,0 +1,51 @@
From 2bf29aea0a6320c67e10400c97b69c6427e49044 Mon Sep 17 00:00:00 2001
From: Don Penney <don.penney@windriver.com>
Date: Fri, 30 Dec 2016 10:59:44 -0500
Subject: [PATCH 2/5] Set hasstatus to false by default
Many of the WR init scripts do not have proper status functions,
so set "hasstatus" to false by default.
Signed-off-by: Robert Church <robert.church@windriver.com>
---
lib/puppet/provider/service/init.rb | 9 ++++++++-
lib/puppet/type/service.rb | 3 ++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/lib/puppet/provider/service/init.rb b/lib/puppet/provider/service/init.rb
index 3ab27b3..6b82baa 100644
--- a/lib/puppet/provider/service/init.rb
+++ b/lib/puppet/provider/service/init.rb
@@ -99,7 +99,14 @@ Puppet::Type.type(:service).provide :init, :parent => :base do
next if exclude.include? name
next if not FileTest.executable?(fullpath)
next if not is_init?(fullpath)
- instances << new(:name => name, :path => path, :hasstatus => true)
+
+ # Try to determine whether the init script has "status" support via grep
+ grepcmd = "grep -q '\\<status)' #{fullpath} 2>/dev/null && echo true || echo false"
+ if Puppet::Util::Execution.execute(grepcmd) =~ /true/
+ instances << new(:name => name, :path => path, :hasstatus => true)
+ else
+ instances << new(:name => name, :path => path, :hasstatus => false)
+ end
end
end
instances
diff --git a/lib/puppet/type/service.rb b/lib/puppet/type/service.rb
index a4e835e..0e6db86 100644
--- a/lib/puppet/type/service.rb
+++ b/lib/puppet/type/service.rb
@@ -152,7 +152,8 @@ module Puppet
newvalues(:true, :false)
- defaultto :true
+ # StarlingX: Change hasstatus default to false
+ defaultto :false
end
newparam(:name) do
desc <<-EOT
--
2.16.6

View File

@ -0,0 +1,34 @@
From a606a6e5f608b0e35967412f66fc5dfbb6935f07 Mon Sep 17 00:00:00 2001
From: Al Bailey <Al.Bailey@windriver.com>
Date: Wed, 4 Oct 2017 13:04:27 -0500
Subject: [PATCH 3/5] Update getpid function
Enhance the getpid function to avoid matching with the "puppet apply" command
---
lib/puppet/provider/service/base.rb | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/puppet/provider/service/base.rb b/lib/puppet/provider/service/base.rb
index 92cc1c3..95814c3 100644
--- a/lib/puppet/provider/service/base.rb
+++ b/lib/puppet/provider/service/base.rb
@@ -31,6 +31,7 @@ Puppet::Type.type(:service).provide :base, :parent => :service do
def getpid
@resource.fail "Either stop/status commands or a pattern must be specified" unless @resource[:pattern]
regex = Regexp.new(@resource[:pattern])
+ regex_pa = Regexp.new('puppet apply')
ps = getps
self.debug "Executing '#{ps}'"
@@ -49,7 +50,7 @@ Puppet::Type.type(:service).provide :base, :parent => :service do
table = Puppet::Util::CharacterEncoding.scrub(table) unless table.valid_encoding?
table.each_line { |line|
- if regex.match(line)
+ if regex.match(line) and not regex_pa.match(line)
self.debug "Process matched: #{line}"
ary = line.sub(/^[[:space:]]+/u, '').split(/[[:space:]]+/u)
return ary[1]
--
2.16.6

View File

@ -0,0 +1,97 @@
From eff536de54dacaef995bcd709647222534c40620 Mon Sep 17 00:00:00 2001
From: Al Bailey <Al.Bailey@windriver.com>
Date: Wed, 4 Oct 2017 14:31:23 -0500
Subject: [PATCH 4/5] Block enabling of services
---
lib/puppet/provider/service/debian.rb | 16 ++++++++++------
lib/puppet/provider/service/redhat.rb | 7 ++++---
lib/puppet/provider/service/systemd.rb | 5 +++--
3 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/lib/puppet/provider/service/debian.rb b/lib/puppet/provider/service/debian.rb
index e0fdd42..36e2747 100644
--- a/lib/puppet/provider/service/debian.rb
+++ b/lib/puppet/provider/service/debian.rb
@@ -16,6 +16,7 @@ Puppet::Type.type(:service).provide :debian, :parent => :init do
# is resolved.
commands :invoke_rc => "/usr/sbin/invoke-rc.d"
commands :service => "/usr/sbin/service"
+ commands :noop => "/bin/true"
optional_commands :systemctl => "/bin/systemctl"
defaultfor :operatingsystem => :cumuluslinux, :operatingsystemmajrelease => ['1','2']
@@ -96,12 +97,15 @@ Puppet::Type.type(:service).provide :debian, :parent => :init do
end
def enable
- if self.class.runs_on_systemd?
- systemctl(:enable, @resource[:name])
- else
- update_rc @resource[:name], "defaults"
- update_rc @resource[:name], "enable"
- end
+ # if self.class.runs_on_systemd?
+ # systemctl(:enable, @resource[:name])
+ # else
+ # update_rc @resource[:name], "defaults"
+ # update_rc @resource[:name], "enable"
+ # end
+
+ # Do not enable services
+ noop(@resource[:name])
end
# The start, stop, restart and status command use service
diff --git a/lib/puppet/provider/service/redhat.rb b/lib/puppet/provider/service/redhat.rb
index 20c6afe..d0d852e 100644
--- a/lib/puppet/provider/service/redhat.rb
+++ b/lib/puppet/provider/service/redhat.rb
@@ -7,6 +7,7 @@ Puppet::Type.type(:service).provide :redhat, :parent => :init, :source => :init
"
commands :chkconfig => "/sbin/chkconfig", :service => "/sbin/service"
+ commands :noop => "/bin/true"
defaultfor :osfamily => :redhat
defaultfor :osfamily => :suse, :operatingsystemmajrelease => ["10", "11"]
@@ -43,10 +44,10 @@ Puppet::Type.type(:service).provide :redhat, :parent => :init, :source => :init
# Don't support them specifying runlevels; always use the runlevels
# in the init scripts.
def enable
- chkconfig("--add", @resource[:name])
- chkconfig(@resource[:name], :on)
+ # Do not enable services
+ noop(@resource[:name])
rescue Puppet::ExecutionFailure => detail
- raise Puppet::Error, "Could not enable #{self.name}: #{detail}", detail.backtrace
+ raise Puppet::Error, "Could not enable #{self.name}", detail.backtrace
end
def initscript
diff --git a/lib/puppet/provider/service/systemd.rb b/lib/puppet/provider/service/systemd.rb
index a0f2d0a..d9a2741 100644
--- a/lib/puppet/provider/service/systemd.rb
+++ b/lib/puppet/provider/service/systemd.rb
@@ -10,6 +10,7 @@ Puppet::Type.type(:service).provide :systemd, :parent => :base do
providing the proper suffix."
commands :systemctl => "systemctl"
+ commands :noop => "/bin/true"
confine :true => Puppet::FileSystem.exist?('/proc/1/comm') && Puppet::FileSystem.read('/proc/1/comm').include?('systemd')
@@ -135,8 +136,8 @@ Puppet::Type.type(:service).provide :systemd, :parent => :base do
end
def enable
- self.unmask
- systemctl_change_enable(:enable)
+ #systemctl_change_enable(:enable)
+ [command(:noop), @resource[:name]]
end
def mask
--
2.16.6

View File

@ -0,0 +1,29 @@
From ded72d71cbcdf31cad3088790195a056b57b47a2 Mon Sep 17 00:00:00 2001
From: Al Bailey <Al.Bailey@windriver.com>
Date: Tue, 10 Oct 2017 09:41:17 -0500
Subject: [PATCH 5/5] Set strict variables and basemodulepath in puppet.conf
Also sets ordering = title-hash so that puppet 4 will run the same as puppet 3
Signed-off-by: Robert Church <robert.church@windriver.com>
---
conf/puppet.conf | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/conf/puppet.conf b/conf/puppet.conf
index 67dba46..4efaf55 100644
--- a/conf/puppet.conf
+++ b/conf/puppet.conf
@@ -4,3 +4,9 @@
# - https://puppet.com/docs/puppet/latest/config_about_settings.html
# - https://puppet.com/docs/puppet/latest/config_file_main.html
# - https://puppet.com/docs/puppet/latest/configuration.html
+[main]
+ # Prevent the use of undefined variables
+ strict_variables = true
+ ordering = title-hash
+ # Set the path to StarlingX puppet modules
+ basemodulepath = /usr/share/puppet/modules:/usr/share/openstack-puppet/modules
--
2.16.6

View File

@ -0,0 +1,5 @@
0001-Add-timestamps-to-logs.patch
0002-Set-hasstatus-to-false-by-default.patch
0003-Update-getpid-function.patch
0004-Block-enabling-of-services.patch
0005-Set-strict-variables-and-basemodulepath-in-puppet.co.patch

View File

@ -4,3 +4,4 @@ config/puppet-modules/puppet-puppi
config/puppet-modules/puppet-rabbitmq-8.5.0
config/puppet-modules/puppet-staging
storage-drivers/trident-installer
config/puppet-5.5.22