Workshop Tag 1
This commit is contained in:
parent
e9383e3eda
commit
896ed4fcb7
5 changed files with 192 additions and 2 deletions
31
playbooks/prepare_automation_user.yml
Normal file
31
playbooks/prepare_automation_user.yml
Normal 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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue