X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=playbooks%2Froles%2Fphd%2Ftasks%2Fmain.yml;fp=playbooks%2Froles%2Fphd%2Ftasks%2Fmain.yml;h=cb36caa7276bb51b725765e795f14361c1f3af50;hb=821cc704535e7fb9a2aaafc5692ad68e38308786;hp=0000000000000000000000000000000000000000;hpb=b8f10de1474570fe82b311a76fb2d5b51ad8152b;p=ansible.git diff --git a/playbooks/roles/phd/tasks/main.yml b/playbooks/roles/phd/tasks/main.yml new file mode 100644 index 0000000..cb36caa --- /dev/null +++ b/playbooks/roles/phd/tasks/main.yml @@ -0,0 +1,59 @@ +- name: Test if user phd already exists + stat: + path: "{{ item }}" + register: phd_exists + changed_when: not phd_exists.stat.exists + loop: ['~/.profile', '~/.shellrc'] + +- debug: + msg: "User phd has already been created" + when: phd_exists.results|selectattr('stat.exists')|list|length == 2 + +- name: Create and setup user phd + block: + - name: Create system groups + become: true + group: + name: "{{ item }}" + system: true + loop: "{{ system_groups.split(',') }}" + + - name: Create group phd + become: true + group: + name: phd + + - name: Add user phd + become: true + user: + name: phd + group: phd + groups: "{{ system_groups }}" + + - name: Remove mc directories + file: + path: "{{ item }}" + state: absent + loop: ['~/.cache/mc', '~/.config/mc', '~/.local/share/mc'] + + - name: Upload and extract home archive + unarchive: + src: ~/archive/STORE/phd/Home/phd.tar.bz2 + dest: /home + + - name: Add alias + become: true + lineinfile: + path: /etc/aliases + regexp: "^root: phd$" + line: "root: phd" + when: ansible_facts.os_family == 'Debian' + when: phd_exists.results|selectattr('stat.exists')|list|length != 2 + +- name: Add alias + become: true + lineinfile: + path: /etc/aliases + regexp: "^root: phd$" + line: "root: phd" + when: ansible_facts.os_family == 'RedHat'