The yaml file is like this:
settings:
clusterName: dev
dbServer: test.db.com
dcsHostName: dev
overrideDevRepo: "true"
globalSuspend: "true"
sharedConfig: "true"
I want to pass globalSuspend as a toggle variable, update true to false or false to true, but as helm need the quote, so quote are needed, also yaml is format sensitive, the leading spaces must be kept as same. Need a way to do it saltstack simple cmd.run or state playbook. Or at least please help on how to do in bash. But I find my command works in bash does not work in saltstack as: colon is a trouble in salt. thanks.
"toggle the suspend value":
cmd.run:
- name: sed -i '/globalSuspend/!b;c \ \ globalSuspend: "{{suspend}}"' settings.yaml
- runas: vagrant
The above does not work because of the colon and also does not keep the leading spaces.
Colon is a special character in YAML. Use a literal block scalar to treat everything as content:
"toggle the suspend value":
cmd.run:
- name: |-
sed -i '/globalSuspend/!b;c \ \ globalSuspend: "{{suspend}}"' settings.yaml
- runas: vagrant
|
starts a literal block scalar. Each following line that is more indented is part of the scalar. The -
means that the final line break is not part of the scalar (wich it would otherwise be).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.