I’m able to get the list of my hosts from the yml file when running this command
$ /opt/ansible/static/inventory/inventory.py https://github.com/adeyeri88/test.git staging.yml
{
“_meta”: {
“hostvars”: {}
},
“db”: {
“children”: [
“db-site2”,
“db-site1”
]
},
“db-site1”: {
“hosts”: [
“bary785c.mylabserver.com”,
“bary786c.mylabserver.com”
]
},
“db-site2”: {
“hosts”: [
“bary783c.mylabserver.com”,
“bary785c.mylabserver.com”
]
},
“site1”: {
“children”: [
“staging-site1”
]
},
“site2”: {
“children”: [
“staging-site2”
]
},
“staging”: {
“children”: [
“web”,
“db”
]
},
“staging-db”: {
“children”: [
“db”
]
},
“staging-db-site1”: {
“children”: [
“db-site1”
]
},
“staging-db-site2”: {
“children”: [
“db-site2”
]
},
“staging-site1”: {
“children”: [
“web-site1”,
“db-site1”
]
},
“staging-site2”: {
“children”: [
“web-site2”,
“db-site2”
]
},
“staging-web”: {
“children”: [
“web”
]
},
“staging-web-site1”: {
“children”: [
“web-site1”
]
},
“staging-web-site2”: {
“children”: [
“web-site2”
]
},
“web”: {
“children”: [
“web-site2”,
“web-site1”
]
},
“web-site1”: {
“hosts”: [
“bary781c.mylabserver.com”,
“bary782c.mylabserver.com”
]
},
“web-site2”: {
“hosts”: [
“bary783c.mylabserver.com”,
“bary784c.mylabserver.com”
]
}
}
But when I’m trying now to run any ansible command to call the same file, I’m getting this error.
]$ ansible -i /opt/ansible/static/inventory/inventory.py all -m ping -e “https://github.com/adeyeri88/test.git staging.yml”
[WARNING]: * Failed to parse /opt/ansible/static/inventory/inventory.py with script plugin: Inventory script (/opt/ansible/static/inventory/inventory.py) had an execution error: usage: inventory.py [-h] [–sshkey SSHKEY] [–commit
COMMIT] url inventory inventory.py: error: too few arguments
[WARNING]: Unable to parse /opt/ansible/static/inventory/inventory.py 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’
Please can you help me here?