summaryrefslogtreecommitdiff
path: root/roles/core/admin-users/tasks/main.yml
blob: a5b1c7bd9afb8449e792af68cc1f2cd800d7b141 (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
29
30
31
32
33
34
35
36
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: "{{ hostvars[inventory_hostname]['vault_user_password_'+item] }}" ## TODO: find nicer way to do this
    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