summaryrefslogtreecommitdiffstats
path: root/ansible/roles/resource-data/tasks/ssh-upload.yml
diff options
context:
space:
mode:
authorSamuli Silvius <s.silvius@partner.samsung.com>2019-02-19 16:00:37 +0200
committerMichal Ptacek <m.ptacek@partner.samsung.com>2019-03-07 08:01:08 +0000
commit29886f09d53bee1ecdc1bc8612e8edb4a130a270 (patch)
tree9507ee70a95e27afd81adf284f1dfe2c8b946491 /ansible/roles/resource-data/tasks/ssh-upload.yml
parentf968e170316ee1e514d4cf03a56137ba93c1a0bf (diff)
Re-factored resources upload into role
Whole functionality of resource files upload is implemented in resource-data role instead of playbook level tasks. This will make roles easier to test and make it easier to implement other OS support later. Issue-ID: OOM-1654 Change-Id: I3d3da9381b0e804f511ee854c41554b924d18883 Signed-off-by: Samuli Silvius <s.silvius@partner.samsung.com>
Diffstat (limited to 'ansible/roles/resource-data/tasks/ssh-upload.yml')
-rw-r--r--ansible/roles/resource-data/tasks/ssh-upload.yml60
1 files changed, 0 insertions, 60 deletions
diff --git a/ansible/roles/resource-data/tasks/ssh-upload.yml b/ansible/roles/resource-data/tasks/ssh-upload.yml
deleted file mode 100644
index bc7df37f..00000000
--- a/ansible/roles/resource-data/tasks/ssh-upload.yml
+++ /dev/null
@@ -1,60 +0,0 @@
----
-- name: Upload resources to infrastructure servers over ssh
- block:
- - name: Upload ssh private key
- copy:
- src: "{{ ansible_ssh_private_key_file }}"
- dest: /root/.ssh/infra_to_resource.privkey
- mode: 0600
- owner: root
- group: root
- remote_src: no
-
- - name: Unarchive resources
- shell: >
- ssh -o StrictHostKeyChecking=no -o BatchMode=yes
- -i /root/.ssh/infra_to_resource.privkey
- {{ hostvars[groups.resources.0].ansible_host }}
- 'cat "{{ hostvars[groups.resources.0].resources_dir }}/{{ hostvars[groups.resources.0].resources_filename }}"'
- | tar -C "{{ app_data_path }}" -xf -
- args:
- warn: False
- when: not resources_data_check.stat.exists
-
- - name: Unarchive auxiliary resources
- shell: >
- ssh -i /root/.ssh/infra_to_resource.privkey
- {{ hostvars[groups.resources.0].ansible_host }}
- 'cat "{{ hostvars[groups.resources.0].resources_dir }}/{{ hostvars[groups.resources.0].aux_resources_filename }}"'
- | tar -C "{{ aux_data_path }}" -xf -
- when: >
- hostvars[groups.resources.0].aux_resources_filename is defined
- and hostvars[groups.resources.0].aux_resources_filename is not none
- and aux_data_path is defined and aux_data_path is not none
- and hostvars[groups.resources.0].aux_file_presence.stat.exists
- and not aux_resources_data_check.stat.exists
- args:
- warn: False
-
- rescue:
- - name: Removing the resources data due to an error - so the next run can try again
- command: /bin/false
- register: upload_failed
-
- always:
- - name: Remove the ssh private key
- file:
- path: /root/.ssh/infra_to_resource.privkey
- state: absent
-
- - name: Remove the resource data on error
- file:
- path: "{{ app_data_path }}"
- state: absent
- when: upload_failed is defined
-
- - name: Remove the auxilliary resource data on error
- file:
- path: "{{ aux_data_path }}"
- state: absent
- when: upload_failed is defined