From 604f60b884707ee25282155c1fe5b5f0146a943d Mon Sep 17 00:00:00 2001 From: igramic <36156377+igramic@users.noreply.github.com> Date: Fri, 16 Jul 2021 10:46:40 +0200 Subject: [PATCH] add support for filtering repositories by OS version --- changelogs/fragments/repository.yml | 2 ++ plugins/modules/repository.py | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/repository.yml diff --git a/changelogs/fragments/repository.yml b/changelogs/fragments/repository.yml new file mode 100644 index 0000000000..93799a3b64 --- /dev/null +++ b/changelogs/fragments/repository.yml @@ -0,0 +1,2 @@ +minor_changes: + - repository - add support for filtering repositories by OS version based on API feature apidoc/v2/repositories/create.html diff --git a/plugins/modules/repository.py b/plugins/modules/repository.py index be5708e564..28da14a167 100644 --- a/plugins/modules/repository.py +++ b/plugins/modules/repository.py @@ -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 @@ -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']), @@ -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)))