Additional information after more testing.  All seems to work if I use 
--limit instead of -i.

I.e.:

This works:
ansible-playbook -k first_playbook_ext_ios2.yml --limit csr1

This does not work:
ansible-playbook -i csr1, first_playbook_ext_ios2.yml -k

Is this expected behavior?  Any pointers or doc links on what I'm missing 
in terms of differences between the two options above?

Thank you!

On Tuesday, March 15, 2022 at 4:11:21 PM UTC-4 EE1 wrote:

> Hi All,
>
> I seem to be having an issue defining a variables in my 
> /etc/ansible/hosts.  When I run a playbook against a host in my inventory, 
> it seems the variable are not read based on the error messages.  For 
> example, here it seems to not see the network os variable:
>
> ansible-playbook -i csr1, first_playbook_ext_ios2.yml
>
> PLAY [Network Getting Started First Playbook - Change Hostname] 
> ****************************************************************************************************************
>
> TASK [Get old config for ios devices] 
> ******************************************************************************************************************************************
> fatal: [csr1]: FAILED! => {"msg": "Unable to automatically determine host 
> network os. Please manually configure ansible_network_os value for this 
> host"}
>
> PLAY RECAP 
> *********************************************************************************************************************************************************************
> csr1                       : ok=0    changed=0    unreachable=0   
>  failed=1    skipped=0    rescued=0    ignored=0
>
> Even though the variable is defined and shows up in ansible-inventory:
>
>  ansible-inventory --host csr1
> {
>     "ansible_become": true,
>     "ansible_become_method": "enable",
>     "ansible_become_password": "cisco",
>     "ansible_host": "192.168.1.73",
>     "ansible_network_os": "ios",
>     "ansible_user": "admin"
> }
>
> Here is the hosts file:
>
> cat /etc/ansible/hosts
> ---
> nxos:
>   hosts:
>     nxos1:
>       ansible_host: 192.168.1.71
>     nxos2:
>       ansible_host: 192.168.1.72
>   vars:
>     ansible_network_os: nxos
>
> ios:
>   hosts:
>     csr1:
>       ansible_host: 192.168.1.73
>   vars:
>     ansible_network_os: ios
>     ansible_become: yes
>     ansible_become_method: enable
>     ansible_become_password: cisco
>
> network:
>   children:
>     ios:
>     nxos:
>   vars:
>     ansible_user: admin
>
>
> If I set the os variable manually at the command line, then it seems to 
> fail on the name alias part:
>
> ansible-playbook -i csr1, first_playbook_ext_ios2.yml -e 
> ansible_network_os=ios
>
> PLAY [Network Getting Started First Playbook - Change Hostname] 
> ****************************************************************************************************************
>
> TASK [Get old config for ios devices] 
> ******************************************************************************************************************************************
> fatal: [csr1]: FAILED! => {"changed": false, "msg": "[Errno -3] Temporary 
> failure in name resolution"}
>
> PLAY RECAP 
> *********************************************************************************************************************************************************************
> csr1                       : ok=0    changed=0    unreachable=0   
>  failed=1    skipped=0    rescued=0    ignored=0
>
> Is something obvious wrong with my inventory file?  Anything else this 
> newbie is overlooking?
>
> Thanks in advance.
>  
>

-- 
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/502ad726-3fbf-4ca8-bbb4-a514ae1c3b09n%40googlegroups.com.

Reply via email to