Skip to content

Commit

Permalink
Adding a validation to ensure /etc/apt/keyrings path exists
Browse files Browse the repository at this point in the history
  • Loading branch information
falcocer-ibm committed Jan 22, 2025
1 parent 1ffa66d commit 5e03141
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion roles/grafana_agent/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,24 @@
loop: "{{ tcp_listen_violations }}"
failed_when: true

- name: "Ensure that path /etc/apt/keyrings exists"
become: true
ansible.builtin.file:
path: /etc/apt/keyrings
state: directory
mode: '0755'
force: true
when: ansible_pkg_mgr == "apt"
register: keyrings_exists

- name: "Import Grafana GPG key"
become: true
ansible.builtin.get_url:
url: "{{ grafana_apt_repo_key_url }}"
dest: /etc/apt/keyrings/grafana.gpg
mode: '0644'
force: true
when: ansible_pkg_mgr == "apt"
when: ansible_pkg_mgr == "apt" and keyrings_exists is defined

- name: Ensure downloaded file for key is a binary keyring
shell: "cat /etc/apt/keyrings/grafana.gpg | gpg --dearmor | sudo tee /etc/apt/keyrings/grafana.gpg > /dev/null"
Expand Down

0 comments on commit 5e03141

Please sign in to comment.