Skip to content

Commit c62fd39

Browse files
committed
feat: support RHEL8/9/10 and Rocky, Debian, Ubuntu
* Major refactor for whole playbook (untested) * Bump ELK version to 9.x
1 parent 1acbc33 commit c62fd39

File tree

19 files changed

+820
-571
lines changed

19 files changed

+820
-571
lines changed

install/roles/apache/tasks/main.yml

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,59 @@
33
# Install/run apache
44
#
55

6-
- name: Install httpd and tools
7-
yum:
8-
name: [httpd, httpd-tools, python-httplib2]
6+
- name: Set OS dependent variables
7+
set_fact:
8+
apache_service: "{{ 'httpd' if ansible_os_family == 'RedHat' else 'apache2' }}"
9+
apache_conf_dir: "{{ '/etc/httpd/conf.d' if ansible_os_family == 'RedHat' else '/etc/apache2/sites-enabled' }}"
10+
apache_packages: "{{ ['httpd', 'httpd-tools', 'python3-httplib2'] if ansible_os_family == 'RedHat' else ['apache2', 'apache2-utils', 'python3-httplib2'] }}"
11+
12+
- name: Install Apache and tools
13+
package:
14+
name: "{{ apache_packages }}"
15+
state: present
916
become: true
1017

11-
# SELinux boolean for nginx
18+
# SELinux boolean for httpd
1219
- name: Apply SELinux boolean httpd_can_network_connect
13-
seboolean: name=httpd_can_network_connect state=yes persistent=yes
20+
seboolean:
21+
name: httpd_can_network_connect
22+
state: yes
23+
persistent: yes
1424
become: true
25+
when: ansible_os_family == 'RedHat'
1526

1627
# deploy kibana.conf with FQDN
1728
- name: Setup apache reverse proxy for kibana
1829
template:
19-
src=kibana.conf.j2
20-
dest=/etc/httpd/conf.d/kibana.conf
21-
owner=root
22-
group=root
23-
mode=0644
30+
src: kibana.conf.j2
31+
dest: "{{ apache_conf_dir }}/kibana.conf"
32+
owner: root
33+
group: root
34+
mode: '0644'
2435
become: true
25-
register: httpd_needs_restart
36+
register: kibana_conf
2637

2738
# deploy basic httpd 8080 vhost
2839
- name: Setup httpd TCP/8080 vhost for SSL certificate
2940
template:
30-
src=8080vhost.conf.j2
31-
dest=/etc/httpd/conf.d/8080vhost.conf
32-
owner=root
33-
group=root
34-
mode=0644
41+
src: 8080vhost.conf.j2
42+
dest: "{{ apache_conf_dir }}/8080vhost.conf"
43+
owner: root
44+
group: root
45+
mode: '0644'
3546
become: true
47+
register: vhost_conf
3648

37-
# start httpd service
38-
- name: Start httpd service
39-
command: systemctl restart httpd.service
40-
ignore_errors: true
41-
when: httpd_needs_restart != 0
49+
- name: Ensure Apache is enabled and started
50+
service:
51+
name: "{{ apache_service }}"
52+
state: started
53+
enabled: true
4254
become: true
4355

44-
- name: Set httpd to start on boot
45-
command: systemctl enable httpd.service
46-
ignore_errors: true
56+
- name: Restart Apache if configuration changed
57+
service:
58+
name: "{{ apache_service }}"
59+
state: restarted
4760
become: true
61+
when: kibana_conf.changed or vhost_conf.changed
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
[curator-5]
2-
name=CentOS/RHEL 7 repository for Elasticsearch Curator 5.x packages
3-
baseurl=https://packages.elastic.co/curator/5/centos/7
1+
[curator-9]
2+
name=RHEL/Rocky repository for Elasticsearch Curator 9.x packages
3+
baseurl=https://artifacts.elastic.co/packages/9.x/yum
44
gpgcheck=1
5-
gpgkey=https://packages.elastic.co/GPG-KEY-elasticsearch
5+
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
66
enabled=1

install/roles/curator/tasks/main.yml

Lines changed: 60 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,58 +3,83 @@
33
# install curator tool for managing elasticsearch
44
#
55

6-
- name: Copy curator yum repo file
7-
copy:
8-
src=curator.repo
9-
dest=/etc/yum.repos.d/curator.repo
10-
owner=root
11-
group=root
12-
mode=0644
6+
- name: Setup Curator repository (RedHat/Rocky)
7+
when:
8+
- install_curator_tool
9+
- ansible_os_family == 'RedHat'
1310
become: true
14-
when: install_curator_tool
11+
block:
12+
- name: Copy curator yum repo file
13+
copy:
14+
src: curator.repo
15+
dest: /etc/yum.repos.d/curator.repo
16+
owner: root
17+
group: root
18+
mode: '0644'
1519

16-
- name: Import curator GPG Key
17-
rpm_key: key=http://packages.elastic.co/GPG-KEY-elasticsearch
18-
state=present
19-
when: install_curator_tool
20-
become: true
20+
- name: Import curator GPG Key
21+
rpm_key:
22+
key: http://packages.elastic.co/GPG-KEY-elasticsearch
23+
state: present
2124

22-
- name: Install curator and python-setuptools
23-
yum:
24-
name: elasticsearch-curator
25+
- name: Setup Curator repository (Debian/Ubuntu)
26+
when:
27+
- install_curator_tool
28+
- ansible_os_family == 'Debian'
2529
become: true
30+
block:
31+
- name: Install apt-transport-https
32+
apt:
33+
name: apt-transport-https
34+
state: present
35+
36+
- name: Import curator GPG Key
37+
apt_key:
38+
url: http://packages.elastic.co/GPG-KEY-elasticsearch
39+
state: present
40+
41+
- name: Add Curator repository
42+
apt_repository:
43+
repo: deb http://packages.elastic.co/curator/5/debian stable main
44+
state: present
45+
46+
- name: Install curator
2647
when: install_curator_tool
48+
become: true
49+
package:
50+
name: elasticsearch-curator
51+
state: present
2752

2853
- name: Setup curator config
29-
template:
30-
src=curator-config.yml.j2
31-
dest=/etc/elasticsearch/curator-config.yml
32-
owner=root
33-
group=root
34-
mode=0644
35-
become: true
3654
when: install_curator_tool
55+
become: true
56+
template:
57+
src: curator-config.yml.j2
58+
dest: /etc/elasticsearch/curator-config.yml
59+
owner: root
60+
group: root
61+
mode: '0644'
3762

3863
- name: Setup curator template file
39-
template:
40-
src=curator-action.yml.j2
41-
dest=/etc/elasticsearch/curator-action.yml
42-
owner=root
43-
group=root
44-
mode=0644
45-
become: true
4664
when: install_curator_tool
65+
become: true
66+
template:
67+
src: curator-action.yml.j2
68+
dest: /etc/elasticsearch/curator-action.yml
69+
owner: root
70+
group: root
71+
mode: '0644'
4772

4873
# Runs cron job to cleanup indices every weekday.
4974
# you should adjust this to your needs
5075
- name: Curator Cleanup Cronjob
76+
when: install_curator_tool
77+
become: true
5178
cron:
5279
name: Curator run
53-
weekday: '*'
54-
minute: 0
55-
hour: 12
80+
weekday: "*"
81+
minute: "0"
82+
hour: "12"
5683
user: root
5784
job: "curator --config /etc/elasticsearch/curator-config.yml /etc/elasticsearch/curator-action.yml >> /var/log/curator.log 2>&1"
5885
cron_file: curator-daily-cleanup
59-
when: install_curator_tool
60-
become: true

install/roles/elasticsearch/files/elasticsearch.repo

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
[elasticsearch-6.x]
2-
name=Elasticsearch repository for 6.x packages
3-
baseurl=https://artifacts.elastic.co/packages/6.x/yum
1+
[elasticsearch-9.x]
2+
name=Elasticsearch repository for 9.x packages
3+
baseurl=https://artifacts.elastic.co/packages/9.x/yum
44
gpgcheck=1
55
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
66
enabled=1

0 commit comments

Comments
 (0)