22 lines
546 B
YAML
22 lines
546 B
YAML
---
|
|
- name: Create user 'cody' with sudo permissions
|
|
hosts: all
|
|
become: true
|
|
vars:
|
|
user_name: "cody"
|
|
user_password: "temppass1"
|
|
tasks:
|
|
- name: Create user 'cody'
|
|
user:
|
|
name: "{{ user_name }}"
|
|
password: "{{ user_password | password_hash('sha512') }}"
|
|
shell: /bin/bash
|
|
createhome: yes
|
|
|
|
- name: Add 'cody' to sudo group
|
|
lineinfile:
|
|
path: /etc/sudoers
|
|
line: "{{ user_name }} ALL=(ALL) ALL"
|
|
validate: 'visudo -cf %s'
|
|
state: present
|
|
backup: yes |