X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=playbooks%2Froles%2Fdebian-phd%2Ftasks%2Fmain.yml;fp=playbooks%2Froles%2Fdebian-phd%2Ftasks%2Fmain.yml;h=52d15906070d741725539d00f91943a7fb4f573a;hb=d93a94543aca4cce397db250b7dd561bf4729aa4;hp=cea3f9fa3c89a6553e14ca81d64920fd5b25d16c;hpb=ae1408603eb63e72b34e57e9dcfbd12bfa65e5bc;p=ansible.git diff --git a/playbooks/roles/debian-phd/tasks/main.yml b/playbooks/roles/debian-phd/tasks/main.yml index cea3f9f..52d1590 100644 --- a/playbooks/roles/debian-phd/tasks/main.yml +++ b/playbooks/roles/debian-phd/tasks/main.yml @@ -1,30 +1,16 @@ -- 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: 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 +- name: Test if user phd already exists + command: test -f ~/.profile -a -f ~/.shellrc + ignore_errors: true + register: phd_exist + +- debug: + msg: "User phd has already been created" + when: phd_exist.rc == 0 + +- name: "Create and setup user phd" + block: + - name: "Create user phd" + import_tasks: create.yml + - name: "Setup SSH: copy SSH public key" + import_tasks: setup-ssh.yml + when: phd_exist.rc != 0