Ansible/misc/tasks/user.yml

33 lines
872 B
YAML
Raw Normal View History

2022-02-14 00:02:14 +00:00
---
- name: Create provisioning user
hosts: all
become: true
gather_facts: false
tasks:
- name: Create user
ansible.builtin.user:
name: "{{ ansible_default_user }}"
comment: Automation user for ansible
state: present
append: yes
system: True
create_home: True
- name: Generate master SSH key
community.crypto.openssh_keypair:
path: "/home/{{ ansible_default_user }}/.ssh/{{ ssh_key_filename }}"
type: rsa
size: 4096
state: present
force: no
tags:
- init
- name: Deploy SSH public key
ansible.posix.authorized_key:
user: "{{ ansible_default_user }}"
state: present
key: "{{ lookup('file', '/home/{{ ansible_default_user }}/.ssh/{{ ssh_key_filename }}.pub') }}"
when: "'init' not in ansible_run_tags"