diff options
author | Christian Pointner <equinox@spreadspace.org> | 2020-06-01 06:41:24 +0200 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2020-06-01 06:41:24 +0200 |
commit | 508602b0426bdf1412bd6fb3350fece0cae2e7c8 (patch) | |
tree | 10a85d780359d65e67ed3ab45004b808f10cb63c /roles/core/admin-users/tasks | |
parent | major refactoring of users database (diff) |
port admin-users role to openbsd and move to core
Diffstat (limited to 'roles/core/admin-users/tasks')
-rw-r--r-- | roles/core/admin-users/tasks/Debian.yml | 5 | ||||
-rw-r--r-- | roles/core/admin-users/tasks/OpenBSD.yml | 12 | ||||
-rw-r--r-- | roles/core/admin-users/tasks/main.yml | 37 |
3 files changed, 54 insertions, 0 deletions
diff --git a/roles/core/admin-users/tasks/Debian.yml b/roles/core/admin-users/tasks/Debian.yml new file mode 100644 index 00000000..6d8d6f95 --- /dev/null +++ b/roles/core/admin-users/tasks/Debian.yml @@ -0,0 +1,5 @@ +--- +- name: install sudo + apt: + name: sudo + state: present diff --git a/roles/core/admin-users/tasks/OpenBSD.yml b/roles/core/admin-users/tasks/OpenBSD.yml new file mode 100644 index 00000000..1a04a3d3 --- /dev/null +++ b/roles/core/admin-users/tasks/OpenBSD.yml @@ -0,0 +1,12 @@ +--- +- name: install sudo + openbsd_pkg: + name: sudo-- + state: present + +- name: allow wheel group to use sudo + lineinfile: + regexp: '^#?\s*%wheel(\s+)ALL=\(ALL\) SETENV: ALL$' + line: '%wheel\1ALL=(ALL) SETENV: ALL' + backrefs: yes + dest: /etc/sudoers diff --git a/roles/core/admin-users/tasks/main.yml b/roles/core/admin-users/tasks/main.yml new file mode 100644 index 00000000..c8a4c756 --- /dev/null +++ b/roles/core/admin-users/tasks/main.yml @@ -0,0 +1,37 @@ +--- +- name: load os/distrubtion/version specific variables + include_vars: "{{ item }}" + with_first_found: + - files: + - "{{ ansible_distribution_release }}.yml" + - "{{ ansible_distribution }}.yml" + - "{{ ansible_os_family }}.yml" + +- name: load os/distrubtion/version specific tasks + vars: + params: + files: + - "{{ ansible_distribution_release }}.yml" + - "{{ ansible_distribution }}.yml" + - "{{ ansible_os_family }}.yml" + loop: "{{ q('first_found', params) }}" + loop_control: + loop_var: tasks_file + include_tasks: "{{ tasks_file }}" + +- name: add admin users + loop: "{{ admin_users_group | union(admin_users_host) }}" + user: + name: "{{ item }}" + state: present + password: "{{ user_passwords[item] }}" + groups: "{{ admin_users_groups }}" + append: yes + shell: "{{ users[item].shell | default(admin_users_default_shell) }}" + +- name: install ssh keys for admin users + loop: "{{ admin_users_group | union(admin_users_host) }}" + authorized_key: + user: "{{ item }}" + key: "{{ users[item].ssh | join('\n') }}" + exclusive: yes |