Skip to content

Commit 00d3c8e

Browse files
committed
Enforce repos only with full stack
RPM installation automatically enabled the Elastic Stack repositories this collection will add to a host. But if you have another tool to manage your repositories, they might have other ids and names. So I added separate installation tasks. If `elasticstack_full_stack` is set to `true`, everything stays as it was. The task will forcefully enable the repository and then install the package. But if `elasticstack_full_stack` is set to `false` it will just ignore the repository and expect the package to be available. While working on this I found a different approach to choosing the correct version in the `beats` role. I couldn't afford to fix it all in a single PR so I opened #313 for this. fixes #312
1 parent 991c804 commit 00d3c8e

File tree

6 files changed

+98
-9
lines changed

6 files changed

+98
-9
lines changed

roles/beats/tasks/auditbeat.yml

+24-2
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,30 @@
1010
string if elasticstack_version is defined else '') |
1111
replace(' ', '')
1212
}}
13-
- name: Install Auditbeat - rpm
13+
14+
- name: Install Auditbeat - rpm - full stack
1415
ansible.builtin.package:
1516
name: "{{ beats_auditbeat_package }}"
1617
enablerepo:
1718
- 'elastic-{{ elasticstack_release }}.x'
1819
when:
1920
- ansible_os_family == "RedHat"
21+
- elasticstack_full_stack | bool
22+
23+
- name: Install Auditbeat - rpm - standalone
24+
ansible.builtin.package:
25+
name: "{{ beats_auditbeat_package }}"
26+
when:
27+
- ansible_os_family == "RedHat"
28+
- not elasticstack_full_stack | bool
2029

2130
- name: Install Auditbeat - deb
2231
ansible.builtin.package:
2332
name: "{{ beats_auditbeat_package }}"
2433
when:
2534
- ansible_os_family == "Debian"
2635

27-
- name: Install Auditbeat latest version - rpm
36+
- name: Install Auditbeat latest version - rpm - full stack
2837
ansible.builtin.package:
2938
name: auditbeat
3039
state: latest
@@ -36,6 +45,19 @@
3645
- elasticstack_version is defined
3746
- elasticstack_version == "latest"
3847
- ansible_os_family == "RedHat"
48+
- elasticstack_full_stack | bool
49+
50+
- name: Install Auditbeat latest version - rpm - standalone
51+
ansible.builtin.package:
52+
name: auditbeat
53+
state: latest
54+
notify:
55+
- Restart Auditbeat
56+
when:
57+
- elasticstack_version is defined
58+
- elasticstack_version == "latest"
59+
- ansible_os_family == "RedHat"
60+
- not elasticstack_full_stack | bool
3961

4062
- name: Install Auditbeat latest version - deb
4163
ansible.builtin.package:

roles/beats/tasks/filebeat.yml

+23-2
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,29 @@
1010
string if elasticstack_version is defined else '') |
1111
replace(' ', '') }}
1212
13-
- name: Install Filebeat - rpm
13+
- name: Install Filebeat - rpm - full stack
1414
ansible.builtin.package:
1515
name: "{{ beats_filebeat_package }}"
1616
enablerepo:
1717
- 'elastic-{{ elasticstack_release }}.x'
1818
when:
1919
- ansible_os_family == "RedHat"
20+
- elasticstack_full_stack | bool
21+
22+
- name: Install Filebeat - rpm - standalone
23+
ansible.builtin.package:
24+
name: "{{ beats_filebeat_package }}"
25+
when:
26+
- ansible_os_family == "RedHat"
27+
- not elasticstack_full_stack | bool
2028

2129
- name: Install Filebeat - deb
2230
ansible.builtin.package:
2331
name: "{{ beats_filebeat_package }}"
2432
when:
2533
- ansible_os_family == "Debian"
2634

27-
- name: Install Filebeat latest version - rpm
35+
- name: Install Filebeat latest version - rpm - full stack
2836
ansible.builtin.package:
2937
name: filebeat
3038
state: latest
@@ -36,6 +44,19 @@
3644
- elasticstack_version is defined
3745
- elasticstack_version == "latest"
3846
- ansible_os_family == "RedHat"
47+
- elasticstack_full_stack | bool
48+
49+
- name: Install Filebeat latest version - rpm - standalone
50+
ansible.builtin.package:
51+
name: filebeat
52+
state: latest
53+
notify:
54+
- Restart Filebeat
55+
when:
56+
- elasticstack_version is defined
57+
- elasticstack_version == "latest"
58+
- ansible_os_family == "RedHat"
59+
- not elasticstack_full_stack | bool
3960

4061
- name: Install Filebeat latest version - deb
4162
ansible.builtin.package:

roles/beats/tasks/metricbeat.yml

+24-2
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,29 @@
1111
replace(' ', '')
1212
}}
1313
14-
- name: Install Metricbeat - rpm
14+
- name: Install Metricbeat - rpm - full stack
1515
ansible.builtin.package:
1616
name: "{{ beats_metricbeat_package }}"
1717
enablerepo:
1818
- 'elastic-{{ elasticstack_release }}.x'
1919
when:
2020
- ansible_os_family == "RedHat"
21+
- elasticstack_full_stack | bool
22+
23+
- name: Install Metricbeat - rpm - standalone
24+
ansible.builtin.package:
25+
name: "{{ beats_metricbeat_package }}"
26+
when:
27+
- ansible_os_family == "RedHat"
28+
- not elasticstack_full_stack | bool
2129

2230
- name: Install Metricbeat - deb
2331
ansible.builtin.package:
2432
name: "{{ beats_metricbeat_package }}"
2533
when:
2634
- ansible_os_family == "Debian"
2735

28-
- name: Install Metricbeat latest version - rpm
36+
- name: Install Metricbeat latest version - rpm - full stack
2937
ansible.builtin.package:
3038
name: metricbeat
3139
state: latest
@@ -37,6 +45,20 @@
3745
- elasticstack_version is defined
3846
- elasticstack_version == "latest"
3947
- ansible_os_family == "RedHat"
48+
- elasticstack_full_stack | bool
49+
50+
- name: Install Metricbeat latest version - rpm - standalone
51+
ansible.builtin.package:
52+
name: metricbeat
53+
state: latest
54+
notify:
55+
- Restart Metricbeat
56+
when:
57+
- elasticstack_version is defined
58+
- elasticstack_version == "latest"
59+
- ansible_os_family == "RedHat"
60+
- not elasticstack_full_stack | bool
61+
4062

4163
- name: Install Metricbeat latest version - deb
4264
ansible.builtin.package:

roles/elasticsearch/tasks/main.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,21 @@
121121
replace(' ', '')
122122
}}
123123
124-
- name: Install Elasticsearch - rpm
124+
- name: Install Elasticsearch - rpm - full stack
125125
ansible.builtin.package:
126126
name: "{{ elasticsearch_package }}"
127127
enablerepo:
128128
- 'elastic-{% if elasticstack_variant == "oss" %}oss-{% endif %}{{ elasticstack_release }}.x'
129129
when:
130130
- ansible_os_family == "RedHat"
131+
- elasticstack_full_stack | bool
132+
133+
- name: Install Elasticsearch - rpm - standalone
134+
ansible.builtin.package:
135+
name: "{{ elasticsearch_package }}"
136+
when:
137+
- ansible_os_family == "RedHat"
138+
- not elasticstack_full_stack | bool
131139

132140
- name: Install Elasticsearch - deb
133141
ansible.builtin.package:

roles/kibana/tasks/main.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,21 @@
4545
string if elasticstack_version is defined else '') |
4646
replace(' ', '') }}
4747
48-
- name: Install Kibana - rpm
48+
- name: Install Kibana - rpm - full stack
4949
ansible.builtin.package:
5050
name: "{{ kibana_package }}"
5151
enablerepo:
5252
- 'elastic-{% if elasticstack_variant == "oss" %}oss-{% endif %}{{ elasticstack_release }}.x'
5353
when:
5454
- ansible_os_family == "RedHat"
55+
- elasticstack_full_stack | bool
56+
57+
- name: Install Kibana - rpm - standalone
58+
ansible.builtin.package:
59+
name: "{{ kibana_package }}"
60+
when:
61+
- ansible_os_family == "RedHat"
62+
- not elasticstack_full_stack | bool
5563

5664
- name: Install Kibana - deb
5765
ansible.builtin.package:

roles/logstash/tasks/main.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,21 @@
7070
replace(' ', '')
7171
}}
7272
73-
- name: Install Logstash - rpm
73+
- name: Install Logstash - rpm - full stack
7474
ansible.builtin.package:
7575
name: "{{ logstash_package }}"
7676
enablerepo:
7777
- 'elastic-{% if elasticstack_variant == "oss" %}oss-{% endif %}{{ elasticstack_release }}.x'
7878
when:
7979
- ansible_os_family == "RedHat"
80+
- elasticstack_full_stack | bool
81+
82+
- name: Install Logstash - rpm - standalone
83+
ansible.builtin.package:
84+
name: "{{ logstash_package }}"
85+
when:
86+
- ansible_os_family == "RedHat"
87+
- not elasticstack_full_stack | bool
8088

8189
- name: Install Logstash - deb
8290
ansible.builtin.package:

0 commit comments

Comments
 (0)