Skip to content

Commit

Permalink
add support for filtering repositories by OS version
Browse files Browse the repository at this point in the history
  • Loading branch information
igramic authored Jul 16, 2021
1 parent 070dc2e commit 604f60b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/repository.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- repository - add support for filtering repositories by OS version based on API feature apidoc/v2/repositories/create.html
15 changes: 14 additions & 1 deletion plugins/modules/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,18 @@
- repositories will be automatically enabled on a registered host subscribed to this product
type: bool
required: false
os_versions:
description:
- Identifies whether the repository should be disabled on a client with a non-matching OS version.
- A maximum of one OS version can be selected.
- Set to C([]) to disable filtering again.
type: list
elements: str
required: false
choices:
- rhel-6
- rhel-7
- rhel-8
extends_documentation_fragment:
- theforeman.foreman.foreman
- theforeman.foreman.foreman.entity_state_with_defaults
Expand Down Expand Up @@ -292,6 +304,7 @@ def main():
ignorable_content=dict(type='list', elements='str'),
ansible_collection_requirements=dict(),
auto_enabled=dict(type='bool'),
os_versions=dict(type='list', elements='str', choices=['rhel-6', 'rhel-7', 'rhel-8']),
),
argument_spec=dict(
state=dict(default='present', choices=['present_with_defaults', 'present', 'absent']),
Expand Down Expand Up @@ -319,7 +332,7 @@ def main():
module.fail_json(msg="({0}) can only be used with content_type 'ansible_collection'".format(",".join(invalid_list)))

if module.foreman_params['content_type'] != 'yum':
invalid_list = [key for key in ['ignorable_content'] if key in module.foreman_params]
invalid_list = [key for key in ['ignorable_content', 'os_versions'] if key in module.foreman_params]
if invalid_list:
module.fail_json(msg="({0}) can only be used with content_type 'yum'".format(",".join(invalid_list)))

Expand Down

0 comments on commit 604f60b

Please sign in to comment.