Skip to content

Commit

Permalink
Enforce repos only with full stack (#314)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
widhalmt authored Feb 9, 2024
1 parent 991c804 commit f3ee73d
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 9 deletions.
26 changes: 24 additions & 2 deletions roles/beats/tasks/auditbeat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,30 @@
string if elasticstack_version is defined else '') |
replace(' ', '')
}}
- name: Install Auditbeat - rpm
- name: Install Auditbeat - rpm - full stack
ansible.builtin.package:
name: "{{ beats_auditbeat_package }}"
enablerepo:
- 'elastic-{{ elasticstack_release }}.x'
when:
- ansible_os_family == "RedHat"
- elasticstack_full_stack | bool

- name: Install Auditbeat - rpm - standalone
ansible.builtin.package:
name: "{{ beats_auditbeat_package }}"
when:
- ansible_os_family == "RedHat"
- not elasticstack_full_stack | bool

- name: Install Auditbeat - deb
ansible.builtin.package:
name: "{{ beats_auditbeat_package }}"
when:
- ansible_os_family == "Debian"

- name: Install Auditbeat latest version - rpm
- name: Install Auditbeat latest version - rpm - full stack
ansible.builtin.package:
name: auditbeat
state: latest
Expand All @@ -36,6 +45,19 @@
- elasticstack_version is defined
- elasticstack_version == "latest"
- ansible_os_family == "RedHat"
- elasticstack_full_stack | bool

- name: Install Auditbeat latest version - rpm - standalone
ansible.builtin.package:
name: auditbeat
state: latest
notify:
- Restart Auditbeat
when:
- elasticstack_version is defined
- elasticstack_version == "latest"
- ansible_os_family == "RedHat"
- not elasticstack_full_stack | bool

- name: Install Auditbeat latest version - deb
ansible.builtin.package:
Expand Down
25 changes: 23 additions & 2 deletions roles/beats/tasks/filebeat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,29 @@
string if elasticstack_version is defined else '') |
replace(' ', '') }}
- name: Install Filebeat - rpm
- name: Install Filebeat - rpm - full stack
ansible.builtin.package:
name: "{{ beats_filebeat_package }}"
enablerepo:
- 'elastic-{{ elasticstack_release }}.x'
when:
- ansible_os_family == "RedHat"
- elasticstack_full_stack | bool

- name: Install Filebeat - rpm - standalone
ansible.builtin.package:
name: "{{ beats_filebeat_package }}"
when:
- ansible_os_family == "RedHat"
- not elasticstack_full_stack | bool

- name: Install Filebeat - deb
ansible.builtin.package:
name: "{{ beats_filebeat_package }}"
when:
- ansible_os_family == "Debian"

- name: Install Filebeat latest version - rpm
- name: Install Filebeat latest version - rpm - full stack
ansible.builtin.package:
name: filebeat
state: latest
Expand All @@ -36,6 +44,19 @@
- elasticstack_version is defined
- elasticstack_version == "latest"
- ansible_os_family == "RedHat"
- elasticstack_full_stack | bool

- name: Install Filebeat latest version - rpm - standalone
ansible.builtin.package:
name: filebeat
state: latest
notify:
- Restart Filebeat
when:
- elasticstack_version is defined
- elasticstack_version == "latest"
- ansible_os_family == "RedHat"
- not elasticstack_full_stack | bool

- name: Install Filebeat latest version - deb
ansible.builtin.package:
Expand Down
26 changes: 24 additions & 2 deletions roles/beats/tasks/metricbeat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,29 @@
replace(' ', '')
}}
- name: Install Metricbeat - rpm
- name: Install Metricbeat - rpm - full stack
ansible.builtin.package:
name: "{{ beats_metricbeat_package }}"
enablerepo:
- 'elastic-{{ elasticstack_release }}.x'
when:
- ansible_os_family == "RedHat"
- elasticstack_full_stack | bool

- name: Install Metricbeat - rpm - standalone
ansible.builtin.package:
name: "{{ beats_metricbeat_package }}"
when:
- ansible_os_family == "RedHat"
- not elasticstack_full_stack | bool

- name: Install Metricbeat - deb
ansible.builtin.package:
name: "{{ beats_metricbeat_package }}"
when:
- ansible_os_family == "Debian"

- name: Install Metricbeat latest version - rpm
- name: Install Metricbeat latest version - rpm - full stack
ansible.builtin.package:
name: metricbeat
state: latest
Expand All @@ -37,6 +45,20 @@
- elasticstack_version is defined
- elasticstack_version == "latest"
- ansible_os_family == "RedHat"
- elasticstack_full_stack | bool

- name: Install Metricbeat latest version - rpm - standalone
ansible.builtin.package:
name: metricbeat
state: latest
notify:
- Restart Metricbeat
when:
- elasticstack_version is defined
- elasticstack_version == "latest"
- ansible_os_family == "RedHat"
- not elasticstack_full_stack | bool


- name: Install Metricbeat latest version - deb
ansible.builtin.package:
Expand Down
10 changes: 9 additions & 1 deletion roles/elasticsearch/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,21 @@
replace(' ', '')
}}
- name: Install Elasticsearch - rpm
- name: Install Elasticsearch - rpm - full stack
ansible.builtin.package:
name: "{{ elasticsearch_package }}"
enablerepo:
- 'elastic-{% if elasticstack_variant == "oss" %}oss-{% endif %}{{ elasticstack_release }}.x'
when:
- ansible_os_family == "RedHat"
- elasticstack_full_stack | bool

- name: Install Elasticsearch - rpm - standalone
ansible.builtin.package:
name: "{{ elasticsearch_package }}"
when:
- ansible_os_family == "RedHat"
- not elasticstack_full_stack | bool

- name: Install Elasticsearch - deb
ansible.builtin.package:
Expand Down
10 changes: 9 additions & 1 deletion roles/kibana/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,21 @@
string if elasticstack_version is defined else '') |
replace(' ', '') }}
- name: Install Kibana - rpm
- name: Install Kibana - rpm - full stack
ansible.builtin.package:
name: "{{ kibana_package }}"
enablerepo:
- 'elastic-{% if elasticstack_variant == "oss" %}oss-{% endif %}{{ elasticstack_release }}.x'
when:
- ansible_os_family == "RedHat"
- elasticstack_full_stack | bool

- name: Install Kibana - rpm - standalone
ansible.builtin.package:
name: "{{ kibana_package }}"
when:
- ansible_os_family == "RedHat"
- not elasticstack_full_stack | bool

- name: Install Kibana - deb
ansible.builtin.package:
Expand Down
10 changes: 9 additions & 1 deletion roles/logstash/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,21 @@
replace(' ', '')
}}
- name: Install Logstash - rpm
- name: Install Logstash - rpm - full stack
ansible.builtin.package:
name: "{{ logstash_package }}"
enablerepo:
- 'elastic-{% if elasticstack_variant == "oss" %}oss-{% endif %}{{ elasticstack_release }}.x'
when:
- ansible_os_family == "RedHat"
- elasticstack_full_stack | bool

- name: Install Logstash - rpm - standalone
ansible.builtin.package:
name: "{{ logstash_package }}"
when:
- ansible_os_family == "RedHat"
- not elasticstack_full_stack | bool

- name: Install Logstash - deb
ansible.builtin.package:
Expand Down

0 comments on commit f3ee73d

Please sign in to comment.