feat: initial commit
This commit is contained in:
commit
38f495e3f4
457 changed files with 40577 additions and 0 deletions
9
environments/production/thirdparty/apt/lib/facter/apt_reboot_required.rb
vendored
Normal file
9
environments/production/thirdparty/apt/lib/facter/apt_reboot_required.rb
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# apt_reboot_required.rb
|
||||
Facter.add(:apt_reboot_required) do
|
||||
confine 'os.family': 'Debian'
|
||||
setcode do
|
||||
File.file?('/var/run/reboot-required')
|
||||
end
|
||||
end
|
13
environments/production/thirdparty/apt/lib/facter/apt_sources.rb
vendored
Normal file
13
environments/production/thirdparty/apt/lib/facter/apt_sources.rb
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# This fact lists the .list filenames that are used by apt.
|
||||
Facter.add(:apt_sources) do
|
||||
confine 'os.family': 'Debian'
|
||||
setcode do
|
||||
sources = ['sources.list']
|
||||
Dir.glob('/etc/apt/sources.list.d/*.{list,sources}').each do |file|
|
||||
sources.push(File.basename(file))
|
||||
end
|
||||
sources
|
||||
end
|
||||
end
|
18
environments/production/thirdparty/apt/lib/facter/apt_update_last_success.rb
vendored
Normal file
18
environments/production/thirdparty/apt/lib/facter/apt_update_last_success.rb
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'facter'
|
||||
|
||||
# This is derived from the file /var/lib/apt/periodic/update-success-stamp
|
||||
# This is generated upon a successful apt-get update run natively in ubuntu.
|
||||
# the Puppetlabs-apt module deploys this same functionality for other debian-ish OSes
|
||||
Facter.add('apt_update_last_success') do
|
||||
confine 'os.family': 'Debian'
|
||||
setcode do
|
||||
if File.exist?('/var/lib/apt/periodic/update-success-stamp')
|
||||
# get epoch time
|
||||
File.mtime('/var/lib/apt/periodic/update-success-stamp').to_i
|
||||
else
|
||||
-1
|
||||
end
|
||||
end
|
||||
end
|
103
environments/production/thirdparty/apt/lib/facter/apt_updates.rb
vendored
Normal file
103
environments/production/thirdparty/apt/lib/facter/apt_updates.rb
vendored
Normal file
|
@ -0,0 +1,103 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
apt_package_updates = nil
|
||||
apt_dist_updates = nil
|
||||
|
||||
# Executes the upgrading of packages
|
||||
# @param
|
||||
# upgrade_option Type of upgrade passed into apt-get command arguments i.e. 'upgrade' or 'dist-upgrade'
|
||||
def get_updates(upgrade_option)
|
||||
apt_updates = nil
|
||||
if File.executable?('/usr/bin/apt-get')
|
||||
apt_get_result = Facter::Core::Execution.execute("/usr/bin/apt-get -s -o Debug::NoLocking=true #{upgrade_option} 2>&1")
|
||||
unless apt_get_result.nil?
|
||||
apt_updates = [[], []]
|
||||
apt_get_result.each_line do |line|
|
||||
next unless %r{^Inst\s}.match?(line)
|
||||
|
||||
package = line.gsub(%r{^Inst\s([^\s]+)\s.*}, '\1').strip
|
||||
apt_updates[0].push(package)
|
||||
security_matches = [
|
||||
%r{ Debian-Security:},
|
||||
%r{ Ubuntu[^\s]+-security[, ]},
|
||||
%r{ gNewSense[^\s]+-security[, ]},
|
||||
]
|
||||
re = Regexp.union(security_matches)
|
||||
apt_updates[1].push(package) if line.match(re)
|
||||
end
|
||||
end
|
||||
end
|
||||
apt_updates
|
||||
end
|
||||
|
||||
Facter.add('apt_has_updates') do
|
||||
confine 'os.family': 'Debian'
|
||||
setcode do
|
||||
apt_package_updates = get_updates('upgrade')
|
||||
apt_package_updates != [[], []] if !apt_package_updates.nil? && apt_package_updates.length == 2
|
||||
end
|
||||
end
|
||||
|
||||
Facter.add('apt_has_dist_updates') do
|
||||
confine 'os.family': 'Debian'
|
||||
setcode do
|
||||
apt_dist_updates = get_updates('dist-upgrade')
|
||||
apt_dist_updates != [[], []] if !apt_dist_updates.nil? && apt_dist_updates.length == 2
|
||||
end
|
||||
end
|
||||
|
||||
Facter.add('apt_package_updates') do
|
||||
confine apt_has_updates: true
|
||||
setcode do
|
||||
apt_package_updates[0]
|
||||
end
|
||||
end
|
||||
|
||||
Facter.add('apt_package_dist_updates') do
|
||||
confine apt_has_dist_updates: true
|
||||
setcode do
|
||||
apt_dist_updates[0]
|
||||
end
|
||||
end
|
||||
|
||||
Facter.add('apt_package_security_updates') do
|
||||
confine apt_has_updates: true
|
||||
setcode do
|
||||
apt_package_updates[1]
|
||||
end
|
||||
end
|
||||
|
||||
Facter.add('apt_package_security_dist_updates') do
|
||||
confine apt_has_dist_updates: true
|
||||
setcode do
|
||||
apt_dist_updates[1]
|
||||
end
|
||||
end
|
||||
|
||||
Facter.add('apt_updates') do
|
||||
confine apt_has_updates: true
|
||||
setcode do
|
||||
Integer(apt_package_updates[0].length)
|
||||
end
|
||||
end
|
||||
|
||||
Facter.add('apt_dist_updates') do
|
||||
confine apt_has_dist_updates: true
|
||||
setcode do
|
||||
Integer(apt_dist_updates[0].length)
|
||||
end
|
||||
end
|
||||
|
||||
Facter.add('apt_security_updates') do
|
||||
confine apt_has_updates: true
|
||||
setcode do
|
||||
Integer(apt_package_updates[1].length)
|
||||
end
|
||||
end
|
||||
|
||||
Facter.add('apt_security_dist_updates') do
|
||||
confine apt_has_dist_updates: true
|
||||
setcode do
|
||||
Integer(apt_dist_updates[1].length)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue