Copy phd.tar.bz2, extract it and rsync to home.
block:
- name: "Create user phd"
import_tasks: create.yml
- - name: "Setup SSH: copy SSH public key"
- import_tasks: setup-ssh.yml
+ - name: "Setup home dir"
+ import_tasks: setup-home.yml
when: phd_exist.rc != 0
--- /dev/null
+- name: Upload archive
+ copy:
+ src: ~/archive/STORE/phd/Home/phd.tar.bz2
+ dest: /tmp
+
+- name: Extract archive
+ shell: "cd /tmp && bzcat phd.tar.bz2 | tar xf -"
+
+- name: Copy home
+ command: rsync -a /tmp/phd /home
+
+- name: Cleanup
+ file:
+ path: "{{ item }}"
+ state: absent
+ loop: ['/tmp/phd', '/tmp/phd.tar.bz2']
+++ /dev/null
-- name: Create folder ~phd/.ssh
- file:
- path: ~phd/.ssh
- state: directory
- owner: phd
- group: phd
- mode: 0700
-
-- name: Upload SSH key
- copy:
- src: ~/.ssh/phd@nb3.pub
- dest: ~phd/.ssh/authorized_keys
- owner: phd
- group: phd
- mode: 0600