mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-28 13:21:25 -07:00
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:
parent
fd02ecd290
commit
05246f7db8
3 changed files with 40 additions and 13 deletions
|
@ -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):
|
||||
'''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue