Skip to content

Commit 03f4a8f

Browse files
author
Dale McDiarmid
authored
Merge pull request elastic#102 from CyVerse-Ansible/task-tags
Allow for selective command line task execution
2 parents e6951b0 + 250b0de commit 03f4a8f

7 files changed

+60
-2
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ The simplest configuration therefore consists of:
4040

4141
The above installs a single node 'node1' on the hosts 'localhost'.
4242

43+
This role also uses [Ansible tags](http://docs.ansible.com/ansible/playbooks_tags.html). Run your playbook with the `--list-tasks` flag for more information.
44+
4345
### Basic Elasticsearch Configuration
4446

4547
All Elasticsearch configuration parameters are supported. This is achieved using a configuration map parameter 'es_config' which is serialized into the elasticsearch.yml file.

tasks/elasticsearch-config.yml

+14
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,31 @@
1111

1212

1313
- set_fact: use_system_d={{(ansible_distribution == 'Debian' and ansible_distribution_version | version_compare('8', '>=')) or (ansible_distribution == 'CentOS' and ansible_distribution_version | version_compare('7', '>=')) or (ansible_distribution == 'Ubuntu' and ansible_distribution_version | version_compare('15', '>=')) }}
14+
tags:
15+
- always
1416

1517
- set_fact: instance_sysd_script={{sysd_script | dirname }}/{{es_instance_name}}_{{sysd_script | basename}}
1618
when: use_system_d
19+
tags:
20+
- always
1721

1822
#For directories we also use the {{inventory_hostname}}-{{ es_instance_name }} - this helps if we have a shared SAN.
1923

2024
- set_fact: instance_suffix={{inventory_hostname}}-{{ es_instance_name }}
25+
tags:
26+
- always
2127

2228
- set_fact: pid_dir={{ es_pid_dir }}/{{instance_suffix}}
29+
tags:
30+
- always
2331

2432
- set_fact: log_dir={{ es_log_dir }}/{{instance_suffix}}
33+
tags:
34+
- always
2535

2636
- set_fact: work_dir={{ es_work_dir }}/{{instance_suffix}}
37+
tags:
38+
- always
2739

2840
#Create required directories
2941
- name: Create Directories
@@ -36,6 +48,8 @@
3648
- "{{plugin_dir}}"
3749

3850
- set_fact: data_dirs={{ es_data_dirs | append_to_list('/'+instance_suffix) }}
51+
tags:
52+
- always
3953

4054
- name: Create Data Directories
4155
file: path={{ item }} state=directory owner={{ es_user }} group={{ es_group }}

tasks/elasticsearch-plugins.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@
22

33
#es_plugins_reinstall will be set to true if elasticsearch_install.changed i.e. we have changed ES version, or if no plugins listed. Otherwise it is false and requires explicitly setting.
44
- set_fact: es_plugins_reinstall=true
5-
when: elasticsearch_install.changed or es_plugins is not defined or es_plugins is none
5+
when: (elasticsearch_install is defined and elasticsearch_install.changed) or es_plugins is not defined or es_plugins is none
6+
tags:
7+
- always
68

79
- set_fact: list_command="list"
10+
tags:
11+
- always
812
- set_fact: list_command="--list"
913
when: es_version | version_compare('2.0', '<')
14+
tags:
15+
- always
1016

1117
#List currently installed plugins
1218
- shell: "{{es_home}}/bin/plugin {{list_command}} | sed -n '1!p' | cut -d '-' -f2-"

tasks/elasticsearch-scripts.yml

+4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
---
22

33
- set_fact: es_script_dir={{ es_conf_dir }}/{{es_instance_name}}
4+
tags:
5+
- always
46

57
- set_fact: es_script_dir={{es_config['path.scripts']}}
68
when: es_config['path.scripts'] is defined
9+
tags:
10+
- always
711

812
- name: Create script dir
913
file: state=directory path={{ es_script_dir }} owner={{ es_user }} group={{ es_group }}

tasks/elasticsearch-templates.yml

+4
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@
1111
with_fileglob: "{{ es_templates_fileglob }}"
1212

1313
- set_fact: http_port=9200
14+
tags:
15+
- always
1416

1517
- set_fact: http_port={{es_config['http.port']}}
1618
when: es_config['http.port'] is defined
19+
tags:
20+
- always
1721

1822
- name: Wait for elasticsearch to startup
1923
wait_for: port={{http_port}} delay=10

tasks/elasticsearch.yml

+10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
---
22

33
- set_fact: instance_default_file={{default_file | dirname}}/{{es_instance_name}}_{{default_file | basename}}
4+
tags:
5+
- always
46
- set_fact: instance_init_script={{init_script | dirname }}/{{es_instance_name}}_{{init_script | basename}}
7+
tags:
8+
- always
59
- set_fact: conf_dir={{ es_conf_dir }}/{{es_instance_name}}
10+
tags:
11+
- always
612
- set_fact: plugin_dir={{ es_plugin_dir }}/{{es_instance_name}}
13+
tags:
14+
- always
715
- set_fact: m_lock_enabled={{ es_config['bootstrap.mlockall'] is defined and es_config['bootstrap.mlockall'] == True }}
16+
tags:
17+
- always
818

919
- debug: msg="Node configuration {{ es_config }} "
1020

tasks/main.yml

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,34 @@
11
---
22
- name: check-parameters
33
include: checkParameters.yml
4+
tags:
5+
- check
46
- name: os-specific vars
57
include_vars: "{{ansible_os_family}}.yml"
8+
tags:
9+
- always
610
- include: java.yml
11+
tags:
12+
- java
713
- include: elasticsearch.yml
14+
tags:
15+
- install
816
- include: elasticsearch-config.yml
17+
tags:
18+
- config
919
- include: elasticsearch-scripts.yml
1020
when: es_scripts
21+
tags:
22+
- scripts
1123
- include: elasticsearch-plugins.yml
1224
when: es_plugins is defined or es_plugins_reinstall
25+
tags:
26+
- plugins
1327
- include: elasticsearch-service.yml
28+
tags:
29+
- service
1430
- include: elasticsearch-templates.yml
1531
when: es_templates
16-
- meta: flush_handlers
32+
tags:
33+
- templates
34+
- meta: flush_handlers

0 commit comments

Comments
 (0)