-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ansible initiative #60
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
9f7e44b
initial commit - copy from opendistro
saravanan30erd 865c1f3
check cert for single noe
saravanan30erd cbb337d
fix the naming convention
saravanan30erd 339be65
create OS installation tasks
saravanan30erd 1356eb3
create security configuration tasks
saravanan30erd 815f73e
fix the syntax errors
saravanan30erd 80c376b
update readme
saravanan30erd 6e817be
add scripts for dashboards
saravanan30erd bc850a4
fix the errors in dashbaord installation
saravanan30erd 3c9a194
update readme
saravanan30erd 807949c
pass credentials in command
saravanan30erd ff9abe5
fix the naming conventions
saravanan30erd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
Deploy OpenSearch with OpenSearch Dashboards using Ansible | ||
========================================================== | ||
|
||
## Single node OpenSearch Installation with Dashboards | ||
|
||
This ansible playbook supports the following, | ||
|
||
- Can be deployed on baremetal and VMs(AWS EC2) | ||
- Supports most popular **Linux distributions**(Centos7, RHEL7) | ||
- Install and configure the Apache2.0 opensource OpenSearch | ||
- Configure TLS/SSL for OpenSearch transport layer(Nodes to Nodes communication) and REST API layer | ||
- Generate self-signed certificates to configure TLS/SSL for opensearch | ||
- Configure the Internal Users Database with limited users and user-defined passwords | ||
|
||
Prerequisite | ||
------------ | ||
- **Ansible** | ||
- **Java 8** | ||
|
||
Configure | ||
--------- | ||
|
||
Refer the file `inventories/opensearch/group_vars/all/all.yml` to change the default values. | ||
|
||
For example we need to increase the java memory heap size for opensearch, | ||
|
||
xms_value: 8 | ||
xmx_value: 8 | ||
|
||
|
||
Install | ||
------- | ||
|
||
### Ansible | ||
|
||
# Deploy with ansible playbook - run the playbook as root | ||
ansible-playbook -i inventories/opensearch/hosts opensearch.yml --extra-vars "admin_password=Test@123 kibanaserver_password=Test@6789" | ||
|
||
You should set the reserved users(`admin` and `kibanaserver`) password using `admin_password` and `kibanaserver_password` variables. | ||
|
||
It will install and configure the opensearch. Once the deployment completed, you can access the opensearch Dashboards with user `admin` and password which you provided for variable `admin_password`. | ||
|
||
## TBD | ||
- opensearch multi-node cluster setup | ||
- Performance analyzer plugin configuration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
## Common opensearch configuration parameters ## | ||
|
||
os_cluster_name: development-cluster | ||
|
||
# opensearch download | ||
os_download_url: https://artifacts.opensearch.org/releases/bundle/opensearch | ||
|
||
# opensearch version | ||
os_version: "1.0.1" | ||
|
||
# Configure hostnames for opensearch nodes | ||
# It is required to configure SSL | ||
# Example es1.example.com, es2.example.com | ||
domain_name: example.com | ||
|
||
os_user: opensearch | ||
|
||
# Java memory heap values(GB) for opensearch | ||
# You can change it based on server specs | ||
xms_value: 2 | ||
xmx_value: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
os1 ansible_host=10.0.1.1 ansible_user=root ip=10.0.1.1 roles=data,master | ||
|
||
dashboards1 ansible_host=10.0.1.2 ansible_user=root ip=10.0.1.2 | ||
|
||
# List all the nodes in the os cluster | ||
[os-cluster] | ||
os1 | ||
|
||
[dashboards] | ||
dashboards1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
|
||
- name: opensearch installation & configuration | ||
hosts: os-cluster | ||
gather_facts: false | ||
roles: | ||
- { role: centos7/opensearch } | ||
|
||
- name: opensearch dashboards installation & configuration | ||
hosts: dashboards | ||
gather_facts: false | ||
roles: | ||
- { role: centos7/dashboards } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
os_nodes: |- | ||
{% for item in groups['os-cluster'] -%} | ||
{{ hostvars[item]['ip'] }}{% if not loop.last %}","{% endif %} | ||
{%- endfor %} | ||
|
||
populate_inventory_to_hosts_file: true | ||
|
||
os_dashboards_home: /usr/share/opensearch-dashboards | ||
os_conf_dir: /usr/share/opensearch-dashboards/config | ||
os_plugin_bin_path: /usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin | ||
|
||
os_api_port: 9200 | ||
os_nodes_dashboards: |- | ||
{% for item in groups['os-cluster'] -%} | ||
https://{{ hostvars[item]['ip'] }}:{{ os_api_port }}{% if not loop.last %}","{% endif %} | ||
{%- endfor %} | ||
|
||
systemctl_path: /etc/systemd/system |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
- name: restart dashboards | ||
systemd: name=dashboards state=restarted enabled=yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
|
||
- name: Dashboards Install | Download opensearch dashbaord {{ os_version }} | ||
get_url: | ||
url: "{{ os_download_url }}-dashboards/{{ os_version }}/opensearch-dashboards-{{ os_version }}-linux-x64.tar.gz" | ||
dest: "/tmp/opensearch-dashboards.tar.gz" | ||
register: download | ||
|
||
- name: Dashboards Install | Create opensearch user | ||
user: | ||
name: "{{ os_user }}" | ||
state: present | ||
shell: /bin/bash | ||
when: download.changed | ||
|
||
- name: Dashboards Install | Create home directory | ||
file: | ||
path: "{{ os_dashboards_home }}" | ||
state: directory | ||
owner: "{{ os_user }}" | ||
group: "{{ os_user }}" | ||
when: download.changed | ||
|
||
- name: Dashboards Install | Extract the tar file | ||
command: chdir=/tmp/ tar -xvzf opensearch-dashboards.tar.gz -C "{{ os_dashboards_home }}" --strip-components=1 | ||
when: download.changed | ||
|
||
- name: Dashboards Install | Copy Configuration File | ||
template: | ||
src: opensearch_dashboards.yml | ||
dest: "{{os_conf_dir}}/opensearch_dashboards.yml" | ||
owner: "{{ os_user }}" | ||
group: "{{ os_user }}" | ||
mode: 0644 | ||
backup: yes | ||
|
||
- name: Dashboards Install | create systemd service | ||
template: | ||
src: dashboards.service | ||
dest: "{{ systemctl_path }}/dashboards.service" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
- name: Hosts | populate inventory into hosts file | ||
blockinfile: | ||
dest: /etc/hosts | ||
block: |- | ||
{% for item in groups['os-cluster'] %} | ||
{{ hostvars[item]['ip'] }} {{ item }}.{{ domain_name }} {{ item }} | ||
{% endfor %} | ||
state: present | ||
create: yes | ||
backup: yes | ||
marker: "# Ansible inventory hosts {mark}" | ||
when: populate_inventory_to_hosts_file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
|
||
- hostname: | ||
name: "{{ inventory_hostname }}" | ||
|
||
- name: Disable the selinux | ||
selinux: | ||
state: disabled | ||
|
||
- name: Populate the nodes to /etc/hosts | ||
import_tasks: etchosts.yml | ||
|
||
- name: include dashboards installation | ||
include: dashboards.yml | ||
|
||
- name: Make sure opensearch dashboards is started | ||
service: | ||
name: dashboards | ||
state: started | ||
enabled: yes | ||
|
||
- name: Get all the installed dashboards plugins | ||
command: "sudo -u {{ os_user }} {{ os_plugin_bin_path }} list" | ||
register: list_plugins | ||
|
||
- name: Show all the installed dashboards plugins | ||
debug: | ||
msg: "{{ list_plugins.stdout }}" |
48 changes: 48 additions & 0 deletions
48
ansible/roles/centos7/dashboards/templates/dashboards.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
[Unit] | ||
Description=opensearch-dashboards | ||
Wants=network-online.target | ||
After=network-online.target | ||
|
||
[Service] | ||
RuntimeDirectory=opensearch-dashboards | ||
PrivateTmp=true | ||
|
||
WorkingDirectory={{ os_dashboards_home }} | ||
|
||
User=opensearch | ||
Group=opensearch | ||
|
||
ExecStart={{ os_dashboards_home }}/bin/opensearch-dashboards -q | ||
|
||
StandardOutput=journal | ||
StandardError=inherit | ||
|
||
# Specifies the maximum file descriptor number that can be opened by this process | ||
LimitNOFILE=65535 | ||
|
||
# Specifies the maximum number of processes | ||
LimitNPROC=4096 | ||
|
||
# Specifies the maximum size of virtual memory | ||
LimitAS=infinity | ||
|
||
# Specifies the maximum file size | ||
LimitFSIZE=infinity | ||
|
||
# Disable timeout logic and wait until process is stopped | ||
TimeoutStopSec=0 | ||
|
||
# SIGTERM signal is used to stop the Java process | ||
KillSignal=SIGTERM | ||
|
||
# Send the signal only to the JVM rather than its control group | ||
KillMode=process | ||
|
||
# Java process is never killed | ||
SendSIGKILL=no | ||
|
||
# When a JVM receives a SIGTERM signal it exits with code 143 | ||
SuccessExitStatus=143 | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
13 changes: 13 additions & 0 deletions
13
ansible/roles/centos7/dashboards/templates/opensearch_dashboards.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
server.port: 5601 | ||
server.host: "{{ hostvars[inventory_hostname]['ip'] }}" | ||
opensearch.hosts: ["{{ os_nodes_dashboards }}"] | ||
opensearch.ssl.verificationMode: none | ||
opensearch.username: "kibanaserver" | ||
opensearch.password: "{{ kibanaserver_password }}" | ||
opensearch.requestHeadersWhitelist: [ authorization,securitytenant ] | ||
|
||
opensearch_security.multitenancy.enabled: true | ||
opensearch_security.multitenancy.tenants.preferred: ["Private", "Global"] | ||
opensearch_security.readonly_mode.roles: ["kibana_read_only"] | ||
# Use this setting if you are running dashboards without https | ||
opensearch_security.cookie.secure: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
# vars file for opensearch | ||
java: "{{ es_java | default('java-1.8.0-openjdk.x86_64') }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
|
||
os_nodes: |- | ||
{% for item in groups['os-cluster'] -%} | ||
{{ item }}{% if not loop.last %}","{% endif %} | ||
{%- endfor %} | ||
|
||
os_master_nodes: |- | ||
{% for item in groups['master'] -%} | ||
{{ item }}{% if not loop.last %}","{% endif %} | ||
{%- endfor %} | ||
|
||
populate_inventory_to_hosts_file: true | ||
|
||
os_home: /usr/share/opensearch | ||
os_conf_dir: /usr/share/opensearch/config | ||
os_plugin_bin_path: /usr/share/opensearch/bin/opensearch-plugin | ||
os_sec_plugin_conf_path: /usr/share/opensearch/plugins/opensearch-security/securityconfig | ||
os_sec_plugin_tools_path: /usr/share/opensearch/plugins/opensearch-security/tools | ||
os_api_port: 9200 | ||
|
||
systemctl_path: /etc/systemd/system |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
# handlers file for opensearch | ||
- name: reload systemd configuration | ||
become: yes | ||
command: systemctl daemon-reload | ||
|
||
# Restart service and ensure it is enabled | ||
|
||
- name: restart opensearch | ||
systemd: name=opensearch state=restarted enabled=yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
- name: Hosts | populate inventory into hosts file | ||
blockinfile: | ||
dest: /etc/hosts | ||
block: |- | ||
{% for item in groups['os-cluster'] %} | ||
{{ hostvars[item]['ip'] }} {{ item }}.{{ domain_name }} {{ item }} | ||
{% endfor %} | ||
state: present | ||
create: yes | ||
backup: yes | ||
marker: "# Ansible inventory hosts {mark}" | ||
when: populate_inventory_to_hosts_file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
|
||
- hostname: | ||
name: "{{ inventory_hostname }}" | ||
|
||
- name: Disable the selinux | ||
selinux: | ||
state: disabled | ||
|
||
- name: Populate the nodes to /etc/hosts | ||
import_tasks: etchosts.yml | ||
|
||
- name: include opensearch installation | ||
include: opensearch.yml | ||
|
||
- name: include security plugin for opensearch | ||
include: security.yml | ||
|
||
- name: Make sure opensearch is started | ||
service: | ||
name: opensearch | ||
state: started | ||
enabled: yes | ||
|
||
- name: Get all the installed ES plugins | ||
command: "{{ os_plugin_bin_path }} list" | ||
register: list_plugins | ||
|
||
- name: Show all the installed ES plugins | ||
debug: | ||
msg: "{{ list_plugins.stdout }}" | ||
|
||
- name: Wait for opensearch to startup | ||
wait_for: host={{ hostvars[inventory_hostname]['ip'] }} port={{os_api_port}} delay=5 connect_timeout=1 | ||
|
||
- name: Check the opensearch status | ||
command: curl https://{{ inventory_hostname }}:9200/_cluster/health?pretty -u 'admin:{{ admin_password }}' -k | ||
register: os_status | ||
|
||
- name: Show the opensearch status | ||
debug: | ||
msg: "{{ os_status.stdout }}" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use a different name here , maybe
dashboardserver
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TheAlgo
kibanaserver
is the name used in default configuration file from Opensearch dashboards source file(Tar file). Refer: https://opensearch.org/docs/dashboards/install/tls/I suggest we should follow the default configuration from installation source to avoid confusions. May be it should be changed first in source files and official documentations then we can change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@peterzhuamazon Just curious , why are we using
kibanaserver
till now?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TheAlgo @peterzhuamazon
kibanaserver
is used in security plugin where it should be changed and then configuration. I raised the below PRs to fix this. Once this merged and released, then we can update here.opensearch-project/security#1443
opensearch-project/opensearch-build#458
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are still in discussion with Security Team on this @saravanan30erd please hold on for some time before we make a decision on this.
Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@peterzhuamazon Sure, I think we can continue with
kibanaserver
here as of now.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will keep this for now @TheAlgo.
@saravanan30erd please create an issue to track this.
Thanks.