Change helm plugin install to copy module

Since helm plugin install command is not the most suitable
for Ansible and it basically just creates link to plugin original
location this change is using Ansible's copy module instead.

Plugin is copied from install server because copy module doesn't
support recursive directory copying with remote_src option.

Issue-ID: OOM-1638
Change-Id: I9e9dcd8d33f8917296f576c2b34c0c576c9c126c
Signed-off-by: Milan Verespej <m.verespej@partner.samsung.com>
diff --git a/ansible/roles/application-install/tasks/pre-install.yml b/ansible/roles/application-install/tasks/pre-install.yml
index 3d63cb5..f87ade3 100644
--- a/ansible/roles/application-install/tasks/pre-install.yml
+++ b/ansible/roles/application-install/tasks/pre-install.yml
@@ -20,21 +20,27 @@
 
 - name: Install helm plugins if needed
   block:
-     - name: Ensure that dir for helm plugins exists
-       file:
-         path: "~/.helm/plugins"
-         state: directory
-         mode: 0755
-     - name: Register all plugins to be inserted by dir names
-       find:
-         paths: "{{ app_helm_plugins_directory }}"
-         file_type: "directory"
-       register: list_of_plugins
-     - name: Install all helm plugins from {{ app_helm_plugins_directory }} dir
-       command: "{{ helm_bin_dir }}/helm plugin install {{ item.path }}"
-       with_items: "{{ list_of_plugins.files }}"
-       register: helm_plugin_install_result
-       failed_when: "helm_plugin_install_result.rc > 0 and helm_plugin_install_result.stderr != 'Error: plugin already exists'"
+    - name: Get helm dir
+      command: "{{ helm_bin_dir }}/helm home"
+      register: helm_home_dir
+    - name: Ensure that dir for helm plugins exists
+      file:
+        path: "{{ helm_home_dir.stdout }}/plugins"
+        state: directory
+        mode: 0755
+    - name: Register all plugins to be inserted by dir names
+      find:
+        paths: "{{ app_helm_plugins_directory }}"
+        file_type: "directory"
+      register: list_of_plugins
+      delegate_to: localhost
+    - name: Install all helm plugins from {{ app_helm_plugins_directory }} dir
+      copy:
+        src: "{{ item.path }}"
+        dest: "{{ helm_home_dir.stdout }}"/plugins"
+        directory_mode: yes
+        mode: 0755
+      with_items: "{{ list_of_plugins.files }}"
   become: true
   when: app_helm_plugins_directory is defined and app_helm_plugins_directory is not none