diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2018-09-16 22:55:20 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2018-09-16 22:55:20 +0200 |
commit | 0203c3892bb3b7ce5037fe25ed33096813185379 (patch) | |
tree | 7d5af5631949d8275aa5291f9b7eb1969dc7079e /code/environments/production/modules/apt/tasks/init.rb | |
parent | 636bddf2ffe042c43f1c56cff5942f73385b3d68 (diff) | |
download | puppet.KATH-0203c3892bb3b7ce5037fe25ed33096813185379.tar.gz puppet.KATH-0203c3892bb3b7ce5037fe25ed33096813185379.tar.bz2 puppet.KATH-0203c3892bb3b7ce5037fe25ed33096813185379.zip |
modules/apt: Ship puppetlabs-apt module v4.5.1.
Diffstat (limited to 'code/environments/production/modules/apt/tasks/init.rb')
-rwxr-xr-x | code/environments/production/modules/apt/tasks/init.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/code/environments/production/modules/apt/tasks/init.rb b/code/environments/production/modules/apt/tasks/init.rb new file mode 100755 index 0000000..d256468 --- /dev/null +++ b/code/environments/production/modules/apt/tasks/init.rb @@ -0,0 +1,24 @@ +#!/opt/puppetlabs/puppet/bin/ruby +require 'json' +require 'open3' +require 'puppet' + +def apt_get(action) + cmd = ['apt-get', action] + cmd << ' -y' if action == 'upgrade' + 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 |