Documented Syntax with Modules

20 views
Skip to first unread message

Jack Neely

unread,
Mar 14, 2014, 11:11:29 AM3/14/14
to ansible...@googlegroups.com
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 

Michael DeHaan

unread,
Mar 17, 2014, 9:49:25 AM3/17/14
to ansible...@googlegroups.com
Hi Jack!

No real reason, the older single-line forms came first and I think some of us like more compact playbooks.

It's something of a stylistic choice.

--Michael


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/0d737fbc-50b5-45a1-b6d8-d6ffc3c21a43%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages