Debian Codegraph @

ansible_collections/community/sops/roles/install/tasks/github_api.yml

raw
1 ---
2 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
3 # SPDX-License-Identifier: GPL-3.0-or-later
4 # SPDX-FileCopyrightText: 2022, Felix Fontein
5
6 - name: Fetch list of releases from GitHub
7 ansible.builtin.uri:
8 headers:
9 Accept: application/vnd.github+json
10 Authorization: "{{ ('Bearer ' ~ sops_github_token) if sops_github_token is defined and sops_github_token else '' }}"
11 status_code:
12 - 200
13 - 403 # "HTTP Error 403: rate limit exceeded"
14 url: https://api.github.com/repos/getsops/sops/releases
15 register: _community_sops_install_github_releases
16 delegate_to: localhost
17 run_once: true
18
19 - name: In case rate limit was exceeded, inform user
20 ansible.builtin.debug:
21 msg: >-
22 Rate limit exceeded! Make sure to provide a GitHub token
23 as `sops_github_token` to reduce the chance of this error.
24 when: _community_sops_install_github_releases.status == 403
25
26 - name: Determine the latest release
27 ansible.builtin.set_fact:
28 _community_sops_install_effective_sops_version: >-
29 {{
30 (
31 _community_sops_install_github_releases.json
32 | rejectattr("prerelease")
33 | rejectattr("draft")
34 | map(attribute="tag_name")
35 | map("ansible.builtin.regex_replace", "^v", "")
36 | community.sops._latest_version
37 ) if _community_sops_install_github_releases.status == 200 else ''
38 }}