formatting
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
---
|
||||
|
||||
- name: Ensure sudo is installed
|
||||
package:
|
||||
ansible.builtin.package:
|
||||
name: sudo
|
||||
|
||||
- name: Fail if removing the current user
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: Refusing to delete the user used to run this play
|
||||
when:
|
||||
- item.name == ansible_user_id
|
||||
@@ -15,7 +15,7 @@
|
||||
become: false
|
||||
|
||||
- name: Ensure users in correct state
|
||||
user:
|
||||
ansible.builtin.user:
|
||||
name: "{{ item.name }}"
|
||||
password: "{{ item.password }}"
|
||||
shell: "{{ item.shell | default('/bin/bash') }}"
|
||||
@@ -25,14 +25,14 @@
|
||||
loop: "{{ users }}"
|
||||
|
||||
- name: Set ssh authorized keys for users
|
||||
authorized_key:
|
||||
ansible.posix.authorized_key:
|
||||
user: "{{ item.name }}"
|
||||
key: "{{ item.ssh_pubkey }}"
|
||||
when: item.state | default('present') == 'present'
|
||||
loop: "{{ users }}"
|
||||
|
||||
- name: Disable login as root with ssh key
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: /root/.ssh/authorized_keys
|
||||
state: absent
|
||||
when: ansible_user | default('') != 'root'
|
||||
|
||||
Reference in New Issue
Block a user