Installing OpenSearch and OpenSearch Dashboards using Ansible
You can use an Ansible playbook to install and configure a production-ready OpenSearch cluster along with OpenSearch Dashboards.
The Ansible playbook deploys OpenSearch and OpenSearch Dashboards to Linux hosts that use systemd. For the operating systems that OpenSearch is tested on, see Compatible operating systems.
Prerequisites
The machine on which you run the playbook (the control node) must have the following installed:
-
Ansible 2.9 or later. If you install only
ansible-coreinstead of the fullansiblepackage, also install the collections that the playbook uses:ansible-galaxy collection install ansible.posix community.general -
Java 8 or later. The playbook uses Java on the control node to generate the TLS certificates for the cluster. If Java is not installed, the playbook fails with a
java: command not founderror.
The control node must have direct SSH access to the root user on each target host.
Configuration
-
Clone the OpenSearch
ansible-playbookrepository and navigate to the repository directory:git clone https://github.com/opensearch-project/ansible-playbook cd ansible-playbookThe
mainbranch installs the latest OpenSearch 3.x version. To install OpenSearch 2.x, check out the2.xbranch. -
Configure the target hosts in the
inventories/opensearch/hostsfile. The default file defines a cluster of five OpenSearch nodes and one OpenSearch Dashboards node. Each line specifies a host name and the following variables:ansible_host: The IP address that Ansible uses to connect to the target host.ansible_user: The user that Ansible uses to connect to the target host.ip: The IP address that OpenSearch and OpenSearch Dashboards bind to. Specify the private IP address of the target host or0.0.0.0.roles: The node roles of the OpenSearch node.
Each host must also be listed in the groups at the end of the file:
os-clusterfor OpenSearch nodes,masterfor cluster manager-eligible nodes, anddashboardsfor the OpenSearch Dashboards node. Hosts that are not listed in a group are not installed. Replace the IP addresses in the default file with the addresses of your hosts.To install OpenSearch and OpenSearch Dashboards on a single host, replace the contents of the file with the following, specifying the IP addresses of your host:
os1 ansible_host=<public-ip-address> ansible_user=root ip=<private-ip-address> roles=data,master [os-cluster] os1 [master] os1 [dashboards] os1For a single host, also set
cluster_typetosingle-nodein theinventories/opensearch/group_vars/all/all.ymlfile:cluster_type: single-node -
You can modify the default configuration values in the
inventories/opensearch/group_vars/all/all.ymlfile. For example, you can increase the Java memory heap size:xms_value: 8 xmx_value: 8
Install OpenSearch and OpenSearch Dashboards using the Ansible playbook
-
From the
ansible-playbookdirectory, run the Ansible playbook:ansible-playbook -i inventories/opensearch/hosts opensearch.yml --extra-vars "admin_password=Test@123 kibanaserver_password=Test@6789 logstash_password=Test@456"You can set the passwords for reserved users (
admin,kibanaserver, andlogstash) using theadmin_password,kibanaserver_password, andlogstash_passwordvariables. -
After the deployment process is complete, you can access OpenSearch and OpenSearch Dashboards with the username
adminand the password that you set for theadmin_passwordvariable.To verify that OpenSearch is running, send a request to the IP address that you specified in the
ipvariable. If you specified a private IP address, send the request from a machine in the same network:curl https://<private-ip-address>:9200 -u 'admin:Test@123' --insecureIf you specified
0.0.0.0, you can send the request tolocalhostfrom the target host or to any IP address of the target host. -
To access OpenSearch Dashboards, go to
http://<ip-address>:5601in your browser. OpenSearch Dashboards can take about 1 minute to start after the playbook finishes.