Greetings,
The documentation always uses the following syntax style when talking about or giving examples of module usage:
- name: Set up /tmp/timings file
lineinfile: >
dest=/tmp/timings line=“{{ ansible_local.preferences.launch_msg }}” create=yes
I’ve had issues in the past when I had a long list of arguments, a loop/templating, and the need to YAML escape a character or two. I ended up with quotes around the entire argument block and had difficulty getting the escape to work, the templating to work, and have the whole scalar parsable by Ansible. Then I found that the following syntax works:
- name: Set up /tmp/timings file
lineinfile:
dest: /tmp/timings
line: “{{ ansible_local.preferences.launch_msg }}”
create: yes
Which just makes a ton more sense. Easier to write and read. Got to be easier to parse.
Is there a reason the latter isn’t the suggested/recommended syntax?
Jack Neely