From: nicoo Date: Thu, 5 Jul 2018 12:11:04 +0000 (+0200) Subject: Import the old “create-users” group X-Git-Url: https://git.realraum.at/?a=commitdiff_plain;h=b58daabb29912f2703369f0cadfec127e05e5376;p=noc.git Import the old “create-users” group --- diff --git a/ansible/roles/create-users/defaults/main.yml b/ansible/roles/create-users/defaults/main.yml new file mode 100644 index 0000000..851480c --- /dev/null +++ b/ansible/roles/create-users/defaults/main.yml @@ -0,0 +1 @@ +aux_groups: [] diff --git a/ansible/roles/create-users/tasks/main.yml b/ansible/roles/create-users/tasks/main.yml new file mode 100644 index 0000000..598daac --- /dev/null +++ b/ansible/roles/create-users/tasks/main.yml @@ -0,0 +1,25 @@ +- name: Install sudo + apt: + name: sudo + state: present + when: sudo in aux_groups + +- name: Create users + become: True + user: + name: "{{ item }}" + shell: "{{ users[item].shell }}" + groups: "{{ aux_groups }}" + with_items: "{{ user_groups[group] }}" + +- name: Set SSH keys for users + become: True + authorized_key: + user: "{{ item }}" + key: "{{ users[item].ssh | join("\n") }}" + with_items: "{{ user_groups[group] }}" + +# TODO: +# - on user creation, generate a password and send it, along with useful info +# (hostname, IP, SSH host key, ...), by encrypted email; +# - execute user-specific playbooks for deploying dotfiles?