Skip to content

Conversation

@brad2014
Copy link

📝 Description

The tags, regions, and types filter array values are scanned, and any jinja templates are detected and expanded, just as is done already with the api_token.

Resolves #746

✔️ How to Test

The test case in #746 now works.

The tags, regions, and types filter array values are scanned, and
any jinja templates are detected and expanded, just as is done
already with the api_token.

Resolves linode#746
@brad2014 brad2014 requested a review from a team as a code owner January 19, 2026 19:12
@brad2014 brad2014 requested review from psnoch-akamai and vshanthe and removed request for a team January 19, 2026 19:12
@vshanthe vshanthe requested review from a team, Copilot, ezilber-akamai and yec-akamai and removed request for a team January 22, 2026 08:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enables Jinja template expansion for tags, regions, and types filter arrays in the dynamic inventory plugin, matching the existing template expansion behavior for api_token.

Changes:

  • Added a helper function to expand Jinja templates in query option lists
  • Applied template expansion to regions, types, and tags query options

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +247 to +253
items = []
for item in query_list:
if self.templar.is_template(item):
items.append(self.templar.template(item, disable_lookups=False))
else:
items.append(item)
return items
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expand_templates function can be simplified using a list comprehension to improve readability and reduce boilerplate code.

Suggested change
items = []
for item in query_list:
if self.templar.is_template(item):
items.append(self.templar.template(item, disable_lookups=False))
else:
items.append(item)
return items
return [
self.templar.template(item, disable_lookups=False)
if self.templar.is_template(item)
else item
for item in query_list
]

Copilot uses AI. Check for mistakes.
items = []
for item in query_list:
if self.templar.is_template(item):
items.append(self.templar.template(item, disable_lookups=False))
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting disable_lookups=False explicitly when it may already be the default could be misleading. Verify if this parameter needs to be specified, and if so, add a comment explaining why lookups should be enabled for these templates.

Suggested change
items.append(self.templar.template(item, disable_lookups=False))
items.append(
self.templar.template(
item,
# Intentionally enable lookups so inventory query
# values can use Ansible lookup plugins (for example,
# to pull regions/types/tags from external sources).
disable_lookups=False,
)
)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Allow jinja expressions in filter values in inventory plugin

1 participant