laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-ci/+/30917 )

 (

3 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted 
one.
 )Change subject: ansible: install-coverity: ensure it's not installed twice
......................................................................

ansible: install-coverity: ensure it's not installed twice

Check if the coverity path already exists. Even this wouldn't
detect if the coverity has been only installed half way.

Related: OS#5801
Change-Id: I95549983bb6bd47e04eb37c73afe5409637f87d3
---
M ansible/roles/install-coverity/tasks/main.yml
1 file changed, 48 insertions(+), 30 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified




diff --git a/ansible/roles/install-coverity/tasks/main.yml 
b/ansible/roles/install-coverity/tasks/main.yml
index 6192c27..246fa36 100644
--- a/ansible/roles/install-coverity/tasks/main.yml
+++ b/ansible/roles/install-coverity/tasks/main.yml
@@ -5,39 +5,44 @@
       - curl
   tags: [coverity]

-- name: copy coverity installer
-  copy:
-    src: "{{ coverity_installer_file }}"
-    dest: "/tmp/{{ coverity_installer_file }}"
-    mode: 0750
-  register: coverity_copy
-  ignore_errors: yes
+- name: check if coverity needs to be installed
+  stat:
+    path: "/opt/coverity/{{ coverity_version }}/"
+  register: coverity_stat
   tags: [coverity]

-- name: create /opt/coverity/{{ coverity_version }}/
-  file:
-    path: /opt/coverity/{{ coverity_version }}/
-    state: directory
-  when: coverity_copy.failed == False
+- name: install coverity if required
+  when: coverity_stat.stat.exists == False
   tags: [coverity]
+  block:
+    - name: copy coverity installer
+      copy:
+        src: "{{ coverity_installer_file }}"
+        dest: "/tmp/{{ coverity_installer_file }}"
+        mode: 0750
+      register: coverity_copy
+      ignore_errors: yes

-- name: unpack coverity
-  unarchive:
-    src: "/tmp/{{ coverity_installer_file }}"
-    dest: /opt/coverity/{{ coverity_version }}
-    remote_src: yes
-  when: coverity_copy.failed == False
-  tags: [coverity]
+    - name: create /opt/coverity/{{ coverity_version }}/
+      file:
+        path: /opt/coverity/{{ coverity_version }}/
+        state: directory
+      when: coverity_copy.failed == False

-- name: create link /opt/coverity/current
-  shell: ln -sf /opt/coverity/{{ coverity_version }}/* /opt/coverity/current
-  args:
-    warn: false
-  when: coverity_copy.failed == False
-  tags: [coverity]
+    - name: unpack coverity
+      unarchive:
+        src: "/tmp/{{ coverity_installer_file }}"
+        dest: /opt/coverity/{{ coverity_version }}
+        remote_src: yes
+      when: coverity_copy.failed == False

-- name: "Please download {{ coverity_installer_file }} to your ansible 
directory to allow ansible to install coverity"
-  debug:
-    msg: "Ansible can not find {{ coverity_installer_file }}"
-  when: coverity_copy.failed
-  tags: [coverity]
+    - name: create link /opt/coverity/current
+      shell: ln -sf /opt/coverity/{{ coverity_version }}/* 
/opt/coverity/current
+      args:
+        warn: false
+      when: coverity_copy.failed == False
+
+    - name: "Please download {{ coverity_installer_file }} to your ansible 
directory to allow ansible to install coverity"
+      debug:
+        msg: "Ansible can not find {{ coverity_installer_file }}"
+      when: coverity_copy.failed

--
To view, visit https://gerrit.osmocom.org/c/osmo-ci/+/30917
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Change-Id: I95549983bb6bd47e04eb37c73afe5409637f87d3
Gerrit-Change-Number: 30917
Gerrit-PatchSet: 5
Gerrit-Owner: lynxis lazus <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-CC: osmith <[email protected]>
Gerrit-MessageType: merged

Reply via email to