lynxis lazus has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ci/+/30913 )


Change subject: install-poky-sdk: ensure it's not installed twice
......................................................................

install-poky-sdk: ensure it's not installed twice

Check if the poky path already exists. Even this wouldn't
detect if the poky has been only installed half way.
Change-Id: I8f795be1e595268abe279b4d15d0b0c162ee22e1

Change-Id: I8ff8e72a5974378327d4692341b0a371c667b741
---
M ansible/roles/install-poky-sdk/tasks/main.yml
1 file changed, 37 insertions(+), 32 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ci refs/changes/13/30913/1

diff --git a/ansible/roles/install-poky-sdk/tasks/main.yml 
b/ansible/roles/install-poky-sdk/tasks/main.yml
index 4b41bd2..7c1e9a9 100644
--- a/ansible/roles/install-poky-sdk/tasks/main.yml
+++ b/ansible/roles/install-poky-sdk/tasks/main.yml
@@ -9,40 +9,45 @@
     cache_valid_time: 3600
     update_cache: yes

-- name: copy poky installer
-  copy:
-    src: "{{ poky_installer_file }}"
-    dest: "/tmp/{{ poky_installer_file }}"
-    mode: 0750
-  register: poky_copy
-  ignore_errors: yes
-  tags: [poky]
-
-- name: execute poky installer
-  command: "/tmp/{{ poky_installer_file }} -y -d '{{ poky_dest }}'"
-  args:
-    creates: "{{ poky_dest }}"
-  when: poky_copy.failed == False
-  tags: [poky]
-
-- name: change owner/group to jenkins user
-  file:
+- name: check if poky needs to be installed
+  stat:
     path: "{{ poky_dest }}"
-    owner: "{{ jenkins_user }}"
-    group: "{{ jenkins_user }}"
-    recurse: yes
-  when: poky_copy.failed == False
+  register: poky_stat
   tags: [poky]

-- name: remove poky installer
-  file:
-    path: "/tmp/{{ poky_installer_file }}"
-    state: absent
-  when: poky_copy.failed == False
+- name: install poky if required
   tags: [poky]
+  when: poky_stat.stat.exists == False
+  block:
+  - name: copy poky installer
+    copy:
+      src: "{{ poky_installer_file }}"
+      dest: "/tmp/{{ poky_installer_file }}"
+      mode: 0750
+    register: poky_copy
+    ignore_errors: yes

-- name: "Please download {{ poky_installer_file }} to your ansible directory 
to allow ansible to install poky"
-  debug:
-    msg: "Ansible can not find or copy {{ poky_installer_file }}"
-  when: poky_copy.failed == True
-  tags: [poky]
+  - name: execute poky installer
+    command: "/tmp/{{ poky_installer_file }} -y -d '{{ poky_dest }}'"
+    args:
+      creates: "{{ poky_dest }}"
+    when: poky_copy.failed == False
+
+  - name: change owner/group to jenkins user
+    file:
+      path: "{{ poky_dest }}"
+      owner: "{{ jenkins_user }}"
+      group: "{{ jenkins_user }}"
+      recurse: yes
+    when: poky_copy.failed == False
+
+  - name: remove poky installer
+    file:
+      path: "/tmp/{{ poky_installer_file }}"
+      state: absent
+    when: poky_copy.failed == False
+
+  - name: "Please download {{ poky_installer_file }} to your ansible directory 
to allow ansible to install poky"
+    debug:
+      msg: "Ansible can not find or copy {{ poky_installer_file }}"
+    when: poky_copy.failed == True

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

Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Change-Id: I8ff8e72a5974378327d4692341b0a371c667b741
Gerrit-Change-Number: 30913
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus <[email protected]>
Gerrit-MessageType: newchange

Reply via email to