From 50b4621ce1cb9bf0bfc0623cb35457bdb0759e5e Mon Sep 17 00:00:00 2001
From: jurgenhaas <juergen@paragon-es.de>
Date: Fri, 19 Jun 2020 07:46:59 +0200
Subject: [PATCH] Extract plugin re-installation into separate file

---
 tasks/install.yml            | 19 +------------------
 tasks/re-install-plugins.yml | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 18 deletions(-)
 create mode 100644 tasks/re-install-plugins.yml

diff --git a/tasks/install.yml b/tasks/install.yml
index 8aa4871..e4e4d00 100644
--- a/tasks/install.yml
+++ b/tasks/install.yml
@@ -32,26 +32,9 @@
   notify:
     - Restart Elasticsearch
 
-- name: Uninstall Plugins
-  elasticsearch_plugin:
-    name: '{{ item }}'
-    state: absent
-  with_items:
-    - ingest-attachment
-  tags:
-    - reinstall-plugins
-
-- name: Install Plugins
-  elasticsearch_plugin:
-    name: '{{ item }}'
-    state: present
-    force: yes
-  with_items:
-    - ingest-attachment
+- include_tasks: re-install-plugins.yml
   tags:
     - reinstall-plugins
-  notify:
-    - Restart Elasticsearch
 
 - name: Configure ES
   lineinfile:
diff --git a/tasks/re-install-plugins.yml b/tasks/re-install-plugins.yml
new file mode 100644
index 0000000..2241ae5
--- /dev/null
+++ b/tasks/re-install-plugins.yml
@@ -0,0 +1,22 @@
+---
+# file: roles/elasticsearch/tasks/re-install-plugins.yml
+
+- name: Uninstall Plugins
+  elasticsearch_plugin:
+    name: '{{ item }}'
+    state: absent
+  with_items:
+    - ingest-attachment
+
+- name: Install Plugins
+  elasticsearch_plugin:
+    name: '{{ item }}'
+    state: present
+    force: yes
+  with_items:
+    - ingest-attachment
+
+- name: Restart Elasticsearch
+  service:
+    name: elasticsearch
+    state: restarted
-- 
GitLab