inventory now errors for invalid group/host names (#45499)

* inventory now errors for invalid group/host names

also made yaml inventory slightly smarte

fixes #45493

* add some 'YAML protection' to ini plugin

* better msg

* avoid ranges as positive match

* pepe

* expand inherited instead of total override
This commit is contained in:
Brian Coca 2018-11-15 16:29:40 -05:00 committed by ansibot
parent fd02ecd290
commit 05246f7db8
3 changed files with 40 additions and 13 deletions

View file

@ -315,6 +315,24 @@ class InventoryModule(BaseFileInventoryPlugin):
return hostnames, port, variables
def _expand_hostpattern(self, hostpattern):
'''
do some extra checks over normal processing
'''
# specification?
hostnames, port = super(InventoryModule, self)._expand_hostpattern(hostpattern)
if hostpattern.strip().endswith(':') and port is None:
raise AnsibleParserError("Invalid host pattern '%s' supplied, ending in ':' is not allowed, this character is reserved to provide a port." %
hostpattern)
for pattern in hostnames:
# some YAML parsing prevention checks
if pattern.strip() == '---':
raise AnsibleParserError("Invalid host pattern '%s' supplied, '---' is normally a sign this is a YAML file." % hostpattern)
return (hostnames, port)
@staticmethod
def _parse_value(v):
'''