lab-ansible/roles/common/tasks/users.yml

28 lines
600 B
YAML
Raw Normal View History

2023-10-28 23:00:05 +00:00
# vim: ft=yaml.ansible
2023-10-29 19:46:52 +00:00
# code: language=ansible
2023-10-28 23:00:05 +00:00
---
- name: Add users
ansible.builtin.user:
name: "{{ item.name }}"
comment: "{{ item.comment }}"
groups: "{{ item.groups }}"
shell: /bin/bash
2023-11-05 18:08:26 +00:00
state: present
2023-10-28 23:00:05 +00:00
loop: "{{ users }}"
2023-11-11 15:35:14 +00:00
- name: Add SSH keys to users
2023-10-28 23:00:05 +00:00
ansible.posix.authorized_key:
user: "{{ item.name }}"
key: "{{ item.ssh_keys | join('\n') }}"
exclusive: true
loop: "{{ users }}"
2023-11-11 15:35:14 +00:00
2023-11-11 15:41:47 +00:00
- name: Allow passwordless sudo
community.general.sudoers:
name: passwordless
group: sudo
host: ALL
commands: ALL
nopassword: true
2023-11-11 15:35:14 +00:00
state: present