Skip to content

Commit f515add

Browse files
committed
Ignore hosts that don't actually exists when applying section vars.
1 parent 84c4336 commit f515add

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/ansiblecmdb/parser.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,11 @@ def _apply_section_hosts(self, section, hosts):
248248
"""
249249
for entry in section['entries']:
250250
for hostname in self.expand_hostdef(entry['name']):
251+
if hostname not in hosts:
252+
# Expanded host or child host or something else refers to a
253+
# host that isn't actually defined. Ansible skips this, so
254+
# we will too.
255+
continue
251256
host = hosts[hostname]
252257
for var_key, var_val in entry['hostvars'].items():
253258
host['hostvars'][var_key] = var_val

0 commit comments

Comments
 (0)