diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d612399..9bed4e0 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,19 @@ Quay Container Registry Collection Release Notes .. contents:: Topics +v2.1.0 +====== + +Release Summary +--------------- + +Adding the ``repo_image_expiry`` event to the ``herve4m.quay.quay_notification`` module. + +Minor Changes +------------- + +- herve4m.quay.quay_notification - New ``repo_image_expiry`` event and new ``image_expiry_days`` parameter (Quay 3.12) + v2.0.0 ====== diff --git a/README.md b/README.md index a47c22d..4765563 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ The collection provides modules for managing your Quay Container Registry deploy ## Included Content -The modules have been tested against versions 3.9, 3.10, and 3.11 of Quay Container Registry. +The modules have been tested against versions 3.10, 3.11, and 3.12 of Quay Container Registry. ### Modules Name | Description diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 52266b7..ca90b46 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -234,3 +234,13 @@ releases: fragments: - PR1-v2.0.0-summary.yaml release_date: '2024-07-26' + 2.1.0: + changes: + minor_changes: + - herve4m.quay.quay_notification - New ``repo_image_expiry`` event and new ``image_expiry_days`` + parameter (Quay 3.12) + release_summary: Adding the ``repo_image_expiry`` event to the ``herve4m.quay.quay_notification`` + module. + fragments: + - PR2-v2.1.0-summary.yml + release_date: '2024-07-29' diff --git a/docs/index.rst b/docs/index.rst index 20f149d..5cf8ccd 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -9,7 +9,7 @@ Infra.Quay_Configuration ======================== -Collection version 2.0.0 +Collection version 2.1.0 .. contents:: :local: diff --git a/docs/quay_api_token_module.rst b/docs/quay_api_token_module.rst index 199c774..b2a908a 100644 --- a/docs/quay_api_token_module.rst +++ b/docs/quay_api_token_module.rst @@ -23,7 +23,7 @@ infra.quay_configuration.quay_api_token module -- Create OAuth access tokens for .. Collection note .. note:: - This module is part of the `infra.quay_configuration collection `_ (version 2.0.0). + This module is part of the `infra.quay_configuration collection `_ (version 2.1.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -206,6 +206,7 @@ Notes .. note:: - Supports \ :literal:`check\_mode`\ . - The generated OAuth access token acts on behalf of the user account you use with the module (in \ :emphasis:`quay\_username`\ ). + - The user must have admin rights to the application's organization, by being the creator of this organization, or by belonging to a team with admin rights. - The module is not idempotent. Every time you run it, an additional OAuth access token is produced. The other OAuth access tokens stay valid. - You cannot delete OAuth access tokens. @@ -224,8 +225,9 @@ Examples infra.quay_configuration.quay_api_token: quay_username: lvasquez quay_password: vs9mrD55NP - # The OAuth application must exist. See the following example that shows - # how to create an organization and an application. + # The OAuth application must exist, and the user must have admin rights + # to the organization that hosts the application. See the following example + # that shows how to create an organization, a team, and an application. client_id: PZ6F80R1LCVPGYNZGSZQ rights: - org:admin @@ -238,9 +240,11 @@ Examples msg: "The OAuth access token is: {{ token_details['access_token'] }}" # The following example creates an organization, an OAuth application, a user - # account, and then generates an OAuth access token for that user account. + # account, and a team, and then generates an OAuth access token for this user + # account. + # The team grants organization admin rights to the user. # The OAuth access token of an existing super user is required to create the - # organization, the application, and the user account. + # organization, the application, the user account, and the team. - name: Ensure the organization exists infra.quay_configuration.quay_organization: name: production @@ -249,7 +253,7 @@ Examples quay_host: https://quay.example.com quay_token: vgfH9zH5q6eV16Con7SvDQYSr0KPYQimMHVehZv7 - - name: Ensure the application extapp exists + - name: Ensure the extapp application exists infra.quay_configuration.quay_application: organization: production name: extapp @@ -267,6 +271,17 @@ Examples quay_host: https://quay.example.com quay_token: vgfH9zH5q6eV16Con7SvDQYSr0KPYQimMHVehZv7 + - name: Ensure the operators team exists in the production organization + infra.quay_configuration.quay_team: + name: operators + organization: production + role: admin + members: + - jziglar + state: present + quay_host: https://quay.example.com + quay_token: vgfH9zH5q6eV16Con7SvDQYSr0KPYQimMHVehZv7 + - name: Generate an OAuth access token for the user infra.quay_configuration.quay_api_token: quay_username: jziglar diff --git a/docs/quay_application_module.rst b/docs/quay_application_module.rst index 7fd1162..451633e 100644 --- a/docs/quay_application_module.rst +++ b/docs/quay_application_module.rst @@ -23,7 +23,7 @@ infra.quay_configuration.quay_application module -- Manage Quay Container Regist .. Collection note .. note:: - This module is part of the `infra.quay_configuration collection `_ (version 2.0.0). + This module is part of the `infra.quay_configuration collection `_ (version 2.1.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/quay_default_perm_module.rst b/docs/quay_default_perm_module.rst index 6ae43ef..42f036c 100644 --- a/docs/quay_default_perm_module.rst +++ b/docs/quay_default_perm_module.rst @@ -23,7 +23,7 @@ infra.quay_configuration.quay_default_perm module -- Manage Quay Container Regis .. Collection note .. note:: - This module is part of the `infra.quay_configuration collection `_ (version 2.0.0). + This module is part of the `infra.quay_configuration collection `_ (version 2.1.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/quay_docker_config_filter.rst b/docs/quay_docker_config_filter.rst index 30371d3..652dc8f 100644 --- a/docs/quay_docker_config_filter.rst +++ b/docs/quay_docker_config_filter.rst @@ -23,7 +23,7 @@ infra.quay_configuration.quay_docker_config filter -- Build a Docker configurati .. Collection note .. note:: - This filter plugin is part of the `infra.quay_configuration collection `_ (version 2.0.0). + This filter plugin is part of the `infra.quay_configuration collection `_ (version 2.1.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/quay_docker_token_module.rst b/docs/quay_docker_token_module.rst index cad6e4e..91c3cb3 100644 --- a/docs/quay_docker_token_module.rst +++ b/docs/quay_docker_token_module.rst @@ -23,7 +23,7 @@ infra.quay_configuration.quay_docker_token module -- Manage tokens for accessing .. Collection note .. note:: - This module is part of the `infra.quay_configuration collection `_ (version 2.0.0). + This module is part of the `infra.quay_configuration collection `_ (version 2.1.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/quay_first_user_module.rst b/docs/quay_first_user_module.rst index e2cd969..2a141dd 100644 --- a/docs/quay_first_user_module.rst +++ b/docs/quay_first_user_module.rst @@ -23,7 +23,7 @@ infra.quay_configuration.quay_first_user module -- Create the first user account .. Collection note .. note:: - This module is part of the `infra.quay_configuration collection `_ (version 2.0.0). + This module is part of the `infra.quay_configuration collection `_ (version 2.1.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/quay_layer_info_module.rst b/docs/quay_layer_info_module.rst index b1cd528..9e9c776 100644 --- a/docs/quay_layer_info_module.rst +++ b/docs/quay_layer_info_module.rst @@ -23,7 +23,7 @@ infra.quay_configuration.quay_layer_info module -- Gather information about imag .. Collection note .. note:: - This module is part of the `infra.quay_configuration collection `_ (version 2.0.0). + This module is part of the `infra.quay_configuration collection `_ (version 2.1.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/quay_manifest_label_info_module.rst b/docs/quay_manifest_label_info_module.rst index aee642a..cf8228d 100644 --- a/docs/quay_manifest_label_info_module.rst +++ b/docs/quay_manifest_label_info_module.rst @@ -23,7 +23,7 @@ infra.quay_configuration.quay_manifest_label_info module -- Gather information a .. Collection note .. note:: - This module is part of the `infra.quay_configuration collection `_ (version 2.0.0). + This module is part of the `infra.quay_configuration collection `_ (version 2.1.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/quay_manifest_label_module.rst b/docs/quay_manifest_label_module.rst index a3469ce..1bf9ee9 100644 --- a/docs/quay_manifest_label_module.rst +++ b/docs/quay_manifest_label_module.rst @@ -23,7 +23,7 @@ infra.quay_configuration.quay_manifest_label module -- Manage Quay Container Reg .. Collection note .. note:: - This module is part of the `infra.quay_configuration collection `_ (version 2.0.0). + This module is part of the `infra.quay_configuration collection `_ (version 2.1.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/quay_message_module.rst b/docs/quay_message_module.rst index 0b86f35..ed2dd8b 100644 --- a/docs/quay_message_module.rst +++ b/docs/quay_message_module.rst @@ -23,7 +23,7 @@ infra.quay_configuration.quay_message module -- Manage Quay Container Registry g .. Collection note .. note:: - This module is part of the `infra.quay_configuration collection `_ (version 2.0.0). + This module is part of the `infra.quay_configuration collection `_ (version 2.1.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/quay_notification_module.rst b/docs/quay_notification_module.rst index d5a746c..c551e12 100644 --- a/docs/quay_notification_module.rst +++ b/docs/quay_notification_module.rst @@ -23,7 +23,7 @@ infra.quay_configuration.quay_notification module -- Manage Quay Container Regis .. Collection note .. note:: - This module is part of the `infra.quay_configuration collection `_ (version 2.0.0). + This module is part of the `infra.quay_configuration collection `_ (version 2.1.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -230,11 +230,27 @@ Parameters
  • "repo_mirror_sync_started"

  • "repo_mirror_sync_success"

  • "repo_mirror_sync_failed"

  • +
  • "repo_image_expiry"

  • +
    +
    +

    image_expiry_days

    + +

    + integer +

    +
    +
    +

    Only used when event is repo_image_expiry.

    +

    The notification is triggered when the image expires in the specified number of days.

    +

    Default: 7

    +
    + +

    method

    @@ -258,7 +274,7 @@ Parameters
    - +

    quay_host

    @@ -274,7 +290,7 @@ Parameters

    Default: "http://127.0.0.1"

    - +

    quay_password

    @@ -290,7 +306,7 @@ Parameters

    Mutually exclusive with quay_token.

    - +

    quay_token

    @@ -305,7 +321,7 @@ Parameters

    Mutually exclusive with quay_username and quay_password.

    - +

    quay_username

    @@ -321,7 +337,7 @@ Parameters

    Mutually exclusive with quay_token.

    - +
    @@ -341,7 +357,7 @@ Parameters

    Mutually exclusive with search_string.

    - +

    repository

    @@ -356,7 +372,7 @@ Parameters

    If you omit the namespace part in the name, then the module looks for the repository in your personal namespace.

    - +

    reset_failcount

    @@ -375,7 +391,7 @@ Parameters
    - +

    search_string

    @@ -391,7 +407,7 @@ Parameters

    Mutually exclusive with regexp.

    - +

    state

    @@ -413,7 +429,7 @@ Parameters
    - +

    test

    @@ -432,7 +448,7 @@ Parameters
    - +

    title

    @@ -445,7 +461,7 @@ Parameters

    Notification title.

    - +
    @@ -468,7 +484,7 @@ Parameters
    - +

    vulnerability_level

    @@ -507,6 +523,8 @@ Notes .. note:: - Supports \ :literal:`check\_mode`\ . + - Your Quay administrator must enable the image garbage collection capability of your Quay installation (\ :literal:`FEATURE\_GARBAGE\_COLLECTION`\ in \ :literal:`config.yaml`\ ) to use the \ :literal:`repo\_image\_expiry`\ event. + - Using the \ :literal:`repo\_image\_expiry`\ event and the \ :emphasis:`image\_expiry\_days`\ parameter requires Quay version 3.12 or later. - The user account associated with the token that you provide in \ :emphasis:`quay\_token`\ must have administrator access to the repository. .. Seealso @@ -549,6 +567,22 @@ Examples quay_host: https://quay.example.com quay_token: vgfH9zH5q6eV16Con7SvDQYSr0KPYQimMHVehZv7 + # You must enable the image garbage collection capability of your Quay + # installation (3.12 or later) to use the repo_image_expiry event. + - name: Ensure notification exists for when an image is going to expire + infra.quay_configuration.quay_notification: + repository: production/smallimage + title: Webhook notification 10 days before an image expires + event: repo_image_expiry + image_expiry_days: 10 + method: webhook + config: + url: https://webhook.example.com/webhook/12345 + template: "{{ lookup('file', 'post.json') | string }}" + state: present + quay_host: https://quay.example.com + quay_token: vgfH9zH5q6eV16Con7SvDQYSr0KPYQimMHVehZv7 + - name: Ensure notification of type Slack exists infra.quay_configuration.quay_notification: repository: production/smallimage diff --git a/docs/quay_org_role.rst b/docs/quay_org_role.rst index 322ae2c..edaed40 100644 --- a/docs/quay_org_role.rst +++ b/docs/quay_org_role.rst @@ -22,7 +22,7 @@ infra.quay_configuration.quay_org role -- Create and configure a Quay Container .. Collection note .. note:: - This role is part of the `infra.quay_configuration collection `_ (version 2.0.0). + This role is part of the `infra.quay_configuration collection `_ (version 2.1.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/quay_organization_module.rst b/docs/quay_organization_module.rst index 14175ee..9879173 100644 --- a/docs/quay_organization_module.rst +++ b/docs/quay_organization_module.rst @@ -23,7 +23,7 @@ infra.quay_configuration.quay_organization module -- Manage Quay Container Regis .. Collection note .. note:: - This module is part of the `infra.quay_configuration collection `_ (version 2.0.0). + This module is part of the `infra.quay_configuration collection `_ (version 2.1.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/quay_proxy_cache_module.rst b/docs/quay_proxy_cache_module.rst index 94e818f..f811942 100644 --- a/docs/quay_proxy_cache_module.rst +++ b/docs/quay_proxy_cache_module.rst @@ -23,7 +23,7 @@ infra.quay_configuration.quay_proxy_cache module -- Manage Quay Container Regist .. Collection note .. note:: - This module is part of the `infra.quay_configuration collection `_ (version 2.0.0). + This module is part of the `infra.quay_configuration collection `_ (version 2.1.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/quay_quota_module.rst b/docs/quay_quota_module.rst index b8bc7da..e1ed953 100644 --- a/docs/quay_quota_module.rst +++ b/docs/quay_quota_module.rst @@ -23,7 +23,7 @@ infra.quay_configuration.quay_quota module -- Manage Quay Container Registry org .. Collection note .. note:: - This module is part of the `infra.quay_configuration collection `_ (version 2.0.0). + This module is part of the `infra.quay_configuration collection `_ (version 2.1.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/quay_repository_mirror_module.rst b/docs/quay_repository_mirror_module.rst index fcdb55e..cf8d5a9 100644 --- a/docs/quay_repository_mirror_module.rst +++ b/docs/quay_repository_mirror_module.rst @@ -23,7 +23,7 @@ infra.quay_configuration.quay_repository_mirror module -- Manage Quay Container .. Collection note .. note:: - This module is part of the `infra.quay_configuration collection `_ (version 2.0.0). + This module is part of the `infra.quay_configuration collection `_ (version 2.1.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/quay_repository_module.rst b/docs/quay_repository_module.rst index 4e1e307..2ca9d66 100644 --- a/docs/quay_repository_module.rst +++ b/docs/quay_repository_module.rst @@ -23,7 +23,7 @@ infra.quay_configuration.quay_repository module -- Manage Quay Container Registr .. Collection note .. note:: - This module is part of the `infra.quay_configuration collection `_ (version 2.0.0). + This module is part of the `infra.quay_configuration collection `_ (version 2.1.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/quay_robot_module.rst b/docs/quay_robot_module.rst index 4993f9e..30471aa 100644 --- a/docs/quay_robot_module.rst +++ b/docs/quay_robot_module.rst @@ -23,7 +23,7 @@ infra.quay_configuration.quay_robot module -- Manage Quay Container Registry rob .. Collection note .. note:: - This module is part of the `infra.quay_configuration collection `_ (version 2.0.0). + This module is part of the `infra.quay_configuration collection `_ (version 2.1.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/quay_tag_info_module.rst b/docs/quay_tag_info_module.rst index 1695876..b8ded77 100644 --- a/docs/quay_tag_info_module.rst +++ b/docs/quay_tag_info_module.rst @@ -23,7 +23,7 @@ infra.quay_configuration.quay_tag_info module -- Gather information about tags i .. Collection note .. note:: - This module is part of the `infra.quay_configuration collection `_ (version 2.0.0). + This module is part of the `infra.quay_configuration collection `_ (version 2.1.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/quay_tag_module.rst b/docs/quay_tag_module.rst index 4da86d9..d069154 100644 --- a/docs/quay_tag_module.rst +++ b/docs/quay_tag_module.rst @@ -23,7 +23,7 @@ infra.quay_configuration.quay_tag module -- Manage Quay Container Registry image .. Collection note .. note:: - This module is part of the `infra.quay_configuration collection `_ (version 2.0.0). + This module is part of the `infra.quay_configuration collection `_ (version 2.1.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/quay_team_ldap_module.rst b/docs/quay_team_ldap_module.rst index 33752f1..f8aefb3 100644 --- a/docs/quay_team_ldap_module.rst +++ b/docs/quay_team_ldap_module.rst @@ -23,7 +23,7 @@ infra.quay_configuration.quay_team_ldap module -- Synchronize Quay Container Reg .. Collection note .. note:: - This module is part of the `infra.quay_configuration collection `_ (version 2.0.0). + This module is part of the `infra.quay_configuration collection `_ (version 2.1.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/quay_team_module.rst b/docs/quay_team_module.rst index 2804f8f..1f4af30 100644 --- a/docs/quay_team_module.rst +++ b/docs/quay_team_module.rst @@ -23,7 +23,7 @@ infra.quay_configuration.quay_team module -- Manage Quay Container Registry team .. Collection note .. note:: - This module is part of the `infra.quay_configuration collection `_ (version 2.0.0). + This module is part of the `infra.quay_configuration collection `_ (version 2.1.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/quay_team_oidc_module.rst b/docs/quay_team_oidc_module.rst index a99517f..0928744 100644 --- a/docs/quay_team_oidc_module.rst +++ b/docs/quay_team_oidc_module.rst @@ -23,7 +23,7 @@ infra.quay_configuration.quay_team_oidc module -- Synchronize Quay Container Reg .. Collection note .. note:: - This module is part of the `infra.quay_configuration collection `_ (version 2.0.0). + This module is part of the `infra.quay_configuration collection `_ (version 2.1.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/quay_user_module.rst b/docs/quay_user_module.rst index 9848d86..2d39763 100644 --- a/docs/quay_user_module.rst +++ b/docs/quay_user_module.rst @@ -23,7 +23,7 @@ infra.quay_configuration.quay_user module -- Manage Quay Container Registry user .. Collection note .. note:: - This module is part of the `infra.quay_configuration collection `_ (version 2.0.0). + This module is part of the `infra.quay_configuration collection `_ (version 2.1.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/quay_vulnerability_info_module.rst b/docs/quay_vulnerability_info_module.rst index 84aefb2..81f7600 100644 --- a/docs/quay_vulnerability_info_module.rst +++ b/docs/quay_vulnerability_info_module.rst @@ -23,7 +23,7 @@ infra.quay_configuration.quay_vulnerability_info module -- Gather information ab .. Collection note .. note:: - This module is part of the `infra.quay_configuration collection `_ (version 2.0.0). + This module is part of the `infra.quay_configuration collection `_ (version 2.1.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/galaxy.yml b/galaxy.yml index 6e53cda..07d5bfd 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -1,7 +1,7 @@ --- namespace: infra name: quay_configuration -version: 2.0.0 +version: 2.1.0 readme: README.md authors: - Hervé Quatremain diff --git a/plugins/modules/quay_notification.py b/plugins/modules/quay_notification.py index b855176..d295e04 100644 --- a/plugins/modules/quay_notification.py +++ b/plugins/modules/quay_notification.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright: (c) 2021, 2022, Herve Quatremain +# Copyright: (c) 2021, 2022, 2024 Herve Quatremain # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # For accessing the API documentation from a running system, use the swagger-ui @@ -60,6 +60,7 @@ - repo_mirror_sync_started - repo_mirror_sync_success - repo_mirror_sync_failed + - repo_image_expiry method: description: - Notification method. Each method requires a specific set of options @@ -132,6 +133,13 @@ - low - negligible - unknown + image_expiry_days: + description: + - Only used when I(event) is C(repo_image_expiry). + - The notification is triggered when the image expires in the specified + number of days. + type: int + default: 7 regexp: description: - The regular expression to search in the title of the existing @@ -187,6 +195,11 @@ choices: [absent, present] notes: - Supports C(check_mode). + - Your Quay administrator must enable the image garbage collection capability + of your Quay installation (C(FEATURE_GARBAGE_COLLECTION) in C(config.yaml)) + to use the C(repo_image_expiry) event. + - Using the C(repo_image_expiry) event and the I(image_expiry_days) parameter + requires Quay version 3.12 or later. - The user account associated with the token that you provide in I(quay_token) must have administrator access to the repository. extends_documentation_fragment: @@ -224,6 +237,22 @@ quay_host: https://quay.example.com quay_token: vgfH9zH5q6eV16Con7SvDQYSr0KPYQimMHVehZv7 +# You must enable the image garbage collection capability of your Quay +# installation (3.12 or later) to use the repo_image_expiry event. +- name: Ensure notification exists for when an image is going to expire + infra.quay_configuration.quay_notification: + repository: production/smallimage + title: Webhook notification 10 days before an image expires + event: repo_image_expiry + image_expiry_days: 10 + method: webhook + config: + url: https://webhook.example.com/webhook/12345 + template: "{{ lookup('file', 'post.json') | string }}" + state: present + quay_host: https://quay.example.com + quay_token: vgfH9zH5q6eV16Con7SvDQYSr0KPYQimMHVehZv7 + - name: Ensure notification of type Slack exists infra.quay_configuration.quay_notification: repository: production/smallimage @@ -306,6 +335,7 @@ def main(): "repo_mirror_sync_started", "repo_mirror_sync_success", "repo_mirror_sync_failed", + "repo_image_expiry", ] ), method=dict( @@ -319,6 +349,7 @@ def main(): ] ), vulnerability_level=dict(choices=vulnerability_level_names), + image_expiry_days=dict(type="int", default=7), config=dict( type="dict", options=dict( @@ -386,6 +417,7 @@ def main(): reset_failcount = module.params.get("reset_failcount") state = module.params.get("state") vulnerability_level = module.params.get("vulnerability_level") + image_expiry_days = module.params.get("image_expiry_days") # Extract namespace and repository from the repository parameter my_name = module.who_am_i() @@ -455,6 +487,19 @@ def main(): # }, # "event_config": {}, # "number_of_failures": 0 + # }, + # { + # "uuid": "d5e8976c-0ac1-4792-be9e-58d4261b2cf8", + # "title": "Send notification on push to Slack 2", + # "event": "repo_image_expiry", + # "method": "slack", + # "config": { + # "url": "https://hooks.slack.com/services/AAA/BBB/CCC" + # }, + # "event_config": { + # "days": 10 + # }, + # "number_of_failures": 0 # } # ] # } @@ -531,7 +576,7 @@ def main(): ) # Gather and verify the parameters - new_fields = {"eventConfig": {}, "config": {}} + new_fields = {"eventConfig": {}, "event_config": {}, "config": {}} missing_parameters = [] if title: new_fields["title"] = title @@ -665,9 +710,13 @@ def main(): ) if event == "vulnerability_found" and vulnerability_level is not None: - new_fields["eventConfig"]["level"] = str( + new_fields["eventConfig"]["level"] = new_fields["event_config"]["level"] = str( vulnerability_level_names.index(vulnerability_level) ) + elif event == "repo_image_expiry": + new_fields["eventConfig"]["days"] = new_fields["event_config"]["days"] = int( + image_expiry_days + ) match_notifications.append( module.create( diff --git a/tests/docker-compose.yml b/tests/docker-compose.yml index 75f9c7c..6ebb8c7 100644 --- a/tests/docker-compose.yml +++ b/tests/docker-compose.yml @@ -26,7 +26,7 @@ services: - "8089:8080" quay: - image: quay.io/projectquay/quay:v3.11.0 + image: quay.io/projectquay/quay:v3.12.0 volumes: - "./quay-config:/conf/stack:Z" - "./quay-delay.sh:/quay-registry/conf/init/a-delay.sh:ro" diff --git a/tests/integration/targets/quay_notification/tasks/main.yml b/tests/integration/targets/quay_notification/tasks/main.yml index ddcb25a..84d3e26 100644 --- a/tests/integration/targets/quay_notification/tasks/main.yml +++ b/tests/integration/targets/quay_notification/tasks/main.yml @@ -145,6 +145,34 @@ quay_token: "{{ quay_token }}" validate_certs: false +- name: Ensure a repo_image_expiry notification (10 days) of type Slack exists + infra.quay_configuration.quay_notification: + repository: ansibletestorg/ansibletestrepo + title: Test Slack Notification3 + event: repo_image_expiry + image_expiry_days: 10 + method: slack + config: + url: https://hooks.slack.com/services/XXX/YYY/ZZZ + test: false + state: present + quay_host: "{{ quay_url }}" + quay_token: "{{ quay_token }}" + validate_certs: false + +- name: Ensure a repo_image_expiry notification (default) of type Slack exists + infra.quay_configuration.quay_notification: + repository: ansibletestorg/ansibletestrepo + title: Test Slack Notification4 + event: repo_image_expiry + method: slack + config: + url: https://hooks.slack.com/services/XXX/YYY/ZZZ + state: present + quay_host: "{{ quay_url }}" + quay_token: "{{ quay_token }}" + validate_certs: false + - name: Wait to ensure the tests have failed ansible.builtin.pause: seconds: 15 @@ -157,6 +185,7 @@ state: present quay_host: "{{ quay_url }}" quay_token: "{{ quay_token }}" + validate_certs: false register: result - name: Ensure that the task did not change anything @@ -172,6 +201,7 @@ state: present quay_host: "{{ quay_url }}" quay_token: "{{ quay_token }}" + validate_certs: false - name: Ensure non-existing notification is removed - method (no change) infra.quay_configuration.quay_notification: @@ -181,6 +211,7 @@ state: absent quay_host: "{{ quay_url }}" quay_token: "{{ quay_token }}" + validate_certs: false register: result - name: Ensure that the task did not change anything @@ -196,6 +227,7 @@ state: absent quay_host: "{{ quay_url }}" quay_token: "{{ quay_token }}" + validate_certs: false register: result - name: Ensure that the task did not change anything @@ -211,6 +243,7 @@ state: absent quay_host: "{{ quay_url }}" quay_token: "{{ quay_token }}" + validate_certs: false - name: Ensure the Slack notifications are removed infra.quay_configuration.quay_notification: @@ -219,6 +252,7 @@ state: absent quay_host: "{{ quay_url }}" quay_token: "{{ quay_token }}" + validate_certs: false - name: Ensure the repository is removed infra.quay_configuration.quay_repository: diff --git a/tests/quay-config/config.yaml b/tests/quay-config/config.yaml index c88e231..01789a9 100644 --- a/tests/quay-config/config.yaml +++ b/tests/quay-config/config.yaml @@ -19,11 +19,13 @@ DISTRIBUTED_STORAGE_PREFERENCE: FEATURE_ACI_CONVERSION: false FEATURE_APP_REGISTRY: false FEATURE_BUILD_SUPPORT: false -FEATURE_MAILING: true +FEATURE_MAILING: false FEATURE_PROXY_CACHE: true FEATURE_UI_V2: true FEATURE_UI_V2_REPO_SETTINGS: true FEATURE_AUTO_PRUNE: true +FEATURE_GARBAGE_COLLECTION: true +FEATURE_ASSIGN_OAUTH_TOKEN: true FEATURE_QUOTA_MANAGEMENT: true FEATURE_REPO_MIRROR: true FEATURE_RESTRICTED_V1_PUSH: true