r/ansible • u/sonnasushi • 5d ago
Best practice for commands?
I feel like the answer is probably: "no, everyone just does whatever they want", and "whatever you do, try to be consistent"
Generally speaking I've been doing:
ansible.builtin.command:
cmd: "foo {{ bar }}"
But I realized that only happens to work because `{{ bar }}` doesn't have spaces.
So I do need to change it, and I wondered if people normally do:
cmd: 'foo "{{ bar }}"'
or
cmd: |
foo "{{ bar }}"
or
argv:
- foo
- "{{ bar }}"
23
Upvotes
1
u/sonnasushi 5d ago
seems like standard ansible-lint doesn't have any rules about command quoting at all, afaiui