-1
- name: get user list from centOs
            ansible.builtin.shell:
                    cmd: cat /etc/passwd
            when: ansible_distribution == "CentOs"
            register: command_output
          - debug:
                  var: command_output.stdout_lines

When I run this playbook it shows like this

TASK [get user list from centOs] ***************************************************************************************************************************************
skipping: []

TASK [debug] ***********************************************************************************************************************************************************
ok: [] => {
    "command_output.stdout_lines": "VARIABLE IS NOT DEFINED!"
}
tripleee
  • 1,416
  • 3
  • 15
  • 24

1 Answers1

1

Your task is skipped because you specified:

when: ansible_distribution == "CentOs"

This must be a typo. There is no distribution "CentOs" defined. There is a distribution "CentOS". Try that instead.

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972