summaryrefslogtreecommitdiff
path: root/roles/admin-user/tasks/main.yml
blob: 5933863dc572ac6e29575ef40cd2995f4d60a978 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
---
- name: install sudo
  apt:
    name: sudo
    state: present

- name: add admin users
  with_items: "{{ admin_user_group | default([]) | union(admin_user_host | default([])) }}"
  user:
    name: "{{ item.name }}"
    state: present
    password: "{{ item.password }}"
    groups:
    - sudo
    - adm
    append: yes
    shell: "{{ item.shell | default(omit) }}"
  loop_control:
    label: "{{ item.name }}"

- name: install ssh keys for admin users
  with_items: "{{ admin_user_group | default([]) | union(admin_user_host | default([])) }}"
  authorized_key:
    user: "{{ item.name }}"
    key: "{{ item.ssh_keys | join('\n') }}"
    exclusive: yes
  loop_control:
    label: "{{ item.name }}"