Skip to content

Add select_sites custom filter#1611

Merged
swalkinshaw merged 1 commit intomasterfrom
add-select_sites-filter
Oct 14, 2025
Merged

Add select_sites custom filter#1611
swalkinshaw merged 1 commit intomasterfrom
add-select_sites-filter

Conversation

@swalkinshaw
Copy link
Member

Simplifies complex Jinja templating logic which is brittle and breaks across Ansible versions.

This is a common enough pattern I think a custom filter makes sense. There is another alternative to avoid the for loops but it's quite complex:

{{ wordpress_sites | dict2items | selectattr('value.env', 'defined') | selectattr('value.env.db_host',
  'defined') | selectattr('value.env.db_host', 'ne', 'localhost') | map(attribute='key') | list }}

Simplifies complex Jinja templating logic which is brittle and breaks
across Ansible versions.
@swalkinshaw swalkinshaw force-pushed the add-select_sites-filter branch from 7f507c3 to 1678538 Compare October 14, 2025 03:04
@swalkinshaw swalkinshaw merged commit a644a42 into master Oct 14, 2025
2 checks passed
@swalkinshaw swalkinshaw deleted the add-select_sites-filter branch October 14, 2025 03:26
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.

1 participant