2018-11-28 02:51:33 +00:00
|
|
|
---
|
2018-12-13 04:52:32 +00:00
|
|
|
- import_playbook: dependencies.yml
|
|
|
|
|
2019-09-27 06:59:11 +00:00
|
|
|
- hosts: all:!network
|
2019-09-01 17:43:53 +00:00
|
|
|
name: Update local user accounts and access controls
|
2018-12-11 05:48:37 +00:00
|
|
|
tasks:
|
2018-12-22 18:55:36 +00:00
|
|
|
- import_tasks: tasks/users-preprocessing.yml
|
2018-12-11 05:48:37 +00:00
|
|
|
|
2018-12-13 04:52:32 +00:00
|
|
|
- name: Create local user accounts
|
|
|
|
tags: users_create
|
2018-12-14 03:30:40 +00:00
|
|
|
become: true
|
2018-12-13 04:52:32 +00:00
|
|
|
block:
|
2018-12-11 05:48:37 +00:00
|
|
|
- name: Create groups
|
|
|
|
group:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: present
|
2019-09-01 17:43:53 +00:00
|
|
|
loop: "{{ targets + ['omni'] }}"
|
2018-12-11 05:48:37 +00:00
|
|
|
|
|
|
|
- name: Create users
|
|
|
|
user:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
comment: "{{ item.fullname | default('') }}"
|
|
|
|
shell: /bin/bash
|
2019-09-27 06:59:11 +00:00
|
|
|
groups: "{{ item.targets | intersect(targets) + ['omni'] }}"
|
|
|
|
system: "{{ item.svc | default(False) }}"
|
2018-12-11 05:48:37 +00:00
|
|
|
state: present
|
2019-09-27 06:59:11 +00:00
|
|
|
generate_ssh_key: "{{ True if generate_keys | bool == true else False }}"
|
2018-12-13 04:52:32 +00:00
|
|
|
ssh_key_comment: "{{ item.name }}@{{ inventory_hostname }}"
|
|
|
|
ssh_key_bits: 4096
|
2019-09-01 17:43:53 +00:00
|
|
|
ssh_key_type: ed25519
|
2018-12-11 05:48:37 +00:00
|
|
|
password: "{{ item.password }}"
|
2019-09-27 06:59:11 +00:00
|
|
|
loop: "{{ local_users }}"
|
2018-12-14 03:30:40 +00:00
|
|
|
|
2019-09-27 06:59:11 +00:00
|
|
|
- name: Delete removed user accounts
|
|
|
|
become: true
|
|
|
|
user:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: absent
|
|
|
|
loop: "{{ local_removed_users | difference(protected_users) }}"
|
2018-12-11 05:48:37 +00:00
|
|
|
|
2019-09-27 06:59:11 +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
|
|
|
|
loop: "{{ local_admin_users }}"
|
2018-12-11 05:48:37 +00:00
|
|
|
|
2019-09-27 06:59:11 +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
|
2018-12-11 05:48:37 +00:00
|
|
|
|
2019-09-27 06:59:11 +00:00
|
|
|
- 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
|
|
|
|
state: "{{ 'absent' if disable_sudo_password | bool == false else 'present' }}"
|
|
|
|
loop: "{{ local_admin_users }}"
|
2018-12-11 05:48:37 +00:00
|
|
|
|
|
|
|
- name: Configure GNOME
|
2018-12-13 04:52:32 +00:00
|
|
|
tags: users_gnome
|
2019-09-27 06:59:11 +00:00
|
|
|
when: ansible_distribution == "Fedora" and disable_gnome_user_list | bool == true
|
2019-09-01 17:43:53 +00:00
|
|
|
become: true
|
2018-12-11 05:48:37 +00:00
|
|
|
block:
|
|
|
|
- name: Configure GDM profile
|
|
|
|
blockinfile:
|
2019-09-27 06:59:11 +00:00
|
|
|
create: true
|
|
|
|
path: /etc/dconf/profile/gdm
|
2018-12-11 05:48:37 +00:00
|
|
|
block: |
|
|
|
|
user-db:user
|
|
|
|
system-db:gdm
|
|
|
|
file-db:/usr/share/gdm/greeter-dconf-defaults
|
|
|
|
- name: Configure GDM keyfile
|
|
|
|
blockinfile:
|
2019-03-03 18:23:15 +00:00
|
|
|
create: true
|
2018-12-11 05:48:37 +00:00
|
|
|
path: /etc/dconf/db/gdm.d/00-login-screen
|
|
|
|
block: |
|
|
|
|
[org/gnome/login-screen]
|
|
|
|
# Do not show the user list
|
|
|
|
disable-user-list=true
|
|
|
|
- name: Delete existing user database
|
2018-12-13 04:52:32 +00:00
|
|
|
file:
|
|
|
|
path: /var/lib/gdm/.config/dconf/user
|
|
|
|
state: absent
|
2018-12-11 05:48:37 +00:00
|
|
|
- name: Restart dconf database
|
|
|
|
shell: dconf update
|
2018-12-13 04:52:32 +00:00
|
|
|
|
|
|
|
- name: Ensure proper ownership of user home directories
|
|
|
|
become: true
|
|
|
|
file:
|
|
|
|
group: "{{ item.name }}"
|
|
|
|
owner: "{{ item.name }}"
|
|
|
|
path: /home/{{ item.name }}
|
2019-09-27 06:59:11 +00:00
|
|
|
recurse: true
|
2018-12-13 04:52:32 +00:00
|
|
|
state: directory
|
2019-09-27 06:59:11 +00:00
|
|
|
loop: "{{ local_users }}"
|
2018-12-31 03:54:33 +00:00
|
|
|
|
2019-09-27 06:59:11 +00:00
|
|
|
# - hosts: router.net.enp.one
|
|
|
|
# name: Configure users on router
|
|
|
|
# connection: network_cli
|
|
|
|
# vars:
|
|
|
|
# ansible_network_os: edgeos
|
|
|
|
# tasks:
|
|
|
|
# - import_tasks: tasks/users-preprocessing.yml
|
|
|
|
#
|
|
|
|
# - name: Create users
|
|
|
|
# edgeos_config:
|
|
|
|
# lines:
|
|
|
|
# - set system login user {{ item.name }} authentication encrypted-password "{{ item.password }}"
|
|
|
|
# - set system login user {{ item.name }} full-name "{{ item.fullname if item.fullname is defined else "" }}"
|
|
|
|
# - set system login user {{ item.name }} level {{ 'operator' if item.name != 'ansible' else 'admin' }}
|
|
|
|
# loop: "{{ local_users | difference([None]) }}"
|
|
|
|
#
|
|
|
|
# - name: Grant administrative access to admin users
|
|
|
|
# edgeos_config:
|
|
|
|
# lines:
|
|
|
|
# - set system login user {{ item.name }} level admin
|
|
|
|
# loop: "{{ local_admin_users | difference([None]) }}"
|
|
|
|
#
|
|
|
|
# - name: Assemble key files for loadkey usage
|
|
|
|
# edgeos_command:
|
|
|
|
# commands: sudo tee /tmp/{{ item.name }}.keys<<<"{{ item.sshkeys | join('\n') }}"
|
|
|
|
# loop: "{{ local_admin_users | difference([None]) }}"
|
|
|
|
#
|
|
|
|
# - import_playbook: deploy-sshkeys.yml
|