mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 22:00:22 -07:00
Allow parent groups to be variables or literal (#53649)
* Allow parent groups to be variables or literal, requires {{ }} * Check strict before failing on templating errors * Don't add a group if an invalid parent group was provided
This commit is contained in:
parent
90a38670be
commit
87ebc56de6
3 changed files with 75 additions and 0 deletions
|
@ -404,6 +404,13 @@ class Constructable(object):
|
|||
prefix = keyed.get('prefix', '')
|
||||
sep = keyed.get('separator', '_')
|
||||
raw_parent_name = keyed.get('parent_group', None)
|
||||
if raw_parent_name:
|
||||
try:
|
||||
raw_parent_name = self.templar.template(raw_parent_name)
|
||||
except AnsibleError as e:
|
||||
if strict:
|
||||
raise AnsibleParserError("Could not generate parent group %s for group %s: %s" % (raw_parent_name, key, to_native(e)))
|
||||
continue
|
||||
|
||||
new_raw_group_names = []
|
||||
if isinstance(key, string_types):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue