Skip to content

Commit cc2189d

Browse files
committed
[FIX] bugs fixed
1 parent 9bf732b commit cc2189d

File tree

4 files changed

+287
-1
lines changed

4 files changed

+287
-1
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
- name: Configure Elasticsearch
3+
hosts: all
4+
become: true
5+
vars_files:
6+
- vars.yml
7+
tasks:
8+
- name: Template elasticsearch.yml configuration
9+
template:
10+
src: templates/elasticsearch.yml.j2
11+
dest: /etc/elasticsearch/elasticsearch.yml
12+
owner: elasticsearch
13+
group: elasticsearch
14+
mode: '0644'
15+
16+
- name: Restart Elasticsearch service
17+
service:
18+
name: elasticsearch
19+
state: restarted
20+
enabled: true
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
cat /etc/elasticsearch/elasticsearch.yml
2+
# ======================== Elasticsearch Configuration =========================
3+
#
4+
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
5+
# Before you set out to tweak and tune the configuration, make sure you
6+
# understand what are you trying to accomplish and the consequences.
7+
#
8+
# The primary way of configuring a node is via this file. This template lists
9+
# the most important settings you may want to configure for a production cluster.
10+
#
11+
# Please consult the documentation for further information on configuration options:
12+
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
13+
#
14+
# ---------------------------------- Cluster -----------------------------------
15+
#
16+
# Use a descriptive name for your cluster:
17+
#
18+
#cluster.name: my-application
19+
#
20+
# ------------------------------------ Node ------------------------------------
21+
#
22+
# Use a descriptive name for the node:
23+
#
24+
#node.name: node-1
25+
#
26+
# Add custom attributes to the node:
27+
#
28+
#node.attr.rack: r1
29+
#
30+
# ----------------------------------- Paths ------------------------------------
31+
#
32+
# Path to directory where to store the data (separate multiple locations by comma):
33+
#
34+
path.data: /var/lib/elasticsearch
35+
#
36+
# Path to log files:
37+
#
38+
path.logs: /var/log/elasticsearch
39+
#
40+
# ----------------------------------- Memory -----------------------------------
41+
#
42+
# Lock the memory on startup:
43+
#
44+
#bootstrap.memory_lock: true
45+
#
46+
# Make sure that the heap size is set to about half the memory available
47+
# on the system and that the owner of the process is allowed to use this
48+
# limit.
49+
#
50+
# Elasticsearch performs poorly when the system is swapping the memory.
51+
#
52+
# ---------------------------------- Network -----------------------------------
53+
#
54+
# By default Elasticsearch is only accessible on localhost. Set a different
55+
# address here to expose this node on the network:
56+
#
57+
#network.host: 192.168.0.1
58+
#
59+
# By default Elasticsearch listens for HTTP traffic on the first free port it
60+
# finds starting at 9200. Set a specific HTTP port here:
61+
#
62+
#http.port: 9200
63+
#
64+
# For more information, consult the network module documentation.
65+
#
66+
# --------------------------------- Discovery ----------------------------------
67+
#
68+
# Pass an initial list of hosts to perform discovery when this node is started:
69+
# The default list of hosts is ["127.0.0.1", "[::1]"]
70+
#
71+
#discovery.seed_hosts: ["host1", "host2"]
72+
#
73+
# Bootstrap the cluster using an initial set of master-eligible nodes:
74+
#
75+
#cluster.initial_master_nodes: ["node-1", "node-2"]
76+
#
77+
# For more information, consult the discovery and cluster formation module documentation.
78+
#
79+
# ---------------------------------- Various -----------------------------------
80+
#
81+
# Allow wildcard deletion of indices:
82+
#
83+
#action.destructive_requires_name: false
84+
85+
#----------------------- BEGIN SECURITY AUTO CONFIGURATION -----------------------
86+
#
87+
# The following settings, TLS certificates, and keys have been automatically
88+
# generated to configure Elasticsearch security features on 25-11-2024 16:33:59
89+
#
90+
# --------------------------------------------------------------------------------
91+
92+
# Enable security features
93+
xpack.security.enabled: true
94+
95+
xpack.security.enrollment.enabled: true
96+
97+
# Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents
98+
xpack.security.http.ssl:
99+
enabled: true
100+
keystore.path: certs/http.p12
101+
102+
# Enable encryption and mutual authentication between cluster nodes
103+
xpack.security.transport.ssl:
104+
enabled: true
105+
verification_mode: certificate
106+
keystore.path: certs/transport.p12
107+
truststore.path: certs/transport.p12
108+
# Create a new cluster with the current node only
109+
# Additional nodes can still join the cluster later
110+
cluster.initial_master_nodes: ["rockylinux"]
111+
112+
# Allow HTTP API connections from anywhere
113+
# Connections are encrypted and require user authentication
114+
http.host: 0.0.0.0
115+
116+
# Allow other nodes to join the cluster from anywhere
117+
# Connections are encrypted and mutually authenticated
118+
#transport.host: 0.0.0.0
119+
120+
#----------------------- END SECURITY AUTO CONFIGURATION -------------------------
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# ======================== Elasticsearch Configuration =========================
2+
#
3+
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
4+
# Before you set out to tweak and tune the configuration, make sure you
5+
# understand what are you trying to accomplish and the consequences.
6+
#
7+
# The primary way of configuring a node is via this file. This template lists
8+
# the most important settings you may want to configure for a production cluster.
9+
#
10+
# Please consult the documentation for further information on configuration options:
11+
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
12+
#
13+
# ---------------------------------- Cluster -----------------------------------
14+
#
15+
# Use a descriptive name for your cluster:
16+
#
17+
cluster.name: {{ cluster_name }}
18+
#
19+
# ------------------------------------ Node ------------------------------------
20+
#
21+
# Use a descriptive name for the node:
22+
#
23+
node.name: {{ node_name }}
24+
#
25+
# Add custom attributes to the node:
26+
#
27+
node.attr.rack: {{ node_attr_rack }}
28+
#
29+
# ----------------------------------- Paths ------------------------------------
30+
#
31+
# Path to directory where to store the data (separate multiple locations by comma):
32+
#
33+
path.data: {{ path_data }}
34+
#
35+
# Path to log files:
36+
#
37+
path.logs: {{ path_logs }}
38+
#
39+
# ----------------------------------- Memory -----------------------------------
40+
#
41+
# Lock the memory on startup:
42+
#
43+
#bootstrap.memory_lock: true
44+
#
45+
# Make sure that the heap size is set to about half the memory available
46+
# on the system and that the owner of the process is allowed to use this
47+
# limit.
48+
#
49+
# Elasticsearch performs poorly when the system is swapping the memory.
50+
#
51+
# ---------------------------------- Network -----------------------------------
52+
#
53+
# By default Elasticsearch is only accessible on localhost. Set a different
54+
# address here to expose this node on the network:
55+
#
56+
network.host: {{ network_host }}
57+
#
58+
# By default Elasticsearch listens for HTTP traffic on the first free port it
59+
# finds starting at 9200. Set a specific HTTP port here:
60+
#
61+
http.port: {{ http_port }}
62+
#
63+
# For more information, consult the network module documentation.
64+
#
65+
# --------------------------------- Discovery ----------------------------------
66+
#
67+
# Pass an initial list of hosts to perform discovery when this node is started:
68+
# The default list of hosts is ["127.0.0.1", "[::1]"]
69+
#
70+
#discovery.seed_hosts: ["host1", "host2"]
71+
#
72+
#discovery.seed_hosts: {{ discovery_seed_hosts | to_json }}
73+
#
74+
# Bootstrap the cluster using an initial set of master-eligible nodes:
75+
#
76+
#cluster.initial_master_nodes: ["node-1", "node-2"]
77+
#
78+
# For more information, consult the discovery and cluster formation module documentation.
79+
#
80+
# ---------------------------------- Various -----------------------------------
81+
#
82+
# Allow wildcard deletion of indices:
83+
#
84+
#action.destructive_requires_name: false
85+
86+
#----------------------- BEGIN SECURITY AUTO CONFIGURATION -----------------------
87+
#
88+
# The following settings, TLS certificates, and keys have been automatically
89+
# generated to configure Elasticsearch security features on 25-11-2024 16:33:59
90+
#
91+
# --------------------------------------------------------------------------------
92+
93+
# Enable security features
94+
xpack.security.enabled: {{ xpack_security_enabled }}
95+
96+
xpack.security.enrollment.enabled: {{ xpack_security_enrollment_enabled }}
97+
98+
# Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents
99+
xpack.security.http.ssl:
100+
enabled: {{ xpack_security_http_ssl_enabled }}
101+
keystore.path: {{ xpack_security_http_ssl_keystore_path }}
102+
103+
# Enable encryption and mutual authentication between cluster nodes
104+
xpack.security.transport.ssl:
105+
enabled: {{ xpack_security_transport_ssl_enabled }}
106+
verification_mode: {{ xpack_security_transport_ssl_verification_mode }}
107+
keystore.path: {{ xpack_security_transport_ssl_keystore_path }}
108+
truststore.path: {{ xpack_security_transport_ssl_truststore_path }}
109+
# Create a new cluster with the current node only
110+
# Additional nodes can still join the cluster later
111+
cluster.initial_master_nodes: ["{{ inventory_hostname }}"]
112+
113+
# Allow HTTP API connections from anywhere
114+
# Connections are encrypted and require user authentication
115+
http.host: {{ http_host }}
116+
117+
# Allow other nodes to join the cluster from anywhere
118+
# Connections are encrypted and mutually authenticated
119+
#transport.host: 0.0.0.0
120+
121+
#----------------------- END SECURITY AUTO CONFIGURATION -------------------------

Ansible/elasticsearch/vars.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,29 @@
22
elastic_version: "8" # 7 or 8
33
elastic_gpg_key: "https://artifacts.elastic.co/GPG-KEY-elasticsearch"
44
elastic_repo_url_apt: "https://artifacts.elastic.co/packages/{{ elastic_version }}.x/apt"
5-
elastic_repo_url_yum: "https://artifacts.elastic.co/packages/{{ elastic_version }}.x/yum"
5+
elastic_repo_url_yum: "https://artifacts.elastic.co/packages/{{ elastic_version }}.x/yum"
6+
7+
# elasticsearch.yml
8+
9+
cluster_name: my-application
10+
node_name: node-1
11+
node_attr_rack: r1
12+
path_data: /var/lib/elasticsearch
13+
path_logs: /var/log/elasticsearch
14+
network_host: 0.0.0.0
15+
http_port: 9200
16+
discovery_seed_hosts:
17+
- host1
18+
- host2
19+
cluster_initial_master_nodes:
20+
- node-1
21+
- node-2
22+
xpack_security_enabled: true
23+
xpack_security_enrollment_enabled: true
24+
xpack_security_http_ssl_enabled: true
25+
xpack_security_http_ssl_keystore_path: certs/http.p12
26+
xpack_security_transport_ssl_enabled: true
27+
xpack_security_transport_ssl_verification_mode: certificate
28+
xpack_security_transport_ssl_keystore_path: certs/transport.p12
29+
xpack_security_transport_ssl_truststore_path: certs/transport.p12
30+
http_host: 0.0.0.0

0 commit comments

Comments
 (0)