How to execute the process every time even if the content of the template that defines NodeExtraConfig has not changed?

Solution In Progress - Updated -

Environment

  • Red Hat OpenStack Platform 16.2

Issue

  • openstack overcloud deploy is not executed if the contents of the template have not changed from the last time it was executed.
  • How to execute a script definded under NodeExtraConfig in a heat template every deployment even if the content has not changed?

Resolution

  • When the DeployIdentifier option was used, the process was always executed even if there were no changes in the template.

/home/stack/templates/pre_config.yaml:

resource_registry:
  OS::TripleO::NodeExtraConfig: /home/stack/templates/test.yaml  <==(*)

parameter_defaults:
  nameserver_ip: 192.168.1.1

/home/stack/templates/test.yaml:

heat_template_version: 2014-10-16

description: >
  Extra hostname configuration

parameters:
  server:
    type: string
  nameserver_ip:
    type: string
  DeployIdentifier:  <==(*)
    type: string

resources:
  CustomExtraConfigPre:
    type: OS::Heat::SoftwareConfig
    properties:
      group: script
      config:
        str_replace:
          template: |
            #!/bin/sh
            echo "nameserver _NAMESERVER_IP_" >> /tmp/test.txt
          params:
            _NAMESERVER_IP_: {get_param: nameserver_ip}

  CustomExtraDeploymentPre:
    type: OS::Heat::SoftwareDeployment
    properties:
      server: {get_param: server}
      config: {get_resource: CustomExtraConfigPre}
      actions: ['CREATE','UPDATE']
      input_values:
        deploy_identifier: {get_param: DeployIdentifier} <==(*)

outputs:
  deploy_stdout:
    description: Deployment reference, used to trigger pre-deploy on changes
    value: {get_attr: [CustomExtraDeploymentPre, deploy_stdout]}

Root Cause

  • Defining a DeployIdentifier for a resource updates the timestamp of the resource. Therefore, each time a resource is deployed, the timestamp is updated and the NodeExtraConfig process is executed each time.

Diagnostic Steps

Set the script that creates the test.txt file to template and perform openstack overcloud deploy 3 times.

  • Result of the first deploy
-rw-r--r--. 1 root root 23 Jan 21 13:31 test.txt
  • Result of the second deploy without DeployIdentifier option
    If the content of the template does not change, the process is skipped.
-rw-r--r--. 1 root root 23 Jan 21 13:31 test.txt
  • Result of the third deploy with DeployIdentifier option
    The file has been re-created and the timestamps have been updated.
-rw-r--r--. 1 root root 46 Jan 21 14:09 test.txt

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments