Ansible: How to add variables to “command” or “shell”

五迷三道 提交于 2019-12-01 16:36:10

Quote the full string in the command argument:

- name: Iniciar zkfc
  command: "{{ hadoop_version }}/sbin/hadoop-daemon.sh start zkfc"

The syntax error is because you started a value with {. If you begin a value with a variable like so:

command: {{ my_var }}

then you must quote the whole line:

command: "{{ my_var }}"

This is due to the parser not being able to distinguish between YAML's dictionary syntax and variable interpolation otherwise.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!