You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible-homelab/ansible/homelab/tasks/install-sudo-tasks.yml

27 lines
625 B
YAML

---
# https://stackoverflow.com/questions/37333305/ansible-create-a-user-with-sudo-privileges
- name: Install Sudo
apt:
pkg:
- sudo
state: latest
update_cache: true
- name: Make sure we have a 'cianhatton' group
group:
name: cianhatton
state: present
- name: Allow 'cianhatton' group to have passwordless sudo
lineinfile:
dest: /etc/sudoers
state: present
regexp: '^%cianhatton'
line: '%cianhatton ALL=(ALL) NOPASSWD: ALL'
validate: 'visudo -cf %s'
- name: Add User
ansible.builtin.user:
name: cianhatton
comment: Cian Hatton
uid: 1000
group: cianhatton