Yum is a hostname ina group variable
And der are multiple yum server entries

On Fri, 24 Jan, 2020, 11:35 PM Dick Visser, <[email protected]> wrote:

> Is 'yum' a group name perhaps?
>
> On Fri, 24 Jan 2020 at 17:49, Rakesh Parida <[email protected]>
> wrote:
>
>> Hi
>>
>> Iam trying to access the variable from other hosts using hostvars. I am
>> getting the undefined error.
>> Can anybody help me: stuck at this point
>>
>>
>>
>> - hosts: yum
>>   gather_facts: false
>>   vars:
>>      file_locn: "/san/repos/{{ version }}/packages"
>>   tasks:
>>     - name: Find the Packages that are present in File location
>>       shell: ls -lrt {{ file_locn }} |awk 'NR>1{print $9}'|grep -i rpm
>>       register: files_present
>>
>>     - name: Set Fact
>>       set_fact:
>>          some_value: "{{ files_present.stdout_lines }}"
>>
>>     - debug:
>>         msg: "{{ some_value }}"
>>
>> - hosts: localhost
>>   gather_facts: false
>>   tasks:
>>     - name: Show hostvars
>>       debug:
>>         msg: "{{ hostvars['yum']['some_value'] }}"
>>
>> error:
>> PLAY [yum]
>> ***********************************************************************************************************************************************************
>>
>> TASK [Find the Packages that are present in File location]
>> ***********************************************************************************************************
>> changed: [YUM01]
>>
>> TASK [Set Fact]
>> ******************************************************************************************************************************************************
>> ok: [YUM01]
>>
>> TASK [debug]
>> *********************************************************************************************************************************************************
>> ok: [YUM01] => {
>>     "msg": [
>>         "common-3.0.12.rpm",
>>
>>     ]
>> }
>>
>> PLAY [localhost]
>> *****************************************************************************************************************************************************
>>
>> TASK [Show hostvars]
>> *************************************************************************************************************************************************
>> fatal: [localhost]: FAILED! => {"msg": "The task includes an option with
>> an undefined variable. The error was: \"hostvars['yum']\" is
>> undefined\n\nThe error appears to be in '/home/rparida1/raka1111.yml': line
>> 20, column 7, but may\nbe elsewhere in the file depending on the exact
>> syntax problem.\n\nThe offending line appears to be:\n\n  tasks:\n    -
>> name: Show hostvars\n      ^ here\n"}
>>
>> PLAY RECAP
>> ***********************************************************************************************************************************************************
>> YUM01                   : ok=3    changed=1    unreachable=0    failed=0
>>   skipped=0    rescued=0    ignored=0
>> localhost                  : ok=0    changed=0    unreachable=0
>> failed=1    skipped=0    rescued=0    ignored=0
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/f6ce73ce-1ef3-455a-9153-f52380c7b56d%40googlegroups.com
>> <https://groups.google.com/d/msgid/ansible-project/f6ce73ce-1ef3-455a-9153-f52380c7b56d%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> --
> Dick Visser
> Trust & Identity Service Operations Manager
> GÉANT
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAL8fbwN%2B-Y-6OQegKH%2BbDTEN5kcSrR3OdBwWUcLvBJXo3sMhUw%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAL8fbwN%2B-Y-6OQegKH%2BbDTEN5kcSrR3OdBwWUcLvBJXo3sMhUw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAPKxTaAFr5MQZwF7ca%3D0seV2fdbe5RTcUXfYuUmx3SpZGbT-4A%40mail.gmail.com.

Reply via email to