Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add composed groups #111

Merged
merged 3 commits into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion plugins/inventory/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@
type: list
elements: str
default: []
groups:
required: False
description:
- Create groups based on jinja filter.
type: dict
default: {}
validate_certs:
description:
- Whether or not to validate SSL of the Infrahub instance
Expand Down Expand Up @@ -246,7 +252,12 @@ def set_hosts_and_groups(self, host_node_attributes: Dict[str, Any]):

self.set_host_variables(host_node=host_node, attributes=attributes)

self._add_host_to_keyed_groups(self.keyed_groups, attributes, host_node, strict=self.strict)
self._add_host_to_composed_groups(
groups=self.groups, variables=attributes, host=host_node, strict=self.strict
)
self._add_host_to_keyed_groups(
keys=self.keyed_groups, variables=attributes, host=host_node, strict=self.strict
)

def set_host_variables(self, host_node: str, attributes: Dict):
"""
Expand Down Expand Up @@ -317,6 +328,7 @@ def parse(self, inventory, loader, path, cache=True):
self.strict = self.get_option("strict")
self.compose = self.get_option("compose")
self.keyed_groups = self.get_option("keyed_groups")
self.groups = self.get_option("groups")

self._set_authorization()

Expand Down
Loading