Skip to content

Commit

Permalink
Multi node Installation (#13)
Browse files Browse the repository at this point in the history
* add multi-node details in hosts

Signed-off-by: saravanan palanisamy <[email protected]>

* add multi-node config

Signed-off-by: saravanan palanisamy <[email protected]>

* fix the issues in config

Signed-off-by: saravanan palanisamy <[email protected]>

* update readme - multi-node

Signed-off-by: saravanan palanisamy <[email protected]>

* update readme

Signed-off-by: saravanan palanisamy <[email protected]>

* clean local tmp directory after installation

Signed-off-by: saravanan palanisamy <[email protected]>
  • Loading branch information
saravanan30erd authored Dec 2, 2021
1 parent 3fa9128 commit 0f70b6c
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 8 deletions.
38 changes: 35 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<img src="https://opensearch.org/assets/brand/SVG/Logo/opensearch_logo_default.svg" height="64px"/>

- [OpenSearch Project Ansible-Playbook](#helm-charts)
- [Single node OpenSearch Installation with Dashboards](single-node-opensearch-installation-with-dashboards)
- [OpenSearch Installation with Dashboards](opensearch-installation-with-dashboards)
- [Contributing](#contributing)
- [Getting Help](#getting-help)
- [Code of Conduct](#code-of-conduct)
Expand All @@ -13,7 +13,7 @@

A community repository for Ansible Playbook of OpenSearch Project.

## Single node OpenSearch Installation with Dashboards
## OpenSearch Installation with Dashboards

This ansible playbook supports the following,

Expand Down Expand Up @@ -44,8 +44,40 @@ In `inventories/opensearch/hosts` file, you can configure the node details.
`ip` is used in OpenSearch and Dashboards configuration.

In AWS EC2,
```
os1 ansible_host=<Elastic/Public IP> address ansible_user=root ip=<Private IP address>
```

os1 ansible_host=<Elastic/Public IP address> ansible_user=root ip=<Private IP address>
#### Multi-node Installation

By default, this playbook will install five nodes opensearch cluster with respective roles (3 master, 5 data and 2 ingest nodes).

```
os1 ansible_host=10.0.1.1 ip=10.0.1.1 roles=data,master
os2 ansible_host=10.0.1.2 ip=10.0.1.2 roles=data,master
os3 ansible_host=10.0.1.3 ip=10.0.1.3 roles=data,master
0s4 ansible_host=10.0.1.4 ip=10.0.1.4 roles=data,ingest
os5 ansible_host=10.0.1.5 ip=10.0.1.5 roles=data,ingest
```

**Note**: You need to add additional nodes details in `inventories/opensearch/hosts` file for creating opensearch cluster with different node sizes.

For example, if you want to create seven nodes cluster with two additional data nodes (`os6` and `os7`) then you need to include the below entries.

```
os6 ansible_host=10.0.1.6 ip=10.0.1.6 roles=data
os7 ansible_host=10.0.1.7 ip=10.0.1.5 roles=data
```

You have to mention the opensearch node [roles](https://opensearch.org/docs/latest/opensearch/cluster/) details in `roles` variable.

#### Single Node Installation

For single node installation, you need to change the `cluster_type` variable in inventory file `inventories/opensearch/group_vars/all/all.yml`

```
cluster_type: single-node
```

### Install

Expand Down
3 changes: 3 additions & 0 deletions inventories/opensearch/group_vars/all/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ os_user: opensearch
# You can change it based on server specs
xms_value: 2
xmx_value: 2

# Cluster type whether its single node or multi-node
cluster_type: multi-node
18 changes: 16 additions & 2 deletions inventories/opensearch/hosts
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
os1 ansible_host=10.0.1.1 ansible_user=root ip=10.0.1.1
os1 ansible_host=10.0.1.1 ansible_user=root ip=10.0.1.1 roles=data,master
os2 ansible_host=10.0.1.2 ansible_user=root ip=10.0.1.2 roles=data,master
os3 ansible_host=10.0.1.3 ansible_user=root ip=10.0.1.3 roles=data,master
os4 ansible_host=10.0.1.4 ansible_user=root ip=10.0.1.4 roles=data,ingest
os5 ansible_host=10.0.1.5 ansible_user=root ip=10.0.1.5 roles=data,ingest

dashboards1 ansible_host=10.0.1.2 ansible_user=root ip=10.0.1.2
dashboards1 ansible_host=10.0.1.6 ansible_user=root ip=10.0.1.6

# List all the nodes in the os cluster
[os-cluster]
os1
os2
os3
os4
os5

# List all the Master eligible nodes under this group
[master]
os1
os2
os3

[dashboards]
dashboards1
15 changes: 15 additions & 0 deletions roles/centos7/opensearch/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
- name: include security plugin for opensearch
include: security.yml

# After the cluster forms successfully for the first time,
# remove the cluster.initial_master_nodes setting from each nodes' configuration.
- name: Remove `cluster.initial_master_nodes` setting from configuration
command: sed -i '/cluster.initial_master_nodes/d' "{{os_conf_dir}}/opensearch.yml"

- name: Make sure opensearch is started
service:
name: opensearch
Expand All @@ -44,3 +49,13 @@
debug:
msg: "{{ os_status.stdout }}"
failed_when: "'number_of_nodes' not in os_status.stdout"

- name: Verify the roles of opensearch cluster nodes
command: curl https://{{ inventory_hostname }}:9200/_cat/nodes?v -u 'admin:{{ admin_password }}' -k
register: os_roles
run_once: true

- name: Show the roles of opensearch cluster nodes
debug:
msg: "{{ os_roles.stdout }}"
run_once: true
6 changes: 3 additions & 3 deletions roles/centos7/opensearch/tasks/opensearch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@

- name: OpenSearch Install | Copy Configuration File
template:
src: opensearch.yml
src: "opensearch-{{ cluster_type }}.yml"
dest: "{{os_conf_dir}}/opensearch.yml"
owner: "{{ os_user }}"
group: "{{ os_user }}"
mode: 0644
mode: 0600
backup: yes

- name: OpenSearch Install | Copy jvm.options File for Instance
Expand All @@ -40,7 +40,7 @@
dest: "{{os_conf_dir}}/jvm.options"
owner: "{{ os_user }}"
group: "{{ os_user }}"
mode: 0644
mode: 0600
force: yes

- name: OpenSearch Install | create systemd service
Expand Down
12 changes: 12 additions & 0 deletions roles/centos7/opensearch/tasks/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@
state: restarted
enabled: yes

- name: Pause for 3 seconds to provide sometime for OpenSearch start
pause:
seconds: 3

- name: Security Plugin configuration | Copy the opensearch security internal users template
template:
src: internal_users.yml
Expand Down Expand Up @@ -142,3 +146,11 @@
JAVA_HOME: "{{ os_home }}/jdk"
run_once: true
when: configuration.changed

- name: Security Plugin configuration | Cleanup local temporary directory
local_action:
module: file
path: /tmp/opensearch-nodecerts
state: absent
run_once: true
when: configuration.changed
15 changes: 15 additions & 0 deletions roles/centos7/opensearch/templates/opensearch-multi-node.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cluster.name: "{{ os_cluster_name }}"

node.name: "{{ inventory_hostname }}"

network.host: "{{ hostvars[inventory_hostname]['ip'] }}"

http.port: 9200

bootstrap.memory_lock: true

discovery.seed_hosts: ["{{ os_nodes }}"]

cluster.initial_master_nodes: ["{{ os_master_nodes }}"]

node.roles: [{{ hostvars[inventory_hostname]['roles'] }}]

0 comments on commit 0f70b6c

Please sign in to comment.