Noticing error while using loop to install multiple packages

  • name: ‘Install required packages through LOOPS’
    hosts: DEV_NIFI_AMB_RANGER_1.12
    vars:
    packages:
    - httpd
    - nfs-utils
    - wget
    - telnet
    - ntp
    - nscd
    tasks:
    -
    yum:
    name: ‘{{ item }}’
    state: ‘present’
    update_cache: True
    loop: ‘{{packages}}’

ansible-playbook -i /opt/scripts/ansible/inventory/inventory.txt /opt/scripts/ansible/code/install_nifi_loop.yml
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details

PLAY [Install required packages] ******************************************************************************************************************************

TASK [Gathering Facts] ****************************************************************************************************************************************
ok: [ldappambari01]
ok: [ldappranger001]
ok: [ldappnifirgt001]
ok: [ldappcdf002]
ok: [ldappcdf001]
ok: [ldappranger002]

TASK [yum] ****************************************************************************************************************************************************
fatal: [ldappambari01]: FAILED! => {“msg”: “The task includes an option with an undefined variable. The error was: ‘item’ is undefined\n\nThe error appears to be in ‘/opt/scripts/ansible/code/install_nifi_loop.yml’: line 15, column 13, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n -\n yum:\n ^ here\n”}
fatal: [ldappcdf001]: FAILED! => {“msg”: “The task includes an option with an undefined variable. The error was: ‘item’ is undefined\n\nThe error appears to be in ‘/opt/scripts/ansible/code/install_nifi_loop.yml’: line 15, column 13, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n -\n yum:\n ^ here\n”}
fatal: [ldappcdf002]: FAILED! => {“msg”: “The task includes an option with an undefined variable. The error was: ‘item’ is undefined\n\nThe error appears to be in ‘/opt/scripts/ansible/code/install_nifi_loop.yml’: line 15, column 13, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n -\n yum:\n ^ here\n”}
fatal: [ldappnifirgt001]: FAILED! => {“msg”: “The task includes an option with an undefined variable. The error was: ‘item’ is undefined\n\nThe error appears to be in ‘/opt/scripts/ansible/code/install_nifi_loop.yml’: line 15, column 13, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n -\n yum:\n ^ here\n”}
fatal: [ldappranger001]: FAILED! => {“msg”: “The task includes an option with an undefined variable. The error was: ‘item’ is undefined\n\nThe error appears to be in ‘/opt/scripts/ansible/code/install_nifi_loop.yml’: line 15, column 13, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n -\n yum:\n ^ here\n”}
fatal: [ldappranger002]: FAILED! => {“msg”: “The task includes an option with an undefined variable. The error was: ‘item’ is undefined\n\nThe error appears to be in ‘/opt/scripts/ansible/code/install_nifi_loop.yml’: line 15, column 13, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n -\n yum:\n ^ here\n”}

PLAY RECAP ****************************************************************************************************************************************************
ldappambari01 : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
ldappcdf001 : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
ldappcdf002 : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
ldappnifirgt001 : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
ldappranger001 : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
ldappranger002 : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

cat /opt/scripts/ansible/inventory/inventory.txt
[DEV_NIFI_AMB_RANGER_1.12]
ldappambari01
ldappcdf001
ldappcdf002
ldappnifirgt001
ldappranger001
ldappranger002

[DEV_ZKPR_KAFKA_1.12]
ldappzkpr001
ldappzkpr002
ldappzkpr003
ldappcdfkfk001
ldappcdfkfk002
ldappcdfkfk003
ldappschmrgt001

[DEV_1.12:children]
DEV_NIFI_AMB_RANGER_1.12
DEV_ZKPR_KAFKA_1.12

Two questions

  1. any pointers about the below warning

[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details

  1. There is one failed task based on the result and fatal
    pointers here please

fatal: [ldappambari01]: FAILED! => {“msg”: “The task includes an option with an undefined variable. The error was: ‘item’ is undefined\n\nThe error appears to be in ‘/opt/scripts/ansible/code/install_nifi_loop.yml’: line 15, column 13, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n -\n yum:\n ^ here\n”}

First, you have an indentation problem so please check the link below then fix it and try again:

https://docs.ansible.com/ansible/latest/collections/ansible/builtin/yum_module.html