snippetyamlMinor
Custom inventory file failing to parse properly
Viewed 0 times
filefailingproperlyinventoryparsecustom
Problem
I've got the following production inventory file (
Based on what I'm reading online, it looks like it should be correct, and I can't find any syntax errors in the file using a YAML linter. However, when I run
```
$ ansible-playbook -i playbooks/production.yaml --extra-vars target=moriarty.server.com playbooks/create-server.yaml
[WARNING]: log file at /var/log/ansible.log is not writeable and we cannot create it, aborting
[WARNING]: Skipping 'control' as this is not a valid group definition
[WARNING]: * Failed to parse /Users/username/infra/playbooks/production.yaml with auto plugin: no root 'plugin' key found,
'/Users/username/infra/playbooks/production.yaml' is not a valid YAML inventory plugin config file
[WARNING]: * Failed to parse /Users/username/infra/playbooks/production.yaml with yaml plugin: control is not a known host nor group
[WARNING]: * Failed to parse /Users/username/infra/playbooks/production.yaml with ini plugin: Invalid host pattern 'all:' supplied, ending in ':' is not allowed, this
character is reserved to provide a port.
[WARNING]: Unable to parse /Users/username/infra/playbooks/production.yaml 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'
[WARNING]: Could not match supplied host pattern, ignoring: moriarty.server.com
PLAY [moriarty.server.com] ****
skipping: no hosts matched
PLAY RECAP ***
playbooks/production.yaml) for Ansible:all:
children:
control:
moriarty.server.com
toby.server.com
managed:
sherlock.server.com
Based on what I'm reading online, it looks like it should be correct, and I can't find any syntax errors in the file using a YAML linter. However, when I run
ansible-playbook on my local machine, I get the following error:```
$ ansible-playbook -i playbooks/production.yaml --extra-vars target=moriarty.server.com playbooks/create-server.yaml
[WARNING]: log file at /var/log/ansible.log is not writeable and we cannot create it, aborting
[WARNING]: Skipping 'control' as this is not a valid group definition
[WARNING]: * Failed to parse /Users/username/infra/playbooks/production.yaml with auto plugin: no root 'plugin' key found,
'/Users/username/infra/playbooks/production.yaml' is not a valid YAML inventory plugin config file
[WARNING]: * Failed to parse /Users/username/infra/playbooks/production.yaml with yaml plugin: control is not a known host nor group
[WARNING]: * Failed to parse /Users/username/infra/playbooks/production.yaml with ini plugin: Invalid host pattern 'all:' supplied, ending in ':' is not allowed, this
character is reserved to provide a port.
[WARNING]: Unable to parse /Users/username/infra/playbooks/production.yaml 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'
[WARNING]: Could not match supplied host pattern, ignoring: moriarty.server.com
PLAY [moriarty.server.com] ****
skipping: no hosts matched
PLAY RECAP ***
Solution
The keyword
See How to build your inventory.
hosts is missing. Also colons : are needed after the hostnames. Fix the syntax, for exampleall:
children:
control:
hosts:
moriarty.server.com:
toby.server.com:
managed:
hosts:
sherlock.server.com:
See How to build your inventory.
Context
StackExchange DevOps Q#11010, answer score: 5
Revisions (0)
No revisions yet.