Skip to content

Instantly share code, notes, and snippets.

@SpikePy
Last active June 1, 2022 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SpikePy/19846d8b9050512c7f0ef83615fd34c3 to your computer and use it in GitHub Desktop.
Save SpikePy/19846d8b9050512c7f0ef83615fd34c3 to your computer and use it in GitHub Desktop.
playing with multiline commands in ansible
#! /usr/bin/env -S ansible-playbook --inventory=localhost, -v
# execute me by running `./multiline_commands.yaml`
---
- name: Playground
hosts: localhost
connection: local
gather_facts: no
tasks:
- name: >
multiline command don't need `\` because
(I think) `command` implicates everything in the
key belongs to one command and could never be
interpreted as many commands unlike `shell`
command: |
date
--utc
- name: >
multiline shell needs `\` when using `|` so that ansible can
destinguish where another command starts (without `\` that would
not be possible)
shell: |
date \
--utc
pwd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment