I'm trying to use custom properties in a template as a strategy for a use case but isn't working.
resources:
Cloud_Machine_1:
type: Cloud.Machine
properties:
image: Ubuntu
flavor: small
resourcePool: global
constraints:
- tag: 'project:${self.resourcePool}'
The Template fail because is trying to find a resource with the tag "project:null:hard".
What I am missing? If this doesn't work, what can I do to get the same result?
Thanks a lot.
Hey,
Try the following:
resources:
Cloud_Machine_1:
type: Cloud.Machine
properties:
image: Ubuntu
flavor: small
resourcePool: global
constraints:
- tag: ${"project:" + self.resourcePool}
Same result as before...
Very odd. Can you post the complete YAML on here? And which version of vRA are you running?
The version is 8.6.2. This is the complete template:
formatVersion: 1
inputs: {}
resources:
Cloud_Machine_1:
type: Cloud.Machine
properties:
image: Ubuntu
flavor: small
resourcePool: global
constraints:
- tag: 'project:${self.resourcePool}'
networks:
- network: '${resource.Cloud_Network_1.id}'
assignment: static
Cloud_Network_1:
type: Cloud.Network
properties:
networkType: existing
constraints:
- tag: net:dmz
- tag: 'project:${self.resourcePool}'
Try changing the property name to something that doesn't relate to an API object. For example change it to myResourcePool and see what happens
I've used the same approach to pass data for the Cloud-Init block. But I guess that the placement evaluation is done before the replacement.
Yes, the idea is to use the value of the custom property defined in the same Template.
In my YAML I have this section under the virtual machine resource which is working, albeit from an input. Sorry, I cannot post the complete YAML but you should get the drift.
constraints:
- tag: ${"cloud.zone.environment:" + input.environment}
- tag: '${input.environment == "non-prod" ? "cloud.account:nonprodWindows" : "cloud.account:prodWindows"}'
- tag: cloud.zone.type:windows
I've tried this and got the same result:
myUniqueName: global
constraints:
- tag: 'project:${self.myUniqueName}'
For me, this is a bug.
The replacement work fine when you use Input variables, but not with custom properties. That is my point.
And this?
myUniqueName: global
constraints:
- tag: ${"project:" + self.myUniqueName}
This is working for me in the latest version
Ah, ok. Understood. I will try and test
Then use a read-only input variable with default value 'global'
Map this input to resourcePool and constraint tag
That doesn't solve my problem. And it will be visible to the user.
The idea is that I can override the Custom Property in the template for a similar custom property in the Project. It works if I use it in the Cloud-Init block, but it seams that the placement evaluation is done before the replacement.
You can always hide an input with Custom Forms.
Also, if this is project-specific, you can use secrets to use custom values.
Resource self variables are allowed only for resources supporting the allocation phase. Resource self variables are only available (or only have a value set) after the allocation phase is complete.
Check the doc for same
I would suggest you to use input with custom form ,use the visibility option to hide it