Skip to content

Commit 67e4c24

Browse files
authored
Fix apt key handling2 (#307)
f/u to #306 Refactored key and sources list for debian based distros. Use current state of the art to include 3party repos. * avoid apt warning `W:https://artifacts.elastic.co/packages/8.x/apt/dists/stable/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details` * prepare for deb822 format: * > Entries MUST be added in the /etc/apt/sources.list.d directory using a shortened repository name * > A sources.list entry SHOULD have the signed-by option set. see: https://wiki.debian.org/DebianRepository/UseThirdParty PS: this time I have run the checks in question (sorry for my carelessness in the other PR): * https://github.com/Rosa-Luxemburgstiftung-Berlin/ansible-collection-elasticstack/actions/runs/7677838360 * https://github.com/Rosa-Luxemburgstiftung-Berlin/ansible-collection-elasticstack/actions/runs/7677869397
1 parent 2da77e0 commit 67e4c24

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

roles/repos/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
# defaults file for elastic-repos
3+
elasticstack_repo_key: https://artifacts.elastic.co/GPG-KEY-elasticsearch
34
elasticstack_release: 8
45
elasticstack_full_stack: true
56
elasticstack_variant: elastic

roles/repos/tasks/debian.yml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,37 @@
66
- gpg-agent
77
state: present
88

9-
- name: Ensure Elastic Stack key is available (Debian)
9+
- name: Ensure Elastic Stack key is removed (Debian legacy format)
1010
ansible.builtin.apt_key:
11-
url: https://artifacts.elastic.co/GPG-KEY-elasticsearch
12-
state: present
11+
url: "{{ elasticstack_repo_key }}"
12+
state: absent
13+
14+
- name: Ensure Elastic Stack key is available (Debian)
15+
ansible.builtin.get_url:
16+
url: "{{ elasticstack_repo_key }}"
17+
dest: /usr/share/keyrings/elasticsearch.asc
18+
mode: "0644"
19+
20+
- name: Ensure Elastic Stack apt repo is absent (Debian legacy format)
21+
ansible.builtin.file:
22+
path: /etc/apt/sources.list.d/artifacts_elastic_co_packages_{{ item }}_x_apt.list
23+
state: absent
24+
with_items:
25+
- "7"
26+
- "oss-7"
27+
- "8"
28+
- "oss-8"
1329

1430
- name: Ensure Elastic Stack apt repository is configured (Debian)
1531
ansible.builtin.apt_repository:
16-
repo: deb https://artifacts.elastic.co/packages/{{ elasticstack_release }}.x/apt stable main
32+
repo: deb [signed-by=/usr/share/keyrings/elasticsearch.asc] https://artifacts.elastic.co/packages/{{ elasticstack_release }}.x/apt stable main
1733
state: present
34+
filename: elasticstack
1835
when: elasticstack_variant == "elastic"
1936

2037
- name: Ensure Elastic Stack OSS apt repository is configured (Debian)
2138
ansible.builtin.apt_repository:
22-
repo: deb https://artifacts.elastic.co/packages/oss-{{ elasticstack_release }}.x/apt stable main
39+
repo: deb [signed-by=/usr/share/keyrings/elasticsearch.asc] https://artifacts.elastic.co/packages/oss-{{ elasticstack_release }}.x/apt stable main
2340
state: present
41+
filename: elasticstack
2442
when: elasticstack_variant == "oss"

roles/repos/tasks/redhat.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
- name: Ensure Elastic repository key is available (RedHat)
3838
ansible.builtin.rpm_key:
39-
key: https://artifacts.elastic.co/GPG-KEY-elasticsearch
39+
key: "{{ elasticstack_repo_key }}"
4040
state: present
4141

4242
- name: Ensure Elastic Stack yum repository is configured (RedHat)
@@ -46,7 +46,7 @@
4646
file: elastic-release
4747
baseurl: https://artifacts.elastic.co/packages/{{ elasticstack_release }}.x/yum
4848
gpgcheck: yes
49-
gpgkey: https://artifacts.elastic.co/GPG-KEY-elasticsearch
49+
gpgkey: "{{ elasticstack_repo_key }}"
5050
enabled: "{{ elasticstack_enable_repos | bool }}"
5151
when: elasticstack_variant == "elastic"
5252

@@ -57,6 +57,6 @@
5757
file: elastic-oss-release
5858
baseurl: https://artifacts.elastic.co/packages/oss-{{ elasticstack_release }}.x/yum
5959
gpgcheck: yes
60-
gpgkey: https://artifacts.elastic.co/GPG-KEY-elasticsearch
60+
gpgkey: "{{ elasticstack_repo_key }}"
6161
enabled: "{{ elasticstack_enable_repos | bool }}"
6262
when: elasticstack_variant == "oss"

0 commit comments

Comments
 (0)