Reputation: 95
I am trying to create a ansible inventory with the command
ansible inventory --inventory=./module7_task0/ansible/inventory.yml --list
Here is my inventory.yml file
all:
hosts:
ec2-3-139-239-155.us-east-2.compute.amazonaws.com:
children:
webservers:
hosts:
ec2-3-139-239-155.us-east-2.compute.amazonaws.com:
jenkins:
hosts:
ec2-3-139-239-155.us-east-2.compute.amazonaws.com:
production:
hosts:
ec2-3-139-239-155.us-east-2.compute.amazonaws.com:
This is the error that I get when I run the above command
WARNING]: Unable to parse /home/vagrant/validation/module7_task0/inventory.yml as an
inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
{
"_meta": {
"hostvars": {}
},
"all": {
"children": [
"ungrouped"
]
}
}
All the formatting seems correct and I am following the documentation to a T from the ansible site. The yaml format is correct as well. Any insight would be appreciated.
Upvotes: 0
Views: 1349
Reputation: 68034
The inventory file is correct
shell> ansible-inventory -i inventory.yml --list --yaml
all:
children:
jenkins:
hosts:
ec2-3-139-239-155.us-east-2.compute.amazonaws.com: {}
production:
hosts:
ec2-3-139-239-155.us-east-2.compute.amazonaws.com: {}
ungrouped: {}
webservers:
hosts:
ec2-3-139-239-155.us-east-2.compute.amazonaws.com: {}
Double-check the path of the file. Review all group_vars and host_vars if any. Test the YAML syntax
shell> yamllint inventory.yml
inventory.yml
1:1 warning missing document start "---" (document-start)
The warning about missing document-start does not cause the problem.
Upvotes: 1