I'm attempting to edit a YAML file in place within the 'runcmd' block. In Bash, my command is working as expected. Here it is:
yq -i '.block1 += {"path": "dir1"} ' /ws1/project.yml
.
However, it's not functioning within the 'runcmd' block. When I include this command in the runcmd block, it disrupts my cloud-init completely. I am unable to access the host because the user block where I add my SSH key is not functional.
Can you please tell me how to properly escape special characters to ensure correct execution of cloud-init?
However, a simpler command such as
yq -i '.block1 += "path" ' /ws1/project.yml
functions properly and does not disrupt the entire cloud-config. I attempted various methods to escape double quotes, curly braces, colon, and spaces before dir1, but none were successful.
Runcmd allows list syntax that shouldn't require escaping: