Modify the cloudConfig property within customProperties
search cancel

Modify the cloudConfig property within customProperties

book

Article ID: 325833

calendar_today

Updated On:

Products

VMware Aria Suite

Issue/Introduction

Symptoms:
Changes made in allocation phase are not persisted after the create phase of a deployment. This happens when the syntax ${self.....} inside the property is changed in the allocation phase.

Environment

VMware Aria Automation 8.x

Cause

Using ${self} inside a cloudConfig & updating the cloudConfig using __computeConfigContent property will lead to cloudConfig not being updated. This happens if cloudConfig script contains references to self or resource in any section of the script (not only runcmd, in any section or module of the script).

Example blueprint which causes this issue:
formatVersion: 1
inputs: {}
resources:
  vSphere_VM:
    type: Cloud.vSphere.Machine
    properties:
      name: ${replace(env.projectName, " ", "-")}
      imageRef: https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-amd64.ova
      cpuCount: 2
      totalMemoryMB: 2048

      cloudConfigSettings:
        deploymentFailOnCloudConfigRuntimeError: true
      customCloudConfig: |
        runcmd:
          - echo Hello
      cloudConfig: |
        ssh_pwauth: true
        chpasswd:
          expire: false
          users:
            - name: root
              password: VMware1!
              type: text
        runcmd:
          - hostnamectl set-hostname ${self.resourceName}
          - eject

Resolution

Use ${input...} or ${env...} variables instead of ${self...}.

Additional Information

Blueprint which works & updates the cloudConfig even after Create phase is shown below:
formatVersion: 1
inputs: {}
resources:
  vSphere_VM:
    type: Cloud.vSphere.Machine
    properties:
      name: ${replace(env.projectName, " ", "-")}
      imageRef: https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-amd64.ova
      cpuCount: 2
      totalMemoryMB: 2048

      cloudConfigSettings:
        deploymentFailOnCloudConfigRuntimeError: true
      customCloudConfig: |
        runcmd:
          - echo Hallo
      cloudConfig: |
        ssh_pwauth: true
        chpasswd:
          expire: false
          users:formatVersion: 1
inputs: {}
resources:
  vSphere_VM:
    type: Cloud.vSphere.Machine
    properties:
      name: ${replace(env.projectName, " ", "-")}
      imageRef: https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-amd64.ova
      cpuCount: 2
      totalMemoryMB: 2048

      cloudConfigSettings:
        deploymentFailOnCloudConfigRuntimeError: true
      customCloudConfig: |
        runcmd:
          - echo Hallo
      cloudConfig: |
        ssh_pwauth: true
        chpasswd:
          expire: false
          users:
            - name: root
              password: VMware1!
              type: text
        runcmd:
          - hostnamectl set-hostname ${replace(env.projectName, " ", "-")}
          - eject
            - name: root
              password: VMware1!
              type: text
        runcmd:
          - hostnamectl set-hostname ${replace(env.projectName, " ", "-")}
          - eject


Impact/Risks:
The cloudConfig will be updated in Allocate phase of the resource, but it will go back to the original cloudConfig after the create phase.