feat: initial commit
This commit is contained in:
commit
38f495e3f4
457 changed files with 40577 additions and 0 deletions
10
environments/production/thirdparty/apt/tasks/init.json
vendored
Normal file
10
environments/production/thirdparty/apt/tasks/init.json
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"description": "Allows you to perform apt-get functions",
|
||||
"input_method": "stdin",
|
||||
"parameters": {
|
||||
"action": {
|
||||
"description": "Action to perform with apt-get",
|
||||
"type": "Enum[update, upgrade, dist-upgrade, autoremove]"
|
||||
}
|
||||
}
|
||||
}
|
34
environments/production/thirdparty/apt/tasks/init.rb
vendored
Executable file
34
environments/production/thirdparty/apt/tasks/init.rb
vendored
Executable file
|
@ -0,0 +1,34 @@
|
|||
#!/opt/puppetlabs/puppet/bin/ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'json'
|
||||
require 'open3'
|
||||
require 'puppet'
|
||||
|
||||
def apt_get(action)
|
||||
cmd = ['apt-get', action]
|
||||
cmd << '-y' if ['upgrade', 'dist-upgrade', 'autoremove'].include?(action)
|
||||
if ['upgrade', 'dist-upgrade', 'autoremove'].include?(action)
|
||||
ENV['DEBIAN_FRONTEND'] = 'noninteractive'
|
||||
cmd << '-o'
|
||||
cmd << 'Dpkg::Options="--force-confdef"'
|
||||
cmd << '-o'
|
||||
cmd << 'Dpkg::Options="--force-confold"'
|
||||
end
|
||||
stdout, stderr, status = Open3.capture3(*cmd)
|
||||
raise Puppet::Error, stderr if status != 0
|
||||
|
||||
{ status: stdout.strip }
|
||||
end
|
||||
|
||||
params = JSON.parse($stdin.read)
|
||||
action = params['action']
|
||||
|
||||
begin
|
||||
result = apt_get(action)
|
||||
puts result.to_json
|
||||
exit 0
|
||||
rescue Puppet::Error => e
|
||||
puts({ status: 'failure', error: e.message }.to_json)
|
||||
exit 1
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue