getting error when test ping on router ios

Hi,

I’m trying test ping using command “ansible -m ping all” and then i getting error bellow :

ansible -m ping all

[WARNING]: * Failed to parse /etc/ansible/hosts with yaml plugin: Syntax Error while loading YAML. found unexpected ‘:’ The error appears to have been in
‘/etc/ansible/hosts’: line 1, column 5, but may be elsewhere in the file depending on the exact syntax problem. The offending line appears to be: [all:vars] ^
here
[WARNING]: * Failed to parse /etc/ansible/hosts with ini plugin: /etc/ansible/hosts:18: Expected key=value, got: $ANSIBLE_VAULT;1.1;AES256
[WARNING]: Unable to parse /etc/ansible/hosts as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match ‘all’

this is my inventory hosts :

[all:vars]
ansible_connection=network_cli
ansible_user=user

[router:children]
ios

[ios]
10.10.1.5

[ios:vars]
ansible_become=yes
ansible_become_method=enable
ansible_network_os=ios
ansible_user=my_ios_user
ansible_ssh_pass= !vault |
$ANSIBLE_VAULT;1.1;AES256
61323831323164346239346133663762653837326630303338363961313834396231656466616161
6461653339343465386635333832636533643531376661380a333138383665646236326262303362
30656633383131396461653035663561393938633762623838366464313439386337313631636137
3836343261363663640a393331653163353864666431396662333735633539343765646635306464
6563

Any help would be much appreciated.

Hello Aris,
you are trying to define the hosts file like a ini file (with name=value and group:vars) but you are trying to read like if it’s in yaml format.
More information about how to describe in yaml/ini format here => https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html

To change and read as ini file (as default) you need to edit ansible.cfg and comment the line starting with “enable_plugins” ynder the [inventory] section.

I hope this helps you

I don’t believe the ping module will work with any device that cannot run python locally. https://docs.ansible.com/ansible/2.5/modules/ping_module.html