The elastic role installs and configures Elasticsearch for use with AxonOps Server. AxonOps uses Elasticsearch to store configuration data, user settings, and other operational metadata.
Note: This role is based on the official elastic.elasticsearch Ansible role and supports Elasticsearch versions 6.x, 7.x, and 8.x (with limitations).
- Ansible 2.9 or higher
- Target system running a supported Linux distribution
- Sufficient system resources for Elasticsearch
jmespathlibrary on the Ansible control machine (required for json_query filter)
- Primary Support: 7.x and 6.x
- 8.x Support: Should work with 8.x but with limited testing. See 8x-support documentation
- OSS Distribution: No longer available for versions >= 7.11.0 due to Elasticsearch license changes
| Variable | Default | Description |
|---|---|---|
es_version |
7.17.0 |
Version of Elasticsearch to install |
es_use_repository |
true |
Use official Elastic package repositories |
es_add_repository |
true |
Add Elastic repositories (if not already present) |
oss_version |
false |
Install OSS distribution (only for versions < 7.11.0) |
| Variable | Default | Description |
|---|---|---|
es_config['http.port'] |
9200 |
HTTP port for the node |
es_config['transport.port'] |
9300 |
Transport port for the node |
es_config['network.host'] |
- | Sets both bind and publish host |
es_api_host |
localhost |
Host for HTTP API calls |
es_api_port |
9200 |
Port for HTTP API calls |
| Variable | Default | Description |
|---|---|---|
es_config['cluster.name'] |
- | Name of the Elasticsearch cluster |
es_config['node.name'] |
- | Name of the node |
es_config['discovery.seed_hosts'] |
- | List of master-eligible nodes for discovery |
es_config['cluster.initial_master_nodes'] |
- | Initial master nodes for cluster bootstrap (7.x+) |
| Variable | Default | Description |
|---|---|---|
es_config['node.master'] |
- | Whether this node can be elected as master |
es_config['node.data'] |
- | Whether this node stores data |
| Variable | Default | Description |
|---|---|---|
es_heap_size |
- | JVM heap size (e.g., "1g", "4g") |
es_config['bootstrap.memory_lock'] |
- | Lock process memory to prevent swapping |
| Variable | Default | Description |
|---|---|---|
es_data_dirs |
- | Array of data directory paths |
es_log_dir |
- | Log directory path |
| Variable | Default | Description |
|---|---|---|
es_xpack_trial |
false |
Enable 30-day X-Pack trial |
es_api_basic_auth_username |
- | Admin username for API calls |
es_api_basic_auth_password |
- | Admin password for API calls |
es_xpack_license |
- | X-Pack license JSON content |
| Variable | Default | Description |
|---|---|---|
es_plugins |
- | Array of plugins to install |
es_plugins_reinstall |
false |
Reinstall all plugins |
None (Java installation is handled by the role)
- name: Install Elasticsearch for AxonOps
hosts: axon-server
become: true
vars:
es_version: 7.17.0
roles:
- role: axonops.axonops.elastic- name: Install Elasticsearch with Custom Configuration
hosts: axon-server
become: true
vars:
es_version: 7.17.0
es_heap_size: 2g
es_data_dirs:
- /opt/elasticsearch/data
es_log_dir: /opt/elasticsearch/logs
es_config:
node.name: "axonops-node1"
cluster.name: "axonops-cluster"
network.host: 0.0.0.0
http.port: 9200
bootstrap.memory_lock: true
roles:
- role: axonops.axonops.elastic- name: Deploy AxonOps Server
hosts: axon-server
become: true
vars:
install_cassandra: true
install_elastic: true
java_pkg: java-17-openjdk-headless
# Elasticsearch Configuration
es_version: 7.17.0
es_heap_size: 2g
es_config:
cluster.name: "axonops"
node.name: "{{ ansible_hostname }}"
network.host: 0.0.0.0
http.port: 9200
discovery.type: single-node
# AxonOps Server Configuration
axon_server_elastic_hosts:
- http://127.0.0.1:9200
axon_server_cql_hosts:
- localhost:9042
axon_dash_listen_address: 0.0.0.0
roles:
- role: axonops.axonops.elastic
tags: elastic
when: install_elastic
- role: axonops.axonops.cassandra
tags: cassandra
when: install_cassandra
- role: axonops.axonops.server
tags: server
- role: axonops.axonops.dash
tags: dash- hosts: elastic_master
become: true
roles:
- role: axonops.axonops.elastic
vars:
es_version: 7.17.0
es_heap_size: 4g
es_config:
cluster.name: "axonops-production"
cluster.initial_master_nodes: "master-node-1"
discovery.seed_hosts: "master-node-1:9300"
node.name: "master-node-1"
node.master: true
node.data: false
network.host: 0.0.0.0
http.port: 9200
transport.port: 9300
bootstrap.memory_lock: true
- hosts: elastic_data
become: true
roles:
- role: axonops.axonops.elastic
vars:
es_version: 7.17.0
es_heap_size: 8g
es_data_dirs:
- /opt/elasticsearch/data
es_config:
cluster.name: "axonops-production"
discovery.seed_hosts: "master-node-1:9300"
node.name: "{{ ansible_hostname }}"
node.master: false
node.data: true
network.host: 0.0.0.0
http.port: 9200
transport.port: 9300
bootstrap.memory_lock: true- name: Install Elasticsearch with Plugins
hosts: axon-server
become: true
vars:
es_version: 7.17.0
es_plugins:
- plugin: ingest-attachment
roles:
- role: axonops.axonops.elastic- name: Install Elasticsearch from Custom URL
hosts: axon-server
become: true
vars:
es_version: 7.17.0
es_use_repository: false
es_custom_package_url: https://downloads.example.com/elasticsearch-7.17.0.rpm
roles:
- role: axonops.axonops.elasticFor AxonOps Server version 2.0.4 and above, use the new hosts array format:
axon_server_elastic_hosts:
- http://127.0.0.1:9200For older server versions, use the legacy configuration:
axon_server_elastic_host: "http://127.0.0.1"
axon_server_elastic_port: "9200"- Heap Size: Set
es_heap_sizeto about 50% of available RAM, but not more than 31GB - Memory Lock: Enable
bootstrap.memory_lockto prevent swapping
- Important: If Elasticsearch binds to a different host or port than the defaults, update
es_api_hostandes_api_port - The role uses these variables for HTTP operations like installing templates and checking node status
- Do not use both: Use
es_data_dirsandes_log_dirORes_config['path.data']andes_config['path.logs'], not both - Using both will create duplicate entries in
elasticsearch.ymland cause startup failures
- Plugins are automatically managed based on the Elasticsearch version
- Setting
es_plugins_reinstall: truewill remove and reinstall all plugins - If
es_pluginsis empty, all currently installed plugins will be removed
| Variable | Default | Description |
|---|---|---|
es_start_service |
true |
Whether to start Elasticsearch after installation |
es_restart_on_change |
true |
Whether to restart Elasticsearch when configuration changes |
Available tags for granular control (use --list-tasks to see all available tags):
- Standard Ansible role tags for different installation phases
You can override default configuration templates:
es_config_default: "my-elasticsearch.j2" # Override /etc/default/elasticsearch
es_config_jvm: "my-jvm.options.j2" # Override jvm.options
es_config_log4j2: "my-log4j2.properties.j2" # Override log4j2.propertiesFor environments requiring proxy access:
es_proxy_host: proxy.example.com
es_proxy_port: 8080See the main collection LICENSE file and the Elasticsearch role LICENSE.
Originally by Elastic Integrated by AxonOps Limited