Files
homelab/create_deployment_user.yml
alecsandruchirosca 0ab49c3de6 become
2024-05-02 21:39:08 +03:00

19 lines
544 B
YAML

- name: Create required deployment users
hosts: all
become: yes
become_method: sudo
become_user: root
tasks:
- name: Create Ansible user
user:
name: ansible # Username
groups: sudo
expires: -1
password: "{{ 'mypassword' | password_hash('sha512') }}" # Encrypted password
state: present # Ensure the user is present
createhome: yes # Create the user's home directory
generate_ssh_key: yes # Generate an SSH key pair for the user
ssh_key_bits: 2048
ssh_key_file: .ssh/id_rsa