31 lines
851 B
YAML
31 lines
851 B
YAML
---
|
|
- name: Prepare Server for Ansible automation
|
|
hosts: all
|
|
gather_facts: false
|
|
tasks:
|
|
- name: Create automation user
|
|
become: true
|
|
ansible.builtin.user:
|
|
name: "{{ automation_user }}"
|
|
home: "/home/{{ automation_user }}"
|
|
shell: "/bin/bash"
|
|
state: present
|
|
|
|
- name: Set authorized key for user ansible copying it from current user
|
|
ansible.posix.authorized_key:
|
|
user: "{{ automation_user }}"
|
|
state: present
|
|
manage_dir: true
|
|
key: "{{ item }}"
|
|
loop: "{{ automation_keys }}"
|
|
|
|
- name: Create sudo rules for automation
|
|
become: true
|
|
ansible.builtin.copy:
|
|
dest: "/etc/sudoers.d/{{ automation_user }}"
|
|
content: |
|
|
{{ automation_user }} ALL=(ALL) NOPASSWD: ALL
|
|
owner: root
|
|
group: root
|
|
mode: 0640
|
|
|