Ansible 模块参数语法
为什么要执行的命令任务下的playbook.yml
上,有的模块有引号,有的模块没有?
例如,如果您检查下面的语法,模块 line
嵌入在引号中,但 script
则没有。
- name: 'Execute a script on all web server nodes and start httpd service'
hosts: web_nodes
tasks:
- name: 'Update entry into /etc/resolv.conf'
lineinfile:
path: /etc/resolv.conf
line: 'nameserver 10.1.250.10'
- name: 'Execute a script'
script: /tmp/install_script.sh
Why is it that on the playbook.yml
under the command task to be executed, some modules have a quotation mark while some does not?
For example, if you check the syntax below, the module line
is with embedded in a quotation mark but script
is not.
- name: 'Execute a script on all web server nodes and start httpd service'
hosts: web_nodes
tasks:
- name: 'Update entry into /etc/resolv.conf'
lineinfile:
path: /etc/resolv.conf
line: 'nameserver 10.1.250.10'
- name: 'Execute a script'
script: /tmp/install_script.sh
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
两个模块均采用
line 的参数
或cmd
一个字符串。您的问题是关于 YAML 语法
何时引用< /a> 和 YAML 陷阱
风格指南也可能是何时以及如何引用不同方式的原因。
Both modules take as parameter for
line
orcmd
a string.Your question is about the YAML Syntax
when to quote and YAML Gotchas
Also a style guide can be a reason of different ways of when and how to quote.