summaryrefslogtreecommitdiff
path: root/roles/admin-user/tasks/main.yml
blob: 53eea376769bf2ee072f4b3f41a3afaa6fc67483 (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
  loop: "{{ admin_user_group | default([]) | union(admin_user_host | default([])) }}"
  loop_control:
    label: "{{ item.name }}"
  user:
    name: "{{ item.name }}"
    state: present
    password: "{{ item.password }}"
    groups:
    - sudo
    - adm
    append: yes
    shell: "{{ item.shell | default(omit) }}"

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