How to run multiline shell script in Ansible?

Viewed 59

I have encountered an error while running this, I have checked the indentation but not sure why

- name: Ensure System accounts are non-login
    shell: >
             egrep -v '^\+' /etc/passwd |
             awk -F: '($1!="root" && $1!="sync" && $1!="shutdown" && $1!="halt" && $3<1000 && $7!="/usr/sbin/nologin" && $7!="/bin/false") {print}' 
    register: system

- debug:
    msg: "{{ system.stdout }}"

This is the error, I don't understand it.

The offending line appears to be:

    - name: Ensure System accounts are non-login
        shell: >
             ^ here
1 Answers

well, it seems that it is about:

- name: Ensure System accounts are non-login
  shell: >

instead of

- name: Ensure System accounts are non-login
    shell: >
Related