2020-02-12 04:17:43 +00:00
|
|
|
---
|
2020-03-18 02:49:57 +00:00
|
|
|
- import_playbook: meta.yml
|
|
|
|
|
|
|
|
- name: Configure system authentication
|
|
|
|
hosts: all
|
2020-02-12 04:26:05 +00:00
|
|
|
roles:
|
|
|
|
- role: sshd
|
|
|
|
tasks:
|
2020-03-18 02:49:57 +00:00
|
|
|
- import_tasks: tasks/preprocess-users.yml
|
2020-02-12 04:26:05 +00:00
|
|
|
|
|
|
|
- name: Create local user accounts
|
|
|
|
tags: users_create
|
|
|
|
become: true
|
|
|
|
block:
|
|
|
|
- name: Create groups
|
|
|
|
group:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: present
|
2020-03-18 02:49:57 +00:00
|
|
|
loop: "{{ omni_local_targets + ['omni'] }}"
|
2020-02-12 04:26:05 +00:00
|
|
|
|
|
|
|
- name: Load user passwords
|
|
|
|
include_vars:
|
|
|
|
file: secrets/passwords.yml
|
|
|
|
|
|
|
|
- name: Create users
|
|
|
|
user:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
comment: "{{ item.fullname | default('') }}"
|
|
|
|
shell: /bin/bash
|
2020-03-18 02:49:57 +00:00
|
|
|
groups: "{{ item.targets | intersect(omni_local_targets) + ['omni'] }}"
|
|
|
|
system: "{{ item.svc | default(false) }}"
|
2020-02-12 04:26:05 +00:00
|
|
|
state: present
|
|
|
|
generate_ssh_key: false
|
2020-03-18 02:49:57 +00:00
|
|
|
password: "{{ omni_users_secrets[item.name] }}"
|
|
|
|
loop: "{{ _users_local }}"
|
2020-02-12 04:26:05 +00:00
|
|
|
|
|
|
|
- name: Delete removed user accounts
|
|
|
|
become: true
|
|
|
|
user:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: absent
|
2020-03-18 02:49:57 +00:00
|
|
|
loop: "{{ _users_local_removed | default([]) | difference(omni_protected_users) }}"
|
2020-02-12 04:26:05 +00:00
|
|
|
|
|
|
|
- name: Grant sudo permissions to admin user accounts
|
|
|
|
become: true
|
|
|
|
user:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
groups: "{{ 'wheel' if ansible_os_family | lower == 'redhat' else 'sudo' }}"
|
|
|
|
state: present
|
2020-03-18 02:49:57 +00:00
|
|
|
loop: "{{ _users_local_admin }}"
|
2020-02-12 04:26:05 +00:00
|
|
|
|
|
|
|
- name: Disable sudo password for ansible
|
|
|
|
become: true
|
|
|
|
lineinfile:
|
|
|
|
create: true
|
|
|
|
path: /etc/sudoers.d/30-ansible
|
|
|
|
line: "ansible ALL=(ALL) NOPASSWD:ALL"
|
|
|
|
mode: 0644
|
|
|
|
|
|
|
|
- name: Disable sudo password for admin users
|
|
|
|
become: true
|
|
|
|
lineinfile:
|
|
|
|
create: true
|
|
|
|
path: /etc/sudoers.d/40-admin
|
|
|
|
line: "{{ item.name }} ALL=(ALL) NOPASSWD:ALL"
|
|
|
|
mode: 0644
|
2020-03-18 02:49:57 +00:00
|
|
|
state: "{{ 'present' if omni_disable_sudo_password | default(false) | bool == true else 'absent' }}"
|
|
|
|
loop: "{{ _users_local_admin }}"
|
2020-02-12 04:26:05 +00:00
|
|
|
|
|
|
|
- name: Ensure proper ownership of user home directories
|
|
|
|
become: true
|
|
|
|
file:
|
|
|
|
group: "{{ item.name }}"
|
|
|
|
owner: "{{ item.name }}"
|
|
|
|
path: /home/{{ item.name }}
|
|
|
|
recurse: true
|
|
|
|
state: directory
|
2020-03-18 02:49:57 +00:00
|
|
|
loop: "{{ _users_local }}"
|
|
|
|
|
|
|
|
- import_tasks: tasks/deploy-ssh-keys.yml
|