Sometimes ansible is not enough, and you want to unleash the raw shell power. But long one-line scripts look totally unreadable. Here is how you can do it with YAML multi-line representation:

- name : long shell script shell : | cat /proc/cmdline | tr ' ' '

' | while read param; do if [[ "$param" == root=* ]]; then echo ${param#root=} fi done args : executable : /bin/bash register : boot_param_root

Links:

UPD androidul on reddit suggested to use file or template lookups for embedding long scripts. IMHO that’s a good idea for really large scripts, but for 5-7 lines YAML multi-line is more readable.