Skip to content

Commit e91d3a7

Browse files
author
Maurício Linhares
committed
Adding opensearch as an option to 1-clicks
This adds a 1 click recipe that installs opensearch and opensearch dashboards on a single droplet with TLS enabled. The apps use a self signed certificate and the passwords for the admin and kibana user are at `/home/opensearch/admin_password.txt` and `/home/opensearch/kibana_password.txt` files.
1 parent 88e076a commit e91d3a7

File tree

17 files changed

+679
-0
lines changed

17 files changed

+679
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
- hosts: default
3+
become: true
4+
serial: 1
5+
roles:
6+
- role: opensearch
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
opensearch_home: /opt/opensearch
3+
opensearch_config_home: /opt/opensearch/config
4+
opensearch_config_file: /opt/opensearch/config/opensearch.yml
5+
opensearch_url: https://artifacts.opensearch.org/releases/bundle/opensearch/1.3.1/opensearch-1.3.1-linux-x64.tar.gz
6+
7+
opensearch_dashboards_home: /opt/opensearch-dashboards
8+
opensearch_dashboards_config_home: /opt/opensearch-dashboards/config
9+
opensearch_dashboards_config_file: /opt/opensearch-dashboards/config/opensearch_dashboards.yml
10+
opensearch_dashboards_url: https://artifacts.opensearch.org/releases/bundle/opensearch-dashboards/1.3.1/opensearch-dashboards-1.3.1-linux-x64.tar.gz
11+
12+
opensearch_user: opensearch
13+
opensearch_group: opensearch
14+
15+
opensearch_plugin_bin_path: /opt/opensearch/bin/opensearch-plugin
16+
opensearch_security_plugin_conf_path: /opt/opensearch/plugins/opensearch-security/securityconfig
17+
opensearch_security_plugin_tools_path: /opt/opensearch/plugins/opensearch-security/tools
18+
19+
systemctl_path: /etc/systemd/system
20+
21+
nodecerts_home: /opt/opensearch-nodecerts
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
# This is the internal user database
3+
# The hash value is a bcrypt hash and can be generated with plugin/tools/hash.sh
4+
5+
_meta:
6+
type: "internalusers"
7+
config_version: 2
8+
9+
# Define your internal users here
10+
11+
admin:
12+
hash: "{{ datasource "admin_password" }}"
13+
reserved: true
14+
backend_roles:
15+
- "admin"
16+
description: "admin user"
17+
18+
kibanaserver:
19+
hash: "{{ datasource "kibanaserver_password" }}"
20+
reserved: true
21+
description: "kibanaserver user"
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
## JVM configuration
2+
3+
################################################################
4+
## IMPORTANT: JVM heap size
5+
################################################################
6+
##
7+
## You should always set the min and max JVM heap
8+
## size to the same value. For example, to set
9+
## the heap to 4 GB, set:
10+
##
11+
## -Xms4g
12+
## -Xmx4g
13+
##
14+
## See https://opensearch.org/docs/opensearch/install/important-settings/
15+
## for more information
16+
##
17+
################################################################
18+
19+
# Xms represents the initial size of total heap space
20+
# Xmx represents the maximum size of total heap space
21+
22+
-Xms{{datasource "max_memory" }}m
23+
-Xmx{{datasource "max_memory" }}m
24+
25+
################################################################
26+
## Expert settings
27+
################################################################
28+
##
29+
## All settings below this section are considered
30+
## expert settings. Don't tamper with them unless
31+
## you understand what you are doing
32+
##
33+
################################################################
34+
35+
## GC configuration
36+
8-13:-XX:+UseConcMarkSweepGC
37+
8-13:-XX:CMSInitiatingOccupancyFraction=75
38+
8-13:-XX:+UseCMSInitiatingOccupancyOnly
39+
40+
## G1GC Configuration
41+
# NOTE: G1 GC is only supported on JDK version 10 or later
42+
# to use G1GC, uncomment the next two lines and update the version on the
43+
# following three lines to your version of the JDK
44+
# 10-13:-XX:-UseConcMarkSweepGC
45+
# 10-13:-XX:-UseCMSInitiatingOccupancyOnly
46+
14-:-XX:+UseG1GC
47+
14-:-XX:G1ReservePercent=25
48+
14-:-XX:InitiatingHeapOccupancyPercent=30
49+
50+
## JVM temporary directory
51+
-Djava.io.tmpdir=${OPENSEARCH_TMPDIR}
52+
53+
## heap dumps
54+
55+
# generate a heap dump when an allocation from the Java heap fails
56+
# heap dumps are created in the working directory of the JVM
57+
-XX:+HeapDumpOnOutOfMemoryError
58+
59+
# specify an alternative path for heap dumps; ensure the directory exists and
60+
# has sufficient space
61+
-XX:HeapDumpPath=data
62+
63+
# specify an alternative path for JVM fatal error logs
64+
-XX:ErrorFile=logs/hs_err_pid%p.log
65+
66+
## JDK 8 GC logging
67+
8:-XX:+PrintGCDetails
68+
8:-XX:+PrintGCDateStamps
69+
8:-XX:+PrintTenuringDistribution
70+
8:-XX:+PrintGCApplicationStoppedTime
71+
8:-Xloggc:logs/gc.log
72+
8:-XX:+UseGCLogFileRotation
73+
8:-XX:NumberOfGCLogFiles=32
74+
8:-XX:GCLogFileSize=64m
75+
76+
# JDK 9+ GC logging
77+
9-:-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m
78+
79+
# Explicitly allow security manager (https://bugs.openjdk.java.net/browse/JDK-8270380)
80+
18-:-Djava.security.manager=allow
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
cluster.name: {{ datasource "droplet_name" }}
2+
3+
node.name: {{ datasource "droplet_name" }}
4+
5+
network.host: {{ datasource "ip_address" }}
6+
7+
http.port: 9200
8+
9+
discovery.type: single-node
10+
11+
bootstrap.memory_lock: true
12+
13+
plugins.security.allow_default_init_securityindex: true
14+
plugins.security.audit.type: internal_opensearch
15+
plugins.security.enable_snapshot_restore_privilege: true
16+
plugins.security.check_snapshot_restore_write_privileges: true
17+
plugins.security.restapi.roles_enabled: ["all_access", "security_rest_api_access"]
18+
19+
plugins.security.ssl.transport.pemcert_filepath: opensearch.pem
20+
plugins.security.ssl.transport.pemkey_filepath: opensearch.key
21+
plugins.security.ssl.transport.pemtrustedcas_filepath: root-ca.pem
22+
plugins.security.ssl.transport.enforce_hostname_verification: false
23+
plugins.security.ssl.transport.resolve_hostname: false
24+
plugins.security.ssl.http.enabled: true
25+
plugins.security.ssl.http.pemcert_filepath: opensearch_http.pem
26+
plugins.security.ssl.http.pemkey_filepath: opensearch_http.key
27+
plugins.security.ssl.http.pemtrustedcas_filepath: root-ca.pem
28+
plugins.security.nodes_dn:
29+
- CN=opensearch,OU=Ops,O=opensearch\, Inc.,DC=opensearch
30+
plugins.security.authcz.admin_dn:
31+
- CN=admin.opensearch,OU=Ops,O=opensearch\, Inc.,DC=opensearch
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
server.port: 5601
2+
server.host: "{{ datasource "ip_address" }}"
3+
opensearch.hosts: ["https://{{ datasource "ip_address" }}:9200"]
4+
opensearch.ssl.verificationMode: none
5+
opensearch.username: "kibanaserver"
6+
opensearch.password: "{{ datasource "kibanaserver_password" }}"
7+
opensearch.requestHeadersWhitelist: [ authorization,securitytenant ]
8+
9+
opensearch_security.multitenancy.enabled: true
10+
opensearch_security.multitenancy.tenants.preferred: ["Private", "Global"]
11+
opensearch_security.readonly_mode.roles: ["kibana_read_only"]
12+
opensearch_security.cookie.secure: true
13+
14+
server.ssl.enabled: true
15+
server.ssl.certificate: {{ datasource "opensearch_config_home" }}/opensearch_http.pem
16+
server.ssl.key: {{ datasource "opensearch_config_home" }}/opensearch_http.key
17+
18+
opensearch.ssl.certificateAuthorities: [ "{{ datasource "opensearch_config_home" }}/root-ca.pem" ]
19+
20+
opensearch.ssl.certificate: {{ datasource "opensearch_config_home" }}/opensearch.pem
21+
opensearch.ssl.key: {{ datasource "opensearch_config_home" }}/opensearch.key
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
ca:
2+
root:
3+
dn: CN=root.ca.opensearch,OU=CA,O=opensearch\, Inc.,DC=opensearch
4+
keysize: 2048
5+
validityDays: 3650
6+
pkPassword: none
7+
file: root-ca.pem
8+
9+
### Default values and global settings
10+
defaults:
11+
validityDays: 3650
12+
pkPassword: none
13+
# Set this to true in order to generate config and certificates for
14+
# the HTTP interface of nodes
15+
httpsEnabled: true
16+
reuseTransportCertificatesForHttp: false
17+
verifyHostnames: false
18+
resolveHostnames: false
19+
20+
21+
###
22+
### Nodes
23+
###
24+
#
25+
# Specify the nodes of your ES cluster here
26+
#
27+
nodes:
28+
- name: opensearch
29+
dn: CN=opensearch,OU=Ops,O=opensearch\, Inc.,DC=opensearch
30+
dns: opensearch
31+
ip: {{ datasource "ip_address" }}
32+
33+
###
34+
### Clients
35+
###
36+
#
37+
# Specify the clients that shall access your ES cluster with certificate authentication here
38+
#
39+
# At least one client must be an admin user (i.e., a super-user). Admin users can
40+
# be specified with the attribute admin: true
41+
#
42+
clients:
43+
- name: admin
44+
dn: CN=admin.opensearch,OU=Ops,O=opensearch\, Inc.,DC=opensearch
45+
admin: true
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
3+
- name: Download dashboards
4+
get_url:
5+
url: "{{ opensearch_dashboards_url }}"
6+
dest: "/tmp/dashboards.tar.gz"
7+
8+
- name: Unpack dashboards tarball
9+
unarchive:
10+
copy: no
11+
src: "/tmp/dashboards.tar.gz"
12+
dest: "{{ opensearch_dashboards_home }}"
13+
owner: "{{ opensearch_user }}"
14+
group: "{{ opensearch_group }}"
15+
extra_opts:
16+
- --strip-components=1
17+
18+
- name: Dashboards Install | create systemd service
19+
template:
20+
src: opensearch_dashboards.service
21+
dest: "{{ systemctl_path }}/opensearch_dashboards.service"
22+
23+
- name: Add dashboards jvm options template
24+
copy:
25+
src: jvm.options.template
26+
dest: "{{ opensearch_dashboards_config_home }}/jvm.options.template"
27+
owner: "{{ opensearch_user }}"
28+
group: "{{ opensearch_group }}"
29+
30+
- name: Copy template config file
31+
copy:
32+
src: "opensearch_dashboards.yml.template"
33+
dest: "{{ opensearch_dashboards_config_file }}.template"
34+
owner: "{{ opensearch_user }}"
35+
group: "{{ opensearch_group }}"
36+
37+
- name: Remove dashboards config file
38+
file:
39+
path: "{{ opensearch_dashboards_config_file }}"
40+
state: absent
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
3+
- name: setup group
4+
group:
5+
name: "{{ opensearch_group }}"
6+
system: true
7+
state: present
8+
9+
- name: setup user
10+
user:
11+
name: "{{ opensearch_user }}"
12+
group: "{{ opensearch_group }}"
13+
system: true
14+
15+
- name: Set vm.max_map_count in sysctl.conf
16+
sysctl:
17+
name: vm.max_map_count
18+
value: 262144
19+
state: present
20+
21+
- name: Set open files limit in sysctl.conf
22+
sysctl:
23+
name: fs.file-max
24+
value: 65536
25+
state: present
26+
27+
- name: create base directories
28+
file:
29+
path: "{{ item }}"
30+
state: directory
31+
owner: "{{ opensearch_user }}"
32+
group: "{{ opensearch_group }}"
33+
mode: 0744
34+
loop:
35+
- "{{ opensearch_home }}"
36+
- "{{ opensearch_dashboards_home }}"
37+
- "{{ nodecerts_home }}"
38+
39+
- name: Download gomplate
40+
get_url:
41+
url: "https://github.com/hairyhenderson/gomplate/releases/download/v3.10.0/gomplate_linux-amd64"
42+
dest: "/usr/bin/gomplate"
43+
mode: a+x
44+
45+
- name: include opensearch
46+
include: opensearch.yml
47+
48+
- name: include dashboards
49+
include: dashboards.yml
50+
51+
- name: include security
52+
include: security.yml
53+
54+
- name: Add opensearch init script
55+
template:
56+
src: 001_onboot
57+
dest: "/var/lib/cloud/scripts/per-instance/001_onboot"
58+
owner: "{{ opensearch_user }}"
59+
group: "{{ opensearch_group }}"
60+
mode: a+x
61+
62+
- name: Run config script on boot
63+
cron:
64+
name: "configure-opensearch"
65+
special_time: "reboot"
66+
job: "/bin/bash /var/lib/cloud/scripts/per-instance/001_onboot"
67+
user: "{{ opensearch_user }}"
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
3+
- name: Download opensearch
4+
get_url:
5+
url: "{{ opensearch_url }}"
6+
dest: "/tmp/opensearch.tar.gz"
7+
8+
- name: Unpack opensearch tarball
9+
unarchive:
10+
copy: no
11+
src: "/tmp/opensearch.tar.gz"
12+
dest: "{{ opensearch_home }}"
13+
owner: "{{ opensearch_user }}"
14+
group: "{{ opensearch_group }}"
15+
mode: 0700
16+
extra_opts:
17+
- --strip-components=1
18+
19+
- name: Add opensearch config template
20+
copy:
21+
src: opensearch.yml.template
22+
dest: "{{ opensearch_config_file }}.template"
23+
owner: "{{ opensearch_user }}"
24+
group: "{{ opensearch_group }}"
25+
26+
- name: Add opensearch jvm options template
27+
copy:
28+
src: jvm.options.template
29+
dest: "{{ opensearch_config_home }}/jvm.options.template"
30+
owner: "{{ opensearch_user }}"
31+
group: "{{ opensearch_group }}"
32+
33+
- name: Remove opensearch config file
34+
file:
35+
path: "{{ opensearch_config_file }}"
36+
state: absent
37+
38+
- name: OpenSearch Install | create systemd service
39+
template:
40+
src: opensearch.service
41+
dest: "{{ systemctl_path }}/opensearch.service"

0 commit comments

Comments
 (0)