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/58f368ee-a17a-4c35-a89b-bfebd8a86e38n%40googlegroups.com.

Reply via email to