This Ansible role has the following features:
- Install elasticsearch
- This role requires java to be installed. Oracle-java role can be used but open-jdk is also an option.
- Version of the ansible for installation: 2.9
- Supported OS:
- EL
- 6
- 7
- Ubuntu
- 16.04
- 18.04
- Debian
- 9
- EL
No problems in role with active SELinux were encountered. In a case of any issues you should disable SELinux Temporarily or Permanently.
es_configAll Elasticsearch configuration parameters are supported. This is achieved using a configuration map parameteres_configwhich is serialized into the elasticsearch.yml file. The use of a map ensures the Ansible playbook does not need to be updated to reflect new/deprecated/plugin configuration parameters.elastic_branchIs used to select main Elasticsearch branch to be installed (6.x or 7.x current stable versions). By default this variable is set to6. So, 6.x version is installed by default. You can override this by setting this variable in playbook.es_versionUsed to define full Elasticsearch version (e.g. 6.6.0). Depends onelastic_branchby default. Default value is6.xelasticsearch_hostSpecifies the address to which the elasticsearch server will bind. The default islocalhost,which usually means remote machines will not be able to connect. To allow connections from remote users, set this parameter to a non-loopback address.elasticsearch_portPort on which elasticsearch listen to incoming requests. Default value is9200.elasticsearch_xmxSpecifies the maximum memory allocation pool for a JVM. Default value512m.elasticsearch_xmsSpecifies the initial memory allocation pool for a JVM. Default value512m.es_jvm_custom_parametersCustom JVM parameters can be added as a list. These values will be added to jvm.options configuration file.elasticsearch_scripts_installInstalls custom scripts to work with indices. Default tofalse.elasticsearch_scripts_pathPath to custom scripts directory. Default is/opt/es_scripts.elasticsearch_set_settingsDefine if custom settings should be deployed or default setting is used. Default totrue.es_restart_on_changeConfigure service restart on configuration upgrade. Default is set totrue.es_start_serviceStart service after install. Default totrue.m_lock_enabledConfigure memory lock. Default tofalse.es_homePath to elasticsearch home directory. Default to/usr/share/elasticsearch.es_pid_dirPath to elasticsearch pid directory. Default to/var/run/elasticsearch.es_log_dirPath to elasticsearch log directory. Default to/var/log/elasticsearch.es_conf_dirPath to elasticsearch configuration directory. Default to/etc/elasticsearch.es_data_dirsPath to elasticsearch data directory. Default to/var/lib/elasticsearch.es_basenameBase name of the service. Used in service configuration files. Default toelasticsearch.es_max_open_filesMaximum number of open files, defaults to65535.es_max_map_countMaximum number of memory map areas a process may have. Default set to262144.es_apt_urlPath to official Elastic APT repository. Default todeb https://artifacts.elastic.co/packages/{{ es_repo_name }}/apt stable maines_yum_urlPath to official Elastic RPM repository. Default tohttps://artifacts.elastic.co/packages/{{ es_repo_name }}/yumes_repo_fileConfigure repo header. Default toelastic-{{ es_major_version }}elastic_gpg_keyGPG-key from elasticsearch repository. Default value ishttps://artifacts.elastic.co/GPG-KEY-elasticsearch.es_use_oss_versionInstalls open source software version (contains only features that are available under the Apache 2.0 license). Default tofalse
-
es_major_versionUsed to define Elasticsearch major version. Depends onelastic_branchby default. Default value is6.x -
es_userThe user to run as, defaults toelasticsearch -
es_groupThe group to run as, defaults toelasticsearch -
es_package_nameSpecifies the package name during installation. There is an option to choose open source version. Default to{{ es_use_oss_version | ternary("elasticsearch-oss", "elasticsearch") }} -
es_repo_nameSpecifies Elasticsearch version during adding repository. There is an option to choose open source version. Default to{{ es_use_oss_version | ternary("oss-" + es_major_version, es_major_version) }} -
es_default_file_redhatPath to elasticsearch defaults file on RedHat. Default to/etc/sysconfig/elasticsearch. -
es_default_file_debianPath to elasticsearch defaults file on Debian. Default to/etc/default/elasticsearch.
Java role is presumed as dependency: https://galaxy.ansible.com/lean_delivery/java
- name: Install Elasticsearch 7.x
hosts: localhost
roles:
- role: lean_delivery.java
- role: lean_delivery.elasticsearch
vars:
elastic_branch: 7Playbook structure:
.
├── elastic_cluster_inventory
├── group_vars
│ ├── all.yml
│ ├── controller.yml
│ └── dm.yml
└── elastic_cluster.ymlelastic_cluster_inventory:
[controller]
node1
[dm]
node2
node3
node4
[cluster:children]
controller
dmgroup_vars/controller.yml:
kibana_host: '{{ ansible_host }}'
es_config:
node.name: '{{ ansible_host }}'
cluster.name: my_cluster
network.host: [_local_,_site_]
node.master: false
node.data: false
node.ingest: false
discovery.zen.minimum_master_nodes: 2
discovery.zen.ping.unicast.hosts: '{{ cluster_list }}'group_vars/dm.yml:
es_config:
node.name: '{{ ansible_host }}'
cluster.name: my_cluster
network.host: [_local_,_site_]
node.master: true
node.data: true
discovery.zen.minimum_master_nodes: 2
discovery.zen.ping.unicast.hosts: '{{ cluster_list }}'elastic_cluster.yml:
- name: Install elasticsearch and configure cluster
hosts: all
vars:
cluster_list: "{{ groups['cluster'] | map ('extract', hostvars, ['ansible_hostname']) | join (',') }}"
roles:
- role: lean_delivery.java
- role: lean_delivery.elasticsearch
- name: Install kibana on controller node
hosts: controller
roles:
- role: lean_delivery.kibanaApache
authors:
- Lean Delivery [email protected]