From b58daabb29912f2703369f0cadfec127e05e5376 Mon Sep 17 00:00:00 2001 From: nicoo Date: Thu, 5 Jul 2018 14:11:04 +0200 Subject: [PATCH] =?utf8?q?Import=20the=20old=20=E2=80=9Ccreate-users=E2=80=9D?= =?utf8?q?=20group?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- ansible/roles/create-users/defaults/main.yml | 1 + ansible/roles/create-users/tasks/main.yml | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 ansible/roles/create-users/defaults/main.yml create mode 100644 ansible/roles/create-users/tasks/main.yml 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? -- 1.7.10.4