cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
5305
Views
0
Helpful
6
Replies

Basic Ansible script

matthewoncisco
Frequent Visitor
Frequent Visitor

 Hi All, This is my first time writing an ansible playbook. Please can anyone help me with the following error. I'm just trying to run a basic show ver to a cisco ios switch. ansible-playbook new.yml PLAY [cisco] *********************************************************************************************************************************************** TASK [show version] **************************************************************************************************************************************** fatal: [mgmtsw1]: FAILED! => {"msg": "Unable to automatically determine host network os. Please manually configure ansible_network_os value for this host"} PLAY RECAP ************************************************************************************************************************************************* mgmtsw1 : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0 Here is my playbook. please forgive the lack of spacing here this is indented correctly in the actual playbook - hosts : cisco gather_facts : false connection : local tasks : - name : show version cisco.ios.ios_command : Commands : show version  and inventory file:  [cisco:vars] ansbile_network_os=ios ansible_connection=network_cli [cisco] mgmtsw1 ansible_host=1.1.1.1 Thanks

6 Replies 6

Hey @matthewoncisco you error message "Unable to automatically determine host network os" means that Ansible cannot automatically detect the operating system of your Cisco device. You can try adding the ansible_network_os variable directly in your playbook, like this:

- hosts: cisco
  gather_facts: false
  connection: local
  vars:
    ansible_network_os: ios
  tasks:
    - name: show version
      cisco.ios.ios_command:
        commands:
          - show version

If you share your playbook/inv file this will help in case you have other issues such as.

Edit: i saw you have In your inventory file, you have a typo in ansbile_network_os. It should be ansible_network_os.

 

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

Ruben Cocheno
Spotlight
Spotlight

@matthewoncisco 

Check the ios release and notes of the ansible collection

Tag me to follow up.
Please mark it as Helpful and/or Solution Accepted if that is the case. Thanks for making Engineering easy again.
Connect with me for more on Linkedin https://www.linkedin.com/in/rubencocheno/

Hi All,

This is my first time writing an ansible playbook. Please can anyone help me with the following error. I'm just trying to run a basic show ver to a cisco ios switch.

ansible-playbook new.yml

PLAY [cisco] ***********************************************************************************************************************************************

TASK [show version] ****************************************************************************************************************************************
fatal: [mgmtsw1]: FAILED! => {"msg": "Unable to automatically determine host network os. Please manually configure ansible_network_os value for this host"}

PLAY RECAP *************************************************************************************************************************************************
mgmtsw1 : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

Here is my playbook. please forgive the lack of spacing here this is indented correctly in the actual playbook

- hosts: cisco
gather_facts: false
connection: local
tasks:
- name: show version
cisco.ios.ios_command:
Commands: show version
 
and inventory file:
 

[cisco:vars]
ansbile_network_os=ios
ansible_connection=network_cli

[cisco]
mgmtsw1 ansible_host=1.1.1.1

Thanks

ignore - problem resolved.

thanks

what was the fix?

@jay_7301 

Are we good to close this?

Tag me to follow up.
Please mark it as Helpful and/or Solution Accepted if that is the case. Thanks for making Engineering easy again.
Connect with me for more on Linkedin https://www.linkedin.com/in/rubencocheno/