Skip to content

Commit 56c5751

Browse files
committed
Centralize package installation in repos role
1 parent 0ccd969 commit 56c5751

File tree

9 files changed

+41
-24
lines changed

9 files changed

+41
-24
lines changed

docs/10-role-repos.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ The role adds Elastic repositories to the package manager. It's main use is in c
88
Requirements
99
------------
1010

11-
* You need `gpg` to be installed because packages / repositories are digitally signed and verified.
12-
* Debian and Ubuntu hosts need to have `apt-transport-https` installed to deal with Elastics repositories.
13-
* Ubuntu hosts also need to have `gpg-agent` installed.
14-
* For SuSE hosts you need the Ansible collection `community.general` on your Ansible controller.
11+
GPG needs to be installed on the systems to verify the package signature. This will be installed as part of the role. Below you can find a list of packages that will be installed.
12+
* Debian family: `apt-transport-https`, `gpg` and `gpg-agent`
13+
* RedHat family: `gnupg`
14+
* Suse family: `gpg2`
15+
16+
For SuSE hosts you will need the Ansible collection `community.general` on your Ansible controller.
1517

1618
Role Variables
1719
--------------

roles/repos/tasks/debian.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
---
2-
- name: Ensure gpg exists, for signing keys
3-
ansible.builtin.apt:
4-
name:
5-
- gpg
6-
- gpg-agent
7-
state: present
8-
92
- name: Ensure Elastic Stack key is removed (Debian legacy format)
103
ansible.builtin.apt_key:
114
url: "{{ elasticstack_repo_key }}"

roles/repos/tasks/main.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,29 @@
55
name: netways.elasticstack.elasticstack
66
when: not hostvars[inventory_hostname]._elasticstack_role_imported | default(false)
77

8+
- name: Include OS specific vars
9+
ansible.builtin.include_vars: "{{ lookup('first_found', params) }}"
10+
vars:
11+
params:
12+
files:
13+
- "{{ ansible_os_family }}-{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
14+
- "{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yml"
15+
- "{{ ansible_os_family }}-{{ ansible_distribution }}.yml"
16+
- "{{ ansible_os_family }}-{{ ansible_lsb.id if ansible_lsb.id is defined else ansible_distribution }}.yml"
17+
- "{{ ansible_os_family }}.yml"
18+
- default.yml
19+
paths:
20+
- "{{ role_path }}/vars"
21+
22+
- name: Install package dependencies
23+
ansible.builtin.package:
24+
name: "{{ item }}"
25+
state: present
26+
loop: "{{ repos_packages }}"
27+
when:
28+
- repos_packages is defined
29+
- repos_packages | length > 0
30+
831
- name: Import RedHat tasks
932
ansible.builtin.import_tasks: redhat.yml
1033
when: ansible_os_family == 'RedHat'

roles/repos/tasks/redhat.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
---
2-
32
# See https://github.com/elastic/elasticsearch/issues/85876
43
# for more information why this is needed
5-
6-
- name: Ensure gpg exists, for signing keys
7-
ansible.builtin.package:
8-
name: gnupg
9-
state: present
10-
114
- name: Workaround for EL > 8
125
when:
136
- ansible_distribution_major_version >= "9"

roles/repos/tasks/suse.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
---
2-
3-
- name: Ensure gpg exists, for signing keys
4-
community.general.zypper:
5-
name: gpg2
6-
state: present
7-
82
- name: Ensure Elastic Stack yum repository is configured (SuSE)
93
community.general.zypper_repository:
104
name: elastic-{{ elasticstack_release }}.x

roles/repos/vars/Debian.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
repos_packages:
3+
- gpg
4+
- gpg-agent
5+
- apt-transport-https

roles/repos/vars/RedHat.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
repos_packages:
3+
- gnupg

roles/repos/vars/Suse.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
repos_packages:
3+
- gpg2

roles/repos/vars/default.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
---

0 commit comments

Comments
 (0)