Workshop Tag 1

This commit is contained in:
Frank Agerholm 2026-07-10 18:23:53 +02:00
commit 896ed4fcb7
No known key found for this signature in database
5 changed files with 192 additions and 2 deletions

View file

@ -0,0 +1,31 @@
---
- 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