Switching user management solution
This commit is contained in:
parent
82dffd5b1d
commit
c83cad2e88
17 changed files with 51 additions and 80 deletions
24
README.md
24
README.md
|
@ -10,30 +10,6 @@ If the "base_core_hostname" variable is defined, it is recommended to set the an
|
|||
| ----------------------- | ------------------------------------------------------------- |
|
||||
| ansible_ssh_common_args | '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' |
|
||||
|
||||
## Role Variables
|
||||
|
||||
### Core Variables
|
||||
|
||||
| Variable | Default | Choices | Comments |
|
||||
| -------------------------------------------- | ------------- | ----------- | ------------------------------------------------------------------------------- |
|
||||
| base_core_cert_common_name | nodename | | Common name for created self-signed cert |
|
||||
| base_core_firewall_configure | True | True, False | Allows the firewall to be configured |
|
||||
| base_core_hostname | "" | | Defines the computer hostname |
|
||||
| base_core_install_updates | True | True, False | Install all available updates for the distro at runtime |
|
||||
| base_core_management_user | ansible_user | | Defines the account that ansible will use for management in the future |
|
||||
| base_core_management_user_disable_password | False | True, False | When enabled the password for the management user account will be disabled |
|
||||
| base_core_motd_banner | "" | | Banner to be added to MOTD if desired |
|
||||
| base_core_motd_configure | True | True, False | Allows the MOTD to be configured |
|
||||
| base_core_root_ca_basename | "" | | Basename of the cert for local system reference |
|
||||
| base_core_root_ca_convert | False | True, False | Converts the defined certificate from DER to PEM type |
|
||||
| base_core_root_ca_url | "" | | URL of a Root CA to install |
|
||||
| base_core_secondary_user | "" | | Defines a secondary account that ansible configure for management in the future |
|
||||
| base_core_secondary_user_disable_password | False | True, False | When enabled the password for the secondary user account will be disabled |
|
||||
| base_core_ssh_permit_password_authentication | False | True, False | Permits the use of passwords for ssh |
|
||||
| base_core_ssh_permit_root_login | False | True, False | Permits the use of root logins for ssh |
|
||||
| base_core_timezone | America/Boise | | Defines the timezone to apply to the client |
|
||||
| base_core_web_management | False | True, False | Enables installation of the Cockpit web management package(s) |
|
||||
|
||||
## Example
|
||||
|
||||
Execute playbook with needed variables
|
||||
|
|
|
@ -8,17 +8,13 @@
|
|||
# General
|
||||
# =======
|
||||
|
||||
# User that should be configured for future management
|
||||
base_core_management_user: "{{ ansible_user }}"
|
||||
|
||||
# Secondary user that may be configured for future management
|
||||
base_core_secondary_user: ""
|
||||
|
||||
# If enabled, the password for the management user account will be disabled
|
||||
base_core_management_user_disable_password: false
|
||||
|
||||
# If enabled, the password for the secondary user account will be disabled
|
||||
base_core_secondary_user_disable_password: false
|
||||
# Users that should be configured for future management
|
||||
base_users: []
|
||||
#- username: "{{ ansible_user }}"
|
||||
# password: ""
|
||||
# disable_password: false
|
||||
# ssh_keys: []
|
||||
# ssh_keys_force: false # setting ssh_keys_force to true will overwrite the authorized_keys file to only be the ssh keys provided
|
||||
|
||||
# Install all available updates at runtime
|
||||
base_core_install_updates: true
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
ecdsa-sha2-nistp521 AAAAE2VjZHNhLXNoYTItbmlzdHA1MjEAAAAIbmlzdHA1MjEAAACFBACzgUaiXanC7LIMR2JHlNjqHdscstjUQ4ZMJOG9ndZY2Ml81g+KPSUQHsmEAO+24TBVc/EpmeU3iMX4BO6XhUEhRACIAfyxW0zZWBZlO46TWf+oMcH6CQNQHubEpxqGvZd8A0tNxI2npzOEW6b3mKDGd1Z60yBPjNr5KZWVcJePPMwjaw== ansible_awx
|
|
@ -1 +0,0 @@
|
|||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEAccPXNMwyNb4UW2P3MyxRGH2xDrOHKOkW0/2DGuNJq as-awx-workstation
|
|
@ -1 +0,0 @@
|
|||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJoxKs7UgLr/6zVzZLSbqMUfHtrAtg93qRwEEXFAMqfR thale-bw-curve25519
|
|
@ -1 +0,0 @@
|
|||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCt6oTKMmZBQB9tS4ucEHZsDEZnBvcQiFeqfW31UjSbMRzKMqQwhOxqM6ezBvIJwlbAsR8p6tpGtl7lVOoOpQtUYBN8sPHHIr4hs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qFu5V5LB+PxQG2MHFAGXJrquf2SpuZpzA thale-work-curve25519
|
|
@ -1 +0,0 @@
|
|||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDCVb3OxjvY9QAPUgrxc9X6h1KpCyyefh8SgBSARJZRwKTHL/HkzL05/5iCX0eeDe7cTsvU9O3lKTKKDh+6ZbJTEuiKlp7XPIGuXL6VCNTkz6yMHy0zQhKW/0VnvIZjHt7Y+evh8wa5SHpZz2ka80pohG9zea4ylqMjfWnxAwbNBwen/o/Owss94tQH1aJIpA8BNwPSqTCDqgcVX8w4d9D3ERMrmp1DaZVU6NlFJ5Pk4acZ9piIOI42Dwb9pqAiOVzQceIEG2RRKyAahNB1iRX9q+jHxAnhh1hv/tKs/i3J5gzlN83WVJLNL70RpMyMI2Tp8Gr3mJkU56/RJkN6OHPOIO066I9psTzTBHMFDjUAvl30STPdsHsX1Ejel3KWVbpkzxiFvVbQfI3/f5g008PvGgRX0/x4UOrNSp8hPCxd//GmoAuxFcJqCN9vrJxL9xiG6JWNe7LDokTeQu+F/M8eXj6wcBs9Jnu4Fmpmx5UROmU/T2+manQnySC34a7AnzzXueH/ysA7iteE6abIMnUJ9zmRZZk624MJzerrbFIf1qHrQWZ8fJ3BPZ9UXNJL945suny0aHnHIMJT/ojPfdJDc62rKxYP7WFeDRM5kOjdnOIZpAaBEcWeykWL5gV8pl+7m3EEDHHbUizrthFlOMgdScPMrkm+jGjDsvzEKKEttw== thale-work-rsa
|
|
@ -27,6 +27,17 @@
|
|||
pool: '^(Red Hat Enterprise Server|Red Hat Virtualization)$'
|
||||
when: ansible_distribution == 'RedHat' and (base_redhat_subscription_org_id != "" and base_redhat_subscription_activationkey != "")
|
||||
|
||||
- name: "*** Users Configuration ***"
|
||||
include_tasks:
|
||||
file: core_users.yml
|
||||
apply:
|
||||
tags: users
|
||||
loop: "{{ base_users }}"
|
||||
loop_control:
|
||||
loop_var: user
|
||||
tags:
|
||||
- users
|
||||
|
||||
- name: "*** MOTD Configuration ***"
|
||||
include_tasks:
|
||||
file: core_motd.yml
|
||||
|
@ -77,15 +88,3 @@
|
|||
when: base_core_web_management == true
|
||||
tags:
|
||||
- web_management
|
||||
|
||||
- name: Disable password for management account
|
||||
user:
|
||||
name: "{{ base_core_management_user }}"
|
||||
password_lock: yes
|
||||
when: base_core_management_user_disable_password == true
|
||||
|
||||
- name: Disable password for secondary management account
|
||||
user:
|
||||
name: "{{ base_core_secondary_user }}"
|
||||
password_lock: yes
|
||||
when: base_core_secondary_user != "" and base_core_secondary_user_disable_password == true
|
||||
|
|
|
@ -18,27 +18,6 @@
|
|||
tags:
|
||||
- issue
|
||||
|
||||
- name: Setup authorized keys
|
||||
authorized_key:
|
||||
user: "{{ base_core_management_user }}"
|
||||
state: present
|
||||
key: '{{ lookup("file", item) }}'
|
||||
with_fileglob:
|
||||
- "public_keys/*"
|
||||
tags:
|
||||
- authorized_key
|
||||
|
||||
- name: Setup authorized keys for secondary user
|
||||
authorized_key:
|
||||
user: "{{ base_core_secondary_user }}"
|
||||
state: present
|
||||
key: '{{ lookup("file", item) }}'
|
||||
with_fileglob:
|
||||
- "public_keys/*"
|
||||
when: base_core_secondary_user != ""
|
||||
tags:
|
||||
- authorized_key
|
||||
|
||||
- name: Configure SSH root login
|
||||
lineinfile:
|
||||
path: /etc/ssh/sshd_config
|
||||
|
|
33
roles/base/tasks/core_users.yml
Normal file
33
roles/base/tasks/core_users.yml
Normal file
|
@ -0,0 +1,33 @@
|
|||
---
|
||||
# file: roles/base/tasks/core_users.yml
|
||||
|
||||
- name: "{{ user.username }} user setup"
|
||||
user:
|
||||
name: "{{ user.username }}"
|
||||
password_lock: "{{ user.disable_password | default(false) }}"
|
||||
|
||||
- name: "Configure {{ user.username }} password"
|
||||
user:
|
||||
name: "{{ user.username }}"
|
||||
password: "{{ user.password | default('*') }}"
|
||||
when: user.password is defined
|
||||
|
||||
- name: "Setup {{ user.username }} authorized keys"
|
||||
authorized_key:
|
||||
user: "{{ user.username }}"
|
||||
state: present
|
||||
key: "{{ user.ssh_keys | join('\n') }}"
|
||||
exclusive: "{{ user.ssh_keys_force | default('false') }}"
|
||||
tags:
|
||||
- authorized_key
|
||||
when: ( user.ssh_keys is defined ) and ( user.ssh_keys is not url )
|
||||
|
||||
- name: "Setup {{ user.username }} authorized keys from url"
|
||||
authorized_key:
|
||||
user: "{{ user.username }}"
|
||||
state: present
|
||||
key: "{{ user.ssh_keys }}"
|
||||
exclusive: "{{ user.ssh_keys_force | default('false') }}"
|
||||
tags:
|
||||
- authorized_key
|
||||
when: ( user.ssh_keys is defined ) and ( user.ssh_keys is url )
|
Loading…
Add table
Reference in a new issue