I try to print the previously registered mosh_version
variable using the ansible debug msg
command like this:
- name: Print mosh version
debug: msg="Mosh Version: {{ mosh_version.stdout }}"
It doesn't work and prints the following error:
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 }}"
I tried
- name: Print mosh version
debug: msg=Mosh Version: "{{ mosh_version.stdout }}"
but this will just print "Mosh".
What's the best way to get this running?
Try this:
More info in http://docs.ansible.com/YAMLSyntax.html#gotchas
Edited: Something like this works perfect for me:
http://pastie.org/private/cgeqjucn3l5kxhkkyhtpta
Simplest answer
I have displayed variable and message in the same debug play.
Ansible Task
Output
Just remove the colon
Anytime I have problems with special characters in Ansible strings/cmds I do this:
So your standard colon becomes
{{':'}}
And your task becomes:
Again this works for most special characters, even strings. Consider the following:
In order to run this in Ansible, just apply the same logic, the following task executes as expected:
I use this, notice the location of double quotes(") and single quotes(')