YAML - 用值替换变量?
考虑以下 yaml
hadoop:
storage: '/x/y/z/a/b'
streaming_jar_path: '/x/c/d/f/r/*.jar'
commands:
mkdir: 'hadoop dfs -mkdir dir'
copyFromLocal: 'hadoop dfs -copyFromLocal from_path to_path'
run: 'hadoop jar $streaming_jar_path -mapper mapper_path -reducer reducer_path -input hdfs_input -output hdfs_output'
我想将 streaming_jar_path
的值替换为 $streaming_jar_path
,我该怎么做?
我知道我们可以使用&(anchors)
合并
哈希
,但在这里我只想更改一个值
如果这是一件微不足道的事情,我很抱歉,我对 YAML
很陌生,
谢谢
consider the following yaml
hadoop:
storage: '/x/y/z/a/b'
streaming_jar_path: '/x/c/d/f/r/*.jar'
commands:
mkdir: 'hadoop dfs -mkdir dir'
copyFromLocal: 'hadoop dfs -copyFromLocal from_path to_path'
run: 'hadoop jar $streaming_jar_path -mapper mapper_path -reducer reducer_path -input hdfs_input -output hdfs_output'
I want to substitute the value of streaming_jar_path
to $streaming_jar_path
, how can I do that?
I know we can merge
the hashes
using &(anchors)
but here i just want to change one value
I am sorry if this is trivial thing, I am very new to YAML
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以重构您的
YAML
文件并使用 Ansible 执行。Commands.yml:
然后只需运行
ansible-playbook
即可执行 shell 命令:You can restructure your
YAML
file and execute with Ansible.commands.yml:
Then simply run
ansible-playbook
to execute shell commands:这应该是一个读取文件、编辑数据并写回文件的简单过程。
This should be a simple process of reading your file, editing the data and writing back to file.