]> git.phdru.name Git - ansible.git/blob - playbooks/debian/roles/phd/tasks/main.yml
1ca3a4b3c8340b70fd436ce2a836328395618a41
[ansible.git] / playbooks / debian / roles / phd / tasks / main.yml
1 - name: Test if user phd already exists
2   stat:
3     path: "{{ item }}"
4   register: phd_exists
5   changed_when: not phd_exists.stat.exists
6   loop: ['~/.profile', '~/.shellrc']
7
8 - debug:
9     msg: "User phd has already been created"
10   when: phd_exists.results|selectattr('stat.exists')|list|length == 2
11
12 - name: Create and setup user phd
13   block:
14     - name: Create system groups
15       become: true
16       group:
17         name: "{{ item }}"
18         system: true
19       loop: "{{ system_groups.split(',') }}"
20
21     - name: Create group phd
22       become: true
23       group:
24         name: phd
25
26     - name: Add user phd
27       become: true
28       user:
29         name: phd
30         group: phd
31         groups: "{{ system_groups }}"
32
33     - name: Upload and extract home archive
34       unarchive:
35         src: ~/archive/STORE/phd/Home/phd.tar.bz2
36         dest: /home
37   when: phd_exists.results|selectattr('stat.exists')|list|length != 2