可以打印debugging信息variables

我尝试使用mosh_version debug msg命令打印先前注册的mosh_versionvariables,如下所示:

 - name: Print mosh version debug: msg="Mosh Version: {{ mosh_version.stdout }}" 

它不起作用,并输出以下错误:

 Note: The error may actually appear before this position: line 55, column 27 - name: Print mosh version debug: msg="Mosh Version: {{ mosh_version.stdout }}" ^ We could be wrong, but this one looks like it might be an issue with missing quotes. Always quote template expression brackets when they start a value. For instance: with_items: - {{ foo }} Should be written as: with_items: - "{{ foo }}" 

我试过了

 - name: Print mosh version debug: msg=Mosh Version: "{{ mosh_version.stdout }}" 

但是这只会打印“Mosh”。

什么是最好的方式来实现这个运行?

尝试这个:

 - name: Print mosh version debug: "msg=Mosh Version: '{{ mosh_version.stdout }}'" 

http://docs.ansible.com/YAMLSyntax.html#gotchas中有更多信息

编辑:这样的东西对我来说是完美的:

 - name: Check Ansible version command: ansible --version register: ansibleVersion - name: Print version debug: msg: "Ansible Version: {{ ansibleVersion.stdout }}" 

http://pastie.org/private/cgeqjucn3l5kxhkkyhtpta

最简单的答案

 - debug: var=mosh_version.stdout 

只要删除冒号

 debug: msg="Mosh Version {{ mosh_version.stdout }}" 

我使用这个,注意双引号(“)和单引号(')的位置

 - name: Print mosh version debug: "msg='Mosh Version: {{ mosh_version.stdout }}'"