Link Search Menu Expand Document Documentation Menu

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-core instead of the full ansible package, 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 found error.

The control node must have direct SSH access to the root user on each target host.

Configuration

  1. Clone the OpenSearch ansible-playbook repository and navigate to the repository directory:

    git clone https://github.com/opensearch-project/ansible-playbook
    cd ansible-playbook
    

    The main branch installs the latest OpenSearch 3.x version. To install OpenSearch 2.x, check out the 2.x branch.

  2. Configure the target hosts in the inventories/opensearch/hosts file. 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 or 0.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-cluster for OpenSearch nodes, master for cluster manager-eligible nodes, and dashboards for 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]
    os1
    

    For a single host, also set cluster_type to single-node in the inventories/opensearch/group_vars/all/all.yml file:

    cluster_type: single-node
    

  3. You can modify the default configuration values in the inventories/opensearch/group_vars/all/all.yml file. 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

  1. From the ansible-playbook directory, 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, and logstash) using the admin_password, kibanaserver_password, and logstash_password variables.

  2. After the deployment process is complete, you can access OpenSearch and OpenSearch Dashboards with the username admin and the password that you set for the admin_password variable.

    To verify that OpenSearch is running, send a request to the IP address that you specified in the ip variable. 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' --insecure
    

    If you specified 0.0.0.0, you can send the request to localhost from the target host or to any IP address of the target host.

  3. To access OpenSearch Dashboards, go to http://<ip-address>:5601 in your browser. OpenSearch Dashboards can take about 1 minute to start after the playbook finishes.

350 characters left

Have a question? .

Want to contribute? or .