summaryrefslogtreecommitdiff
path: root/code/environments/production/modules/apt/tasks
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2018-09-16 22:55:58 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2018-09-16 22:55:58 +0200
commit9513b93a992470e21e387db1451fa4fd21ffc5d6 (patch)
tree24b584e9a66ce00f053748ab938eecc8d91110ab /code/environments/production/modules/apt/tasks
parentb9c90f087cb54a0b8be222dbdcd88c8a73ef4f57 (diff)
downloadpuppet.DEV-9513b93a992470e21e387db1451fa4fd21ffc5d6.tar.gz
puppet.DEV-9513b93a992470e21e387db1451fa4fd21ffc5d6.tar.bz2
puppet.DEV-9513b93a992470e21e387db1451fa4fd21ffc5d6.zip
modules/apt: Ship puppetlabs-apt module v4.5.1.
Diffstat (limited to 'code/environments/production/modules/apt/tasks')
-rw-r--r--code/environments/production/modules/apt/tasks/init.json10
-rwxr-xr-xcode/environments/production/modules/apt/tasks/init.rb24
2 files changed, 34 insertions, 0 deletions
diff --git a/code/environments/production/modules/apt/tasks/init.json b/code/environments/production/modules/apt/tasks/init.json
new file mode 100644
index 0000000..2020005
--- /dev/null
+++ b/code/environments/production/modules/apt/tasks/init.json
@@ -0,0 +1,10 @@
+{
+ "description": "Allows you to perform apt functions",
+ "input_method": "stdin",
+ "parameters": {
+ "action": {
+ "description": "Action to perform ",
+ "type": "Enum[update, upgrade]"
+ }
+ }
+}
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