Add support for DeployArtifactURLs
authorDan Prince <dprince@redhat.com>
Fri, 13 Nov 2015 20:01:13 +0000 (15:01 -0500)
committerDan Prince <dprince@redhat.com>
Fri, 26 Feb 2016 21:55:44 +0000 (16:55 -0500)
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
puppet/cinder-storage-post.yaml
puppet/compute-post.yaml
puppet/controller-post.yaml
puppet/deploy-artifacts.sh [new file with mode: 0644]
puppet/deploy-artifacts.yaml [new file with mode: 0644]
puppet/swift-storage-post.yaml

index f9c5346..e90710c 100644 (file)
@@ -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}
index 9b7c752..f470203 100644 (file)
@@ -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:
index 3861e50..a122df0 100644 (file)
@@ -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}
index d250dd7..713ad70 100644 (file)
@@ -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 (file)
index 0000000..22fde9a
--- /dev/null
@@ -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 (file)
index 0000000..17f8416
--- /dev/null
@@ -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}
index a55b395..eb06b24 100644 (file)
@@ -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}