From 87bbff52790191b9317e4657920b1d2e94fd88bd Mon Sep 17 00:00:00 2001 From: Jonathan Strootman Date: Tue, 26 Apr 2016 12:11:13 -0700 Subject: [PATCH] Add `always` tags to `set_fact` tasks Small correction to `when` clause in `tasks/elasticsearch-plugins.yml`. --- tasks/elasticsearch-config.yml | 14 ++++++++++++++ tasks/elasticsearch-plugins.yml | 8 +++++++- tasks/elasticsearch-scripts.yml | 4 ++++ tasks/elasticsearch-templates.yml | 4 ++++ tasks/elasticsearch.yml | 10 ++++++++++ tasks/main.yml | 2 ++ 6 files changed, 41 insertions(+), 1 deletion(-) diff --git a/tasks/elasticsearch-config.yml b/tasks/elasticsearch-config.yml index 70a1f42..77d0a5f 100644 --- a/tasks/elasticsearch-config.yml +++ b/tasks/elasticsearch-config.yml @@ -11,19 +11,31 @@ - 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', '>=')) }} + tags: + - always - set_fact: instance_sysd_script={{sysd_script | dirname }}/{{es_instance_name}}_{{sysd_script | basename}} when: use_system_d + tags: + - always #For directories we also use the {{inventory_hostname}}-{{ es_instance_name }} - this helps if we have a shared SAN. - set_fact: instance_suffix={{inventory_hostname}}-{{ es_instance_name }} + tags: + - always - set_fact: pid_dir={{ es_pid_dir }}/{{instance_suffix}} + tags: + - always - set_fact: log_dir={{ es_log_dir }}/{{instance_suffix}} + tags: + - always - set_fact: work_dir={{ es_work_dir }}/{{instance_suffix}} + tags: + - always #Create required directories - name: Create Directories @@ -36,6 +48,8 @@ - "{{plugin_dir}}" - set_fact: data_dirs={{ es_data_dirs | append_to_list('/'+instance_suffix) }} + tags: + - always - name: Create Data Directories file: path={{ item }} state=directory owner={{ es_user }} group={{ es_group }} diff --git a/tasks/elasticsearch-plugins.yml b/tasks/elasticsearch-plugins.yml index a3e4e1b..94d7353 100644 --- a/tasks/elasticsearch-plugins.yml +++ b/tasks/elasticsearch-plugins.yml @@ -2,11 +2,17 @@ #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. - set_fact: es_plugins_reinstall=true - when: elasticsearch_install.changed or es_plugins is not defined or es_plugins is none + when: (elasticsearch_install is defined and elasticsearch_install.changed) or es_plugins is not defined or es_plugins is none + tags: + - always - set_fact: list_command="list" + tags: + - always - set_fact: list_command="--list" when: es_version | version_compare('2.0', '<') + tags: + - always #List currently installed plugins - shell: "{{es_home}}/bin/plugin {{list_command}} | sed -n '1!p' | cut -d '-' -f2-" diff --git a/tasks/elasticsearch-scripts.yml b/tasks/elasticsearch-scripts.yml index aa363e8..3dc4150 100644 --- a/tasks/elasticsearch-scripts.yml +++ b/tasks/elasticsearch-scripts.yml @@ -1,9 +1,13 @@ --- - set_fact: es_script_dir={{ es_conf_dir }}/{{es_instance_name}} + tags: + - always - set_fact: es_script_dir={{es_config['path.scripts']}} when: es_config['path.scripts'] is defined + tags: + - always - name: Create script dir file: state=directory path={{ es_script_dir }} owner={{ es_user }} group={{ es_group }} diff --git a/tasks/elasticsearch-templates.yml b/tasks/elasticsearch-templates.yml index a4179a6..ccc8b8d 100644 --- a/tasks/elasticsearch-templates.yml +++ b/tasks/elasticsearch-templates.yml @@ -11,9 +11,13 @@ with_fileglob: "{{ es_templates_fileglob }}" - set_fact: http_port=9200 + tags: + - always - set_fact: http_port={{es_config['http.port']}} when: es_config['http.port'] is defined + tags: + - always - name: Wait for elasticsearch to startup wait_for: port={{http_port}} delay=10 diff --git a/tasks/elasticsearch.yml b/tasks/elasticsearch.yml index 18c9206..1e5cc89 100644 --- a/tasks/elasticsearch.yml +++ b/tasks/elasticsearch.yml @@ -1,10 +1,20 @@ --- - set_fact: instance_default_file={{default_file | dirname}}/{{es_instance_name}}_{{default_file | basename}} + tags: + - always - set_fact: instance_init_script={{init_script | dirname }}/{{es_instance_name}}_{{init_script | basename}} + tags: + - always - set_fact: conf_dir={{ es_conf_dir }}/{{es_instance_name}} + tags: + - always - set_fact: plugin_dir={{ es_plugin_dir }}/{{es_instance_name}} + tags: + - always - set_fact: m_lock_enabled={{ es_config['bootstrap.mlockall'] is defined and es_config['bootstrap.mlockall'] == True }} + tags: + - always - debug: msg="Node configuration {{ es_config }} " diff --git a/tasks/main.yml b/tasks/main.yml index bb33824..6b97512 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -5,6 +5,8 @@ - check - name: os-specific vars include_vars: "{{ansible_os_family}}.yml" + tags: + - always - include: java.yml tags: - java