I am using below dynamic inventory file(JSON) and the Playbook YML. I am not able to execute it. Getting an error. Need your inputs.
my_dynamic_inventory --list
{
"_meta": {
"hostvars": {
Node_001": {
"model_name":"router1",
"ansible_user":"xxx",
"ansible_password":"xxx",
"ansible_port":"20",
"ansible_host":"172.xx.xx.xx",
"snmp_version":"2c",
"snmp_community":"public",
"snmp_port":"yyyy",
"stack_node_num":"5"
"ansible_network_os":"moduleA"
}
},
},
"all": {
"hosts": ["Node_001"]
}
}
YML file:
---
- hosts: all
gather_facts: off
connection: local
tasks:
- name: create vlan entry
necqx_vlan:
vlan_id: 194
name: VLAN1
state: present
model: router1
When I execute the play book with the dynamic inventory file I am getting below error
[WARNING]: * Failed to parse /Path_to_dynamic_inventory/dynamic_inventory with ini plugin: /Path_to_dynamic_inventory/dynamic_inventory:1: Expected key=value host variable assignment, got: --list
File "/usr/lib/python2.7/site-packages/ansible/plugins/inventory/ini.py", line 132, in parse self._parse(path, data) File "/usr/lib/python2.7/site-packages/ansible/plugins/inventory/ini.py", line 210, in _parse hosts, port, variables = self._parse_host_definition(line) File "/usr/lib/python2.7/site-packages/ansible/plugins/inventory/ini.py", line 308, in _parse_host_definition self._raise_error("Expected key=value host variable assignment, got: %s" % (t)) File "/usr/lib/python2.7/site-packages/ansible/plugins/inventory/ini.py", line 137, in _raise_error raise AnsibleError("%s:%d: " % (self._filename, self.lineno) + message)
[WARNING]: Unable to parse /Path_to_dynamic_inventory/dynamic_inventory 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'
.... ...
PLAY [all] **************************************************************************************************************
skipping: no hosts matched
my_dynamic_inventory --list
is not valid JSON syntax. – techraf