Skip to content

Commit dd93aea

Browse files
committed
[NEW] added Kibana inslattion playbook
1 parent cc2189d commit dd93aea

File tree

8 files changed

+98
-125
lines changed

8 files changed

+98
-125
lines changed

Ansible/elasticsearch/templates/elasticsearch.yml

Lines changed: 0 additions & 120 deletions
This file was deleted.

Ansible/elasticsearch/templates/elasticsearch.yml.j2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,18 @@ http.port: {{ http_port }}
9191
# --------------------------------------------------------------------------------
9292

9393
# Enable security features
94-
xpack.security.enabled: {{ xpack_security_enabled }}
94+
xpack.security.enabled: {{ xpack_security_enabled | lower }}
9595

96-
xpack.security.enrollment.enabled: {{ xpack_security_enrollment_enabled }}
96+
xpack.security.enrollment.enabled: {{ xpack_security_enrollment_enabled | lower }}
9797

9898
# Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents
9999
xpack.security.http.ssl:
100-
enabled: {{ xpack_security_http_ssl_enabled }}
100+
enabled: {{ xpack_security_http_ssl_enabled | lower }}
101101
keystore.path: {{ xpack_security_http_ssl_keystore_path }}
102102

103103
# Enable encryption and mutual authentication between cluster nodes
104104
xpack.security.transport.ssl:
105-
enabled: {{ xpack_security_transport_ssl_enabled }}
105+
enabled: {{ xpack_security_transport_ssl_enabled | lower }}
106106
verification_mode: {{ xpack_security_transport_ssl_verification_mode }}
107107
keystore.path: {{ xpack_security_transport_ssl_keystore_path }}
108108
truststore.path: {{ xpack_security_transport_ssl_truststore_path }}

Ansible/elasticsearch/vars.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ discovery_seed_hosts:
1919
cluster_initial_master_nodes:
2020
- node-1
2121
- node-2
22-
xpack_security_enabled: true
22+
xpack_security_enabled: false
2323
xpack_security_enrollment_enabled: true
2424
xpack_security_http_ssl_enabled: true
2525
xpack_security_http_ssl_keystore_path: certs/http.p12

Ansible/kibana/ansible.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[defaults]
2+
callbacks_enabled = profile_tasks

Ansible/kibana/install.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
- name: Install Kibana dynamically based on OS
3+
hosts: all
4+
become: yes
5+
vars_files:
6+
- vars.yml
7+
8+
tasks:
9+
- name: Install required packages for Debian/Ubuntu
10+
apt:
11+
name: "{{ item }}"
12+
state: present
13+
loop:
14+
- apt-transport-https
15+
- wget
16+
- gnupg
17+
when: ansible_os_family == "Debian"
18+
19+
- name: Download and add Kibana GPG key for Debian/Ubuntu
20+
shell: |
21+
wget -qO - {{ elastic_gpg_key }} | gpg --dearmor -o /usr/share/keyrings/elastic-keyring.gpg
22+
args:
23+
creates: /usr/share/keyrings/elastic-keyring.gpg
24+
when: ansible_os_family == "Debian"
25+
26+
- name: Add Kibana APT repository for Debian/Ubuntu
27+
apt_repository:
28+
repo: "deb [signed-by=/usr/share/keyrings/elastic-keyring.gpg] {{ elastic_repo_url_apt }} stable main"
29+
state: present
30+
when: ansible_os_family == "Debian"
31+
32+
- name: Update APT cache for Debian/Ubuntu
33+
apt:
34+
update_cache: yes
35+
when: ansible_os_family == "Debian"
36+
37+
- name: Install Kibana for Debian/Ubuntu
38+
apt:
39+
name: kibana
40+
state: present
41+
when: ansible_os_family == "Debian"
42+
43+
- name: Import Kibana GPG key for RedHat/CentOS
44+
rpm_key:
45+
state: present
46+
key: "{{ elastic_gpg_key }}"
47+
when: ansible_os_family == "RedHat"
48+
49+
- name: Create Kibana repository file for RedHat/CentOS
50+
template:
51+
src: templates/kibana-yum.j2
52+
dest: /etc/yum.repos.d/kibana.repo
53+
when: ansible_os_family == "RedHat"
54+
55+
- name: Install Kibana for RedHat/CentOS
56+
yum:
57+
name: kibana
58+
state: present
59+
when: ansible_os_family == "RedHat"
60+
61+
- name: Enable and start Kibana service
62+
systemd:
63+
name: kibana
64+
enabled: yes
65+
state: started
66+
67+
- name: Verify Kibana is running
68+
shell: |
69+
systemctl status kibana | grep 'active (running)'
70+
register: kibana_status
71+
changed_when: false
72+
73+
- name: Display Kibana status
74+
debug:
75+
msg: "Kibana is running: {{ kibana_status.stdout }}"

Ansible/kibana/inventory.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[all]
2+
debian ansible_host=142.93.193.106 ansible_user=root
3+
ubuntu ansible_host=143.198.115.57 ansible_user=root
4+
rockylinux ansible_host=178.128.150.243 ansible_user=root
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[kibana-{{ elastic_version }}.x]
2+
name=Kibana repository for {{ elastic_version }}.x packages
3+
baseurl={{ elastic_repo_url_yum }}
4+
gpgcheck=1
5+
gpgkey={{ elastic_gpg_key }}
6+
enabled=1
7+
autorefresh=1
8+
type=rpm-md

Ansible/kibana/vars.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
elastic_version: "8" # 7 or 8
2+
elastic_gpg_key: "https://artifacts.elastic.co/GPG-KEY-elasticsearch"
3+
elastic_repo_url_apt: "https://artifacts.elastic.co/packages/{{ elastic_version }}.x/apt"
4+
elastic_repo_url_yum: "https://artifacts.elastic.co/packages/{{ elastic_version }}.x/yum"

0 commit comments

Comments
 (0)