--- - hosts: all tasks: - name: Check run-level shell: /bin/systemctl get-default register: runlev - name: Debug stdout capture debug: msg=`{{ runlev.stdout | to_nice_yaml }}` when: ansible_distribution_major_version == '7' ignore_errors: yes