Closed jgard closed 3 weeks ago
I cannot recall when it was added, but this functionality works.
I created a component with:
schemaVersion: 1.0
constants:
- MY_VAR:
type: string
value: MY_VAR_VALUE!
phases:
- name: build
steps:
- name: CreatePlaybook
action: CreateFile
inputs:
- path: /tmp/playbook.yaml
overwrite: true
content: |
I want Image Builder to not try to substitute this next line:
{{ MY_VAR }}
When I run this and look at the file:
$ cat /tmp/playbook.yaml
I want Image Builder to not try to substitute this next line:
MY_VAR_VALUE!
Community Note
Tell us about your request I'd like to be able to write out an Ansible playbook (itself being yaml) using Image Builder Component action CreateFile. In this playbook we have a looping construct that is coincidentally, syntactically identical to component parameter substitution syntax. It uses
{{ variable }}
. I need to be able to escape those curly braces in the context of Image Builder, so the string ends up as-is in the file created in the image.Overly simplified example, not valid Ansible playbook yaml but you should get the point:
In the above example, trying to create this component would result in error
The value supplied for parameter 'data' is not valid. Parameter validation failed for document index '0' phase 'build' step 'CreatePlaybook'. Error: Parameter 'myAnsibleVariable' not declared but referenced.
I couldn't find any hint for escaping syntax in the documentation, and I tried plenty of permutations with
\
and`
Tell us about the problem you're trying to solve. What are you trying to do, and why is it hard?
Are you currently working around this issue? Saving the file to an http repository and using WebDownload
Additional context
Attachments