Changes to support Hash Map for Config

This commit is contained in:
Dale McDiarmid 2015-11-24 17:32:36 +00:00
parent 4689922ad6
commit d34d5e6103
15 changed files with 65 additions and 64 deletions

View file

@ -18,6 +18,7 @@ platforms:
- apt-get update && apt-get install -y software-properties-common && add-apt-repository -y ppa:ansible/ansible
- apt-get update && apt-get -y -q install ansible python-apt python-pycurl
use_sudo: false
#run_command: "-e ENV ANSIBLE_HASH_BEHAVIOUR=merge"
- name: debian-7
driver_config:
image: electrical/debian:7.3
@ -26,12 +27,16 @@ platforms:
- echo 'deb http://http.debian.net/debian/ wheezy-backports main' >> /etc/apt/sources.list
- apt-get update
- apt-get install -y -q ansible
- apt-get install -y -q net-tools
use_sudo: false
- name: debian-8
driver_config:
image: electrical/debian:8
privileged: true
provision_command: apt-get -y -q install ansible
provision_command:
- apt-get update
- apt-get install -y -q ansible
- apt-get install -y -q net-tools
use_sudo: false
- name: centos-6
driver_config:

View file

@ -29,7 +29,7 @@ hosts: my_host
- .... your tasks ...
```
By default es_multicast_enabled is false. If this is not to true, the user is required to specify the following additional parameters:
By default es_multicast_enabled is false and the user is required to specify the following additional parameters:
1. es_http_port - the http port for the node
2. es_transport_tcp_port - the transport port for the node

View file

@ -1,2 +1,2 @@
[defaults]
roles_path = ../
hash_behaviour = merge

View file

@ -9,6 +9,9 @@ es_scripts: false
es_templates: false
es_user: elasticsearch
es_group: elasticsearch
es_cluster_name: elasticsearch
es_multicast_enabled: false
es_node_name_prefix: ""
es_config: {
"cluster_name": elasticsearch,
"multicast_enabled": false,
"node_name_prefix": ""
}

View file

@ -1,10 +1,10 @@
# Check for mandatory parameters
- fail: msg="Parameter 'es_http_port' must be defined when multicast is disabled"
when: es_multicast_enabled == false and es_http_port is not defined
when: es_config['multicast_enabled'] == false and es_config['http_port'] is not defined
- fail: msg="Parameter 'es_transport_tcp_port' must be defined when multicast is disabled"
when: es_multicast_enabled == false and es_transport_tcp_port is not defined
when: es_config['multicast_enabled'] == false and es_config['transport_tcp_port'] is not defined
- fail: msg="Parameter 'es_unicast_hosts' must be defined when multicast is disabled"
when: es_multicast_enabled == false and es_unicast_hosts is not defined
when: es_config['multicast_enabled'] == false and es_config['unicast_hosts'] is not defined

View file

@ -44,15 +44,15 @@
when: es_max_open_files is defined
register: elasticsearch_configure
#For directories we also use the {{ es_node_name_prefix }}{{inventory_hostname}} - this helps if we have a shared SAN. {{es_node_name_prefix}}{{default_file | basename} could potentially be used -
#For directories we also use the {{ es_config['node_name_prefix'] }}{{inventory_hostname}} - this helps if we have a shared SAN. {{es_config['node_name_prefix']}}{{default_file | basename} could potentially be used -
#init script effectively means this is the default.
#Create PID directory
- name: Create PID Directory
file: path={{pid_dir}}/{{ es_node_name_prefix }}{{inventory_hostname}} state=directory owner={{ es_user }} group={{ es_group }}
file: path={{pid_dir}}/{{ es_config['node_name_prefix'] }}{{inventory_hostname}} state=directory owner={{ es_user }} group={{ es_group }}
- name: Configure PID directory
lineinfile: dest={{instance_default_file}} regexp="^PID_DIR" insertafter="^#PID_DIR" line="PID_DIR={{pid_dir}}/{{ es_node_name_prefix }}{{inventory_hostname}}"
lineinfile: dest={{instance_default_file}} regexp="^PID_DIR" insertafter="^#PID_DIR" line="PID_DIR={{pid_dir}}/{{ es_config['node_name_prefix'] }}{{inventory_hostname}}"
register: elasticsearch_configure
- set_fact: es_data_dir={{default_data_dir}}
@ -60,30 +60,30 @@
#include the host name as potentially shared SAN
- name: Create data dir
file: state=directory path={{ es_data_dir }}/{{ es_node_name_prefix }}{{inventory_hostname}} owner={{ es_user }} group={{ es_group }}
file: state=directory path={{ es_data_dir }}/{{ es_config['node_name_prefix'] }}{{inventory_hostname}} owner={{ es_user }} group={{ es_group }}
- name: Configure data store
lineinfile: dest={{instance_default_file}} regexp="^DATA_DIR" insertafter="^#DATA_DIR" line="DATA_DIR={{ es_data_dir }}/{{ es_node_name_prefix }}{{inventory_hostname}}"
lineinfile: dest={{instance_default_file}} regexp="^DATA_DIR" insertafter="^#DATA_DIR" line="DATA_DIR={{ es_data_dir }}/{{ es_config['node_name_prefix'] }}{{inventory_hostname}}"
register: elasticsearch_configure
- set_fact: es_work_dir={{default_work_dir}}
when: es_work_dir is undefined
- name: Create work dir
file: state=directory path={{ es_work_dir }}/{{ es_node_name_prefix }}{{inventory_hostname}} owner={{ es_user }} group={{ es_group }}
file: state=directory path={{ es_work_dir }}/{{ es_config['node_name_prefix'] }}{{inventory_hostname}} owner={{ es_user }} group={{ es_group }}
- name: Configure work directory
lineinfile: dest={{instance_default_file}} regexp="^WORK_DIR" insertafter="^#WORK_DIR" line="WORK_DIR={{ es_work_dir }}/{{ es_node_name_prefix }}{{inventory_hostname}}"
lineinfile: dest={{instance_default_file}} regexp="^WORK_DIR" insertafter="^#WORK_DIR" line="WORK_DIR={{ es_work_dir }}/{{ es_config['node_name_prefix'] }}{{inventory_hostname}}"
register: elasticsearch_configure
- set_fact: es_log_dir={{default_log_dir}}
when: es_log_dir is undefined
- name: Create log dir
file: state=directory path={{ es_log_dir }}/{{ es_node_name_prefix }}{{inventory_hostname}} owner={{ es_user }} group={{ es_group }}
file: state=directory path={{ es_log_dir }}/{{ es_config['node_name_prefix'] }}{{inventory_hostname}} owner={{ es_user }} group={{ es_group }}
- name: Configure log directory
lineinfile: dest={{instance_default_file}} regexp="^LOG_DIR" insertafter="^#LOG_DIR" line="LOG_DIR={{ es_log_dir }}/{{ es_node_name_prefix }}{{inventory_hostname}}"
lineinfile: dest={{instance_default_file}} regexp="^LOG_DIR" insertafter="^#LOG_DIR" line="LOG_DIR={{ es_log_dir }}/{{ es_config['node_name_prefix'] }}{{inventory_hostname}}"
register: elasticsearch_configure
#required so that the ES_HOME does not change between instances
@ -104,7 +104,7 @@
#Apply changes to init script - NAME can be changed in Debian start script
- name: Name Node in Init Script
lineinfile: dest={{instance_init_script}} regexp="^NAME" line="NAME={{es_node_name_prefix}}{{default_file | basename}}"
lineinfile: dest={{instance_init_script}} regexp="^NAME" line="NAME={{es_config['node_name_prefix']}}{{default_file | basename}}"
register: elasticsearch_configure
when: ansible_os_family == 'Debian'

View file

@ -1,7 +1,8 @@
---
- set_fact: instance_default_file={{default_file | dirname}}/{{es_node_name_prefix}}{{default_file | basename}}
- set_fact: instance_init_script={{init_script | dirname }}/{{es_node_name_prefix}}{{init_script | basename}}
- set_fact: instance_config_directory={{ es_conf_dir }}/{{es_node_name_prefix}}elasticsearch
- debug: msg="Node configuration {{ es_config }} "
- set_fact: instance_default_file={{default_file | dirname}}/{{es_config["node_name_prefix"]}}{{default_file | basename}}
- set_fact: instance_init_script={{init_script | dirname }}/{{es_config['node_name_prefix']}}{{init_script | basename}}
- set_fact: instance_config_directory={{ es_conf_dir }}/{{es_config['node_name_prefix']}}elasticsearch

View file

@ -29,29 +29,29 @@
# Cluster name identifies your cluster for auto-discovery. If you're running
# multiple clusters on the same network, make sure you're using unique names.
#
cluster.name: {{ es_cluster_name }}
cluster.name: {{ es_config['cluster_name'] }}
#################################### Node #####################################
# Node names are generated dynamically on startup, so you're relieved
# from configuring them manually. You can tie this node to a specific name:
#
node.name: {{es_node_name_prefix}}{{inventory_hostname}}
node.name: {{ es_config['node_name_prefix'] }}{{inventory_hostname}}
# Every node can be configured to allow or deny being eligible as the master,
# and to allow or deny to store the data.
#
# Allow this node to be eligible as a master node (enabled by default):
#
{% if es_master_node is defined %}
node.master: {{es_master_node | lower}}
{% if es_config['master_node'] is defined %}
node.master: {{ es_config['master_node'] | lower}}
{% endif %}
#
# Allow this node to store data (enabled by default):
#
{% if es_data_node is defined %}
node.data: {{es_data_node | lower}}
{% if es_config['data_node'] is defined %}
node.data: {{ es_config['data_node'] | lower}}
{% endif %}
# Use the Cluster Health API [http://localhost:9200/_cluster/health], the
@ -65,8 +65,8 @@ node.data: {{es_data_node | lower}}
# for customized shard allocation filtering, or allocation awareness. An attribute
# is a simple key value pair, similar to node.key: value, here is an example:
#
{% if es_node_rack is defined %}
node.rack: {{ es_node_rack }}
{% if es_config['node_rack'] is defined %}
node.rack: {{ es_config['node_rack'] }}
{% endif %}
# By default, multiple nodes are allowed to start from the same installation location
@ -89,13 +89,13 @@ node.rack: {{ es_node_rack }}
# Set the number of shards (splits) of an index (5 by default) if provided:
{% if es_index_number_of_shards is defined %}
index.number_of_shards: {{ es_index_number_of_shards }}
{% if es_config['index_number_of_shards'] is defined %}
index.number_of_shards: {{ es_config['index_number_of_shards'] }}
{% endif %}
# Set the number of replicas (additional copies) of an index (1 by default) if provided:
{% if es_index_number_of_replicas is defined %}
index.number_of_replicas: {{ es_index_number_of_replicas }}
{% if es_config['index_number_of_replicas'] is defined %}
index.number_of_replicas: {{ es_config['index_number_of_replicas'] }}
{% endif %}
@ -124,10 +124,7 @@ index.number_of_replicas: {{ es_index_number_of_replicas }}
#################################### Paths ####################################
# Path to directory containing configuration (this file and logging.yml):
#
{% if es_conf_dir is defined %}
path.conf: {{ es_conf_dir }}
{% endif %}
path.conf: {{ instance_config_directory }}
# Path to directory where to store index data allocated for this node.
@ -169,8 +166,8 @@ path.logs: {{ es_log_dir }}
#
# Set this property to true to lock the memory:
#
{% if es_m_lock_enabled is defined %}
bootstrap.mlockall: {{es_m_lock_enabled | lower}}
{% if es_config['m_lock_enabled'] is defined %}
bootstrap.mlockall: {{ es_config['m_lock_enabled'] | lower}}
{% endif %}
@ -200,15 +197,15 @@ bootstrap.mlockall: {{es_m_lock_enabled | lower}}
# Set both 'bind_host' and 'publish_host':
#
{% if es_network_host is defined %}
network.host: {{ es_network_host }}
{% if es_config['network_host'] is defined %}
network.host: {{ es_config['network_host'] }}
{% endif %}
# Set a custom port for the node to node communication (9300 by default):
#
{% if es_transport_tcp_port is defined %}
transport.tcp.port: {{ es_transport_tcp_port }}
{% if es_config['transport_tcp_port'] is defined %}
transport.tcp.port: {{ es_config['transport_tcp_port'] }}
{% endif %}
# Enable compression for all communication between nodes (disabled by default):
@ -217,8 +214,8 @@ transport.tcp.port: {{ es_transport_tcp_port }}
# Set a custom port to listen for HTTP traffic (9200 by default):
#
{% if es_http_port is defined %}
http.port: {{ es_http_port }}
{% if es_config['http_port'] is defined %}
http.port: {{ es_config['http_port'] }}
{% endif %}
# Set a custom allowed content length:
@ -316,7 +313,7 @@ http.port: {{ es_http_port }}
#
# 1. Disable multicast discovery (enabled by default):
#
discovery.zen.ping.multicast.enabled: {{es_multicast_enabled | lower }}
discovery.zen.ping.multicast.enabled: {{ es_config['multicast_enabled'] | lower }}
#
# 2. Configure an initial list of master nodes in the cluster
@ -325,8 +322,8 @@ discovery.zen.ping.multicast.enabled: {{es_multicast_enabled | lower }}
#We put all the current eligible masters in here. If not specified, we assumes its a master
{% if es_multicast_enabled is defined and not es_multicast_enabled %}
discovery.zen.ping.unicast.hosts: {{es_unicast_hosts}}
{% if es_config['multicast_enabled'] is defined and not es_config['multicast_enabled'] %}
discovery.zen.ping.unicast.hosts: {{ es_config['unicast_hosts'] }}
{% endif %}

View file

@ -4,9 +4,9 @@
hosts: localhost
roles:
#expand to all available parameters
- { role: elasticsearch, es_unicast_hosts: "localhost:9301", es_http_port: "9201", es_transport_tcp_port: "9301", es_data_node: false, es_master_node: true, es_m_lock_enabled: true, es_multicast_enabled: false, es_node_name_prefix: "node1_", es_cluster_name: "custom-cluster" }
- { role: elasticsearch, es_config: { node_name_prefix: "node1_", cluster_name: "custom-cluster", unicast_hosts: "localhost:9301", http_port: "9201", transport_tcp_port: "9301", data_node: false, master_node: true, m_lock_enabled: true, multicast_enabled: false } }
vars:
es_scripts: false
es_templates: false
es_version_lock: false
es_m_lock_enabled: true
es_config: { "m_lock_enabled": true }

View file

@ -3,6 +3,6 @@
- name: Elasticsearch Config tests
hosts: localhost
roles:
- { role: elasticsearch, es_node_name_prefix: "node1_", es_unicast_hosts: "localhost:9300", es_http_port: "9201", es_transport_tcp_port: "9301", es_data_node: true, es_master_node: false, es_m_lock_enabled: true, es_multicast_enabled: false }
- { role: elasticsearch, es_node_name_prefix: "master_", es_unicast_hosts: "localhost:9300", es_http_port: "9200", es_transport_tcp_port: "9300", es_data_node: false, es_master_node: true, es_m_lock_enabled: true, es_multicast_enabled: false }
- { role: elasticsearch, es_config: { "multicast_enabled": false, node_name_prefix: "master_", unicast_hosts: "localhost:9300", http_port: "9200", transport_tcp_port: "9300", data_node: false, master_node: true, m_lock_enabled: true,multicast_enabled: false } }
- { role: elasticsearch, es_config: { "multicast_enabled": false, node_name_prefix: "node1_", unicast_hosts: "localhost:9300", http_port: "9201", transport_tcp_port: "9301", data_node: true, master_node: false, m_lock_enabled: true,multicast_enabled: false } }
vars:

View file

@ -2,5 +2,5 @@
- name: Elasticsearch Package tests
hosts: localhost
roles:
- { role: elasticsearch, es_multicast_enabled: true}
- { role: elasticsearch, es_config: { "multicast_enabled": true } }
vars:

View file

@ -2,7 +2,7 @@
- name: wrapper playbook for kitchen testing "elasticsearch"
hosts: localhost
roles:
- { role: elasticsearch, es_multicast_enabled: true}
- { role: elasticsearch, es_config: { "multicast_enabled": true } }
vars:
es_use_repository: "true"
es_plugins:

View file

@ -4,8 +4,3 @@ default_file: "/etc/default/elasticsearch"
init_script: "/etc/init.d/elasticsearch"
es_conf_dir: "/etc/elasticsearch"
es_home: "/usr/share/elasticsearch"
default_data_dir: "/var/lib/elasticsearch"
default_log_dir: "/var/log/elasticsearch"
default_work_dir: "/tmp/elasticsearch"
default_pid_dir: "/var/run/elasticsearch"