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

content_views role: multiple filter rules #1628

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions roles/content_views/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ This role also allows you to create Content View Filters and add them to the Con

Additionally you can pass any other parameters accepted by the `content_view_filter` module.

Optionally, set multiple rules by passing a list of dicts in the `rules` field.
Each rule must have a `name`, and optionally any parameters accepted by the `content_view_filter_rule` module.

Example Playbooks
-----------------

Expand Down Expand Up @@ -67,4 +70,13 @@ Example Playbooks
latest: true
- content_view: BearApp
latest: true
filters:
- name: "exclude packages from all repositories"
filter_type: "rpm"
inclusion: false
repositories: []
rule_state: absent
rules:
- name: bad-package
- name: worse-package
```
31 changes: 4 additions & 27 deletions roles/content_views/tasks/_create_content_view.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,8 @@
repositories: "{{ content_view.repositories | default(omit) }}"
solve_dependencies: "{{ content_view.solve_dependencies | default(omit) }}"

- name: Add content view filters
theforeman.foreman.content_view_filter:
username: "{{ foreman_username | default(omit) }}"
password: "{{ foreman_password | default(omit) }}"
server_url: "{{ foreman_server_url | default(omit) }}"
validate_certs: "{{ foreman_validate_certs | default(omit) }}"
organization: "{{ foreman_organization }}"
name: "{{ item.name }}"
content_view: "{{ content_view.name }}"
repositories: "{{ item.repositories | default(omit) }}"
filter_type: "{{ item.filter_type }}"
start_date: "{{ item.start_date | default(omit) }}"
end_date: "{{ item.end_date | default(omit) }}"
types: "{{ item.types | default(omit) }}"
date_type: "{{ item.date_type | default(omit) }}"
inclusion: "{{ item.inclusion | default(omit) }}"
errata_id: "{{ item.errata_id | default(omit) }}"
max_version: "{{ item.max_version | default(omit) }}"
min_version: "{{ item.min_version | default(omit) }}"
rule_name: "{{ item.rule_name | default(omit) }}"
version: "{{ item.version | default(omit) }}"
description: "{{ item.description | default(omit) }}"
architecture: "{{ item.architecture | default(omit) }}"
filter_state: "{{ item.filter_state | default(omit) }}"
original_packages: "{{ item.original_packages | default(omit) }}"
original_module_streams: "{{ item.original_module_streams | default(omit) }}"
rule_state: "{{ item.rule_state | default(omit) }}"
- name: Create content view filters
ansible.builtin.include_tasks: '_create_content_view_filter.yml'
loop: "{{ content_view.filters | default([]) }}"
loop_control:
loop_var: content_view_filter
52 changes: 52 additions & 0 deletions roles/content_views/tasks/_create_content_view_filter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
- name: Add content view filters
theforeman.foreman.content_view_filter:
username: "{{ foreman_username | default(omit) }}"
password: "{{ foreman_password | default(omit) }}"
server_url: "{{ foreman_server_url | default(omit) }}"
validate_certs: "{{ foreman_validate_certs | default(omit) }}"
organization: "{{ foreman_organization }}"
name: "{{ content_view_filter.name }}"
content_view: "{{ content_view.name }}"
repositories: "{{ content_view_filter.repositories | default(omit) }}"
filter_type: "{{ content_view_filter.filter_type }}"
start_date: "{{ content_view_filter.start_date | default(omit) }}"
end_date: "{{ content_view_filter.end_date | default(omit) }}"
types: "{{ content_view_filter.types | default(omit) }}"
date_type: "{{ content_view_filter.date_type | default(omit) }}"
inclusion: "{{ content_view_filter.inclusion | default(omit) }}"
errata_id: "{{ content_view_filter.errata_id | default(omit) }}"
max_version: "{{ content_view_filter.max_version | default(omit) }}"
min_version: "{{ content_view_filter.min_version | default(omit) }}"
rule_name: "{{ content_view_filter.rule_name | default(omit) }}"
version: "{{ content_view_filter.version | default(omit) }}"
description: "{{ content_view_filter.description | default(omit) }}"
architecture: "{{ content_view_filter.architecture | default(omit) }}"
filter_state: "{{ content_view_filter.filter_state | default(omit) }}"
original_packages: "{{ content_view_filter.original_packages | default(omit) }}"
original_module_streams: "{{ content_view_filter.original_module_streams | default(omit) }}"
rule_state: "{{ content_view_filter.rule_state | default(omit) }}"

- name: Add content view filter rules
theforeman.foreman.content_view_filter_rule:
username: "{{ foreman_username | default(omit) }}"
password: "{{ foreman_password | default(omit) }}"
server_url: "{{ foreman_server_url | default(omit) }}"
validate_certs: "{{ foreman_validate_certs | default(omit) }}"
organization: "{{ foreman_organization }}"
content_view: "{{ content_view.name }}"
content_view_filter: "{{ content_view_filter.name }}"
context: "{{ content_view_filter_rule.context | default(omit) }}"
date_type: "{{ content_view_filter_rule.date_type | default(omit) }}"
end_date: "{{ content_view_filter_rule.end_date | default(omit) }}"
errata_id: "{{ content_view_filter_rule.errata_id | default(omit) }}"
max_version: "{{ content_view_filter_rule.max_version | default(omit) }}"
min_version: "{{ content_view_filter_rule.min_version | default(omit) }}"
name: "{{ content_view_filter_rule.name | default(omit) }}"
start_date: "{{ content_view_filter_rule.start_date | default(omit) }}"
stream: "{{ content_view_filter_rule.stream | default(omit) }}"
types: "{{ content_view_filter_rule.types | default(omit) }}"
version: "{{ content_view_filter_rule.version | default(omit) }}"
loop: "{{ content_view_filter.rules | default([]) }}"
loop_control:
loop_var: content_view_filter_rule