How to do multiline shell script in Ansible 

Hits: 717

I found the following works to run several commands in an ansible-playbook. This also shows the output.

---
- hosts: two
  gather_facts: no
  tasks:
  - name: Executing a Command Using Shell Module
    shell:  
      date
      ls
    register: cat
  - debug: var=cat.stdout_lines

Source: How to do multiline shell script in Ansible – Stack Overflow