From cd7543a86551bddec755566b1104d3b7a26c1b73 Mon Sep 17 00:00:00 2001 From: Alexey Khivin Date: Thu, 23 Jun 2016 00:48:32 +0300 Subject: [PATCH] [Puppet] PuppetInstance.applyManifest added You can now apply Puppet manifest from MuranoPL directly Change-Id: I38c5cd4c2f8af194d42931ef2d70f5d8b158cac1 --- .../package/Classes/PuppetInstance.yaml | 24 ++++++++++++ .../package/Resources/ApplyManifest.template | 37 +++++++++++++++++++ .../Resources/scripts/apply_manifest.sh | 12 ++++++ 3 files changed, 73 insertions(+) create mode 100644 murano-apps/Puppet/package/Resources/ApplyManifest.template create mode 100644 murano-apps/Puppet/package/Resources/scripts/apply_manifest.sh diff --git a/murano-apps/Puppet/package/Classes/PuppetInstance.yaml b/murano-apps/Puppet/package/Classes/PuppetInstance.yaml index af10fa4..9292fdc 100644 --- a/murano-apps/Puppet/package/Classes/PuppetInstance.yaml +++ b/murano-apps/Puppet/package/Classes/PuppetInstance.yaml @@ -139,3 +139,27 @@ Methods: code => $code )) - Return: $.agent.call($template, $resources) + # + # Apply manifest + # + # Usage example: + # - $fileContent: $resources.string('example.pp') + # - $.instance1.applyManifest($fileContent) + # + # The code above is equal to: + # puppet apply example.pp + # + applyManifest: + Arguments: + - manifest: + Contract: $.string().notNull() + - timeout: + Contract: $.int().notNull() + Default: 600 + Body: + - $resources: new(sys:Resources) + - $parameters: + manifestContent: base64encode($manifest) + - $template: $resources.yaml('ApplyManifest.template').bind($parameters) + + - Return: $this.agent.call($template, $resources, $timeout) \ No newline at end of file diff --git a/murano-apps/Puppet/package/Resources/ApplyManifest.template b/murano-apps/Puppet/package/Resources/ApplyManifest.template new file mode 100644 index 0000000..932f3f1 --- /dev/null +++ b/murano-apps/Puppet/package/Resources/ApplyManifest.template @@ -0,0 +1,37 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +FormatVersion: 2.1.0 +Version: 1.0.0 +Name: Apply Puppet Manifest + +Parameters: + +Body: | + applyManifest() + +Files: + manifest: + BodyType: Base64 + Name: site.pp + Body: $manifestContent + +Scripts: + applyManifest: + Type: Application + Version: 1.0.0 + EntryPoint: apply_manifest.sh + Files: + - site.pp + Options: + captureStdout: true + captureStderr: true + verifyExitcode: true diff --git a/murano-apps/Puppet/package/Resources/scripts/apply_manifest.sh b/murano-apps/Puppet/package/Resources/scripts/apply_manifest.sh new file mode 100644 index 0000000..1122182 --- /dev/null +++ b/murano-apps/Puppet/package/Resources/scripts/apply_manifest.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set +e + +puppet apply --detailed-exitcodes --color=false "site.pp" + +PUPPET_RETURN=$? +if [ "${PUPPET_RETURN}" -eq 4 ] || [ "${PUPPET_RETURN}" -eq 6 ] ; then + exit ${PUPPET_RETURN} +fi + +set -e \ No newline at end of file