From 55054f02d77ebbca63b6fbd3eab285873452933e Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Fri, 13 Nov 2015 15:01:13 -0500 Subject: Add support for DeployArtifactURLs Adds a new nested stack deployment which allows operators to opt-in to deploy tarball's and RPM packages by setting DeployArtifactURLs as a parameter_default in a Heat environment. The intent is to use this setting to allow t-h-t to transparently deploy things like tarballs of puppet modules via a Swift Temp URL. Change-Id: I1bad4a4a79cf297f5b6e439e0657269738b5f326 Implements: blueprint puppet-modules-deployment-via-swift --- puppet/ceph-storage-post.yaml | 14 +++++++++++++- puppet/cinder-storage-post.yaml | 12 ++++++++++++ puppet/compute-post.yaml | 12 ++++++++++++ puppet/controller-post.yaml | 11 ++++++++++- puppet/deploy-artifacts.sh | 26 ++++++++++++++++++++++++++ puppet/deploy-artifacts.yaml | 32 ++++++++++++++++++++++++++++++++ puppet/swift-storage-post.yaml | 13 ++++++++++++- 7 files changed, 117 insertions(+), 3 deletions(-) create mode 100644 puppet/deploy-artifacts.sh create mode 100644 puppet/deploy-artifacts.yaml (limited to 'puppet') diff --git a/puppet/ceph-storage-post.yaml b/puppet/ceph-storage-post.yaml index f9c53465..e90710c7 100644 --- a/puppet/ceph-storage-post.yaml +++ b/puppet/ceph-storage-post.yaml @@ -14,8 +14,19 @@ parameters: type: json description: Value which changes if the node configuration may need to be re-applied - resources: + + CephStorageArtifactsConfig: + type: deploy-artifacts.yaml + + CephStorageArtifactsDeploy: + type: OS::Heat::StructuredDeployments + properties: + servers: {get_param: servers} + config: {get_resource: CephStorageArtifactsConfig} + input_values: + update_identifier: {get_param: NodeConfigIdentifiers} + CephStoragePuppetConfig: type: OS::Heat::SoftwareConfig properties: @@ -29,6 +40,7 @@ resources: CephStorageDeployment_Step1: type: OS::Heat::StructuredDeployments + depends_on: CephStorageArtifactsDeploy properties: name: CephStorageDeployment_Step1 servers: {get_param: servers} diff --git a/puppet/cinder-storage-post.yaml b/puppet/cinder-storage-post.yaml index 9b7c752a..f470203f 100644 --- a/puppet/cinder-storage-post.yaml +++ b/puppet/cinder-storage-post.yaml @@ -14,8 +14,20 @@ parameters: resources: + VolumeArtifactsConfig: + type: deploy-artifacts.yaml + + VolumeArtifactsDeploy: + type: OS::Heat::StructuredDeployments + properties: + servers: {get_param: servers} + config: {get_resource: VolumeArtifactsConfig} + input_values: + update_identifier: {get_param: NodeConfigIdentifiers} + VolumePuppetConfig: type: OS::Heat::SoftwareConfig + depends_on: VolumeArtifactsDeploy properties: group: puppet options: diff --git a/puppet/compute-post.yaml b/puppet/compute-post.yaml index 3861e50c..a122df0e 100644 --- a/puppet/compute-post.yaml +++ b/puppet/compute-post.yaml @@ -17,6 +17,17 @@ parameters: resources: + ComputeArtifactsConfig: + type: deploy-artifacts.yaml + + ComputeArtifactsDeploy: + type: OS::Heat::StructuredDeployments + properties: + servers: {get_param: servers} + config: {get_resource: ComputeArtifactsConfig} + input_values: + update_identifier: {get_param: NodeConfigIdentifiers} + ComputePuppetConfig: type: OS::Heat::SoftwareConfig properties: @@ -30,6 +41,7 @@ resources: ComputePuppetDeployment: type: OS::Heat::StructuredDeployments + depends_on: ComputeArtifactsDeploy properties: name: ComputePuppetDeployment servers: {get_param: servers} diff --git a/puppet/controller-post.yaml b/puppet/controller-post.yaml index d250dd70..713ad706 100644 --- a/puppet/controller-post.yaml +++ b/puppet/controller-post.yaml @@ -17,6 +17,15 @@ parameters: resources: + ControllerArtifactsConfig: + type: deploy-artifacts.yaml + + ControllerArtifactsDeploy: + type: OS::Heat::StructuredDeployments + properties: + servers: {get_param: servers} + config: {get_resource: ControllerArtifactsConfig} + ControllerPrePuppet: type: OS::TripleO::Tasks::ControllerPrePuppet properties: @@ -33,7 +42,7 @@ resources: # e.g all Deployment resources should have a *Deployment_StepN suffix ControllerLoadBalancerDeployment_Step1: type: OS::Heat::StructuredDeployments - depends_on: ControllerPrePuppet + depends_on: [ControllerPrePuppet, ControllerArtifactsDeploy] properties: name: ControllerLoadBalancerDeployment_Step1 servers: {get_param: servers} diff --git a/puppet/deploy-artifacts.sh b/puppet/deploy-artifacts.sh new file mode 100644 index 00000000..22fde9a7 --- /dev/null +++ b/puppet/deploy-artifacts.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +TMP_DATA=$(mktemp -d) +function cleanup { + rm -Rf "$TMP_DATA" +} +trap cleanup EXIT + +if [ -n "$artifact_urls" ]; then + for URL in $(echo $artifact_urls | sed -e "s| |\n|g" | sort -u); do + curl -o $TMP_DATA/file_data "$artifact_urls" + if file -b $TMP_DATA/file_data | grep RPM &>/dev/null; then + yum install -y $TMP_DATA/file_data + elif file -b $TMP_DATA/file_data | grep 'gzip compressed data' &>/dev/null; then + pushd / + tar xvzf $TMP_DATA/file_data + popd + else + echo "ERROR: Unsupported file format." + exit 1 + fi + rm $TMP_DATA/file_data + done +else + echo "No artifact_urls was set. Skipping..." +fi diff --git a/puppet/deploy-artifacts.yaml b/puppet/deploy-artifacts.yaml new file mode 100644 index 00000000..17f84163 --- /dev/null +++ b/puppet/deploy-artifacts.yaml @@ -0,0 +1,32 @@ +heat_template_version: 2015-04-30 + +description: > + Software Config to install deployment artifacts (tarball's and/or + distribution packages) via HTTP URLs. The contents of the URL's can + be tarballs or distribution packages (RPMs). If a tarball URL is supplied + it is extracted onto the target node during deployment. If a package is + deployed it is installed from the supplied URL. Note, you need the + heat-config-script element built into your images, due to the script group + below. + +parameters: + DeployArtifactURLs: + default: [] + description: A list of HTTP URLs containing deployment artifacts. + Currently supports tarballs and RPM packages. + type: comma_delimited_list + +resources: + DeployArtifacts: + type: OS::Heat::SoftwareConfig + properties: + group: script + inputs: + - name: artifact_urls + default: {list_join: [' ', {get_param: DeployArtifactURLs}]} + config: {get_file: ./deploy-artifacts.sh} + +outputs: + OS::stack_id: + description: The ID of the DeployArtifacts resource. + value: {get_resource: DeployArtifacts} diff --git a/puppet/swift-storage-post.yaml b/puppet/swift-storage-post.yaml index a55b3959..eb06b241 100644 --- a/puppet/swift-storage-post.yaml +++ b/puppet/swift-storage-post.yaml @@ -12,9 +12,19 @@ parameters: type: json description: Value which changes if the node configuration may need to be re-applied - resources: + StorageArtifactsConfig: + type: deploy-artifacts.yaml + + StorageArtifactsDeploy: + type: OS::Heat::StructuredDeployments + properties: + servers: {get_param: servers} + config: {get_resource: StorageArtifactsConfig} + input_values: + update_identifier: {get_param: NodeConfigIdentifiers} + StoragePuppetConfig: type: OS::Heat::SoftwareConfig properties: @@ -28,6 +38,7 @@ resources: StorageDeployment_Step1: type: OS::Heat::StructuredDeployments + depends_on: StorageArtifactsDeploy properties: name: StorageDeployment_Step1 servers: {get_param: servers} -- cgit 1.2.3-korg