core: Swap to ansible roles for config
Signed-off-by: Noah Knegt <git@noahknegt.com>
This commit is contained in:
48
roles/base/tasks/users/ansible.yml
Normal file
48
roles/base/tasks/users/ansible.yml
Normal file
@@ -0,0 +1,48 @@
|
||||
#===================================================================================================
|
||||
# ? ABOUT
|
||||
# @author : Noah Knegt
|
||||
# @email : personal@noahknegt.com
|
||||
# @repo : https://git.noahknegt.com/noah.knegt/ansible-automations
|
||||
# @createdOn : 27-02-2023
|
||||
# @description : It contains the tasks to properly configure the ansible user.
|
||||
#===================================================================================================
|
||||
|
||||
---
|
||||
- name: Add ansible group
|
||||
group:
|
||||
name: ansible
|
||||
state: present
|
||||
|
||||
- name: Add new ansible user
|
||||
user:
|
||||
name: ansible
|
||||
group: ansible
|
||||
groups: ansible,{{ sudo_group }}
|
||||
password: "{{ ansible_password }}"
|
||||
state: present
|
||||
shell: /bin/bash
|
||||
|
||||
- name: Add ansible user to sudoers
|
||||
copy:
|
||||
src: files/ansible_sudoers
|
||||
dest: /etc/sudoers.d/ansible
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0440
|
||||
|
||||
- name: Create .ssh directory
|
||||
file:
|
||||
path: /home/ansible/.ssh
|
||||
state: directory
|
||||
owner: ansible
|
||||
group: ansible
|
||||
mode: 0700
|
||||
with_items:
|
||||
- { dir: /home/ansible/.ssh }
|
||||
|
||||
- name: Copy ssh public key
|
||||
authorized_key:
|
||||
user: ansible
|
||||
key: "{{ item }}"
|
||||
with_file:
|
||||
- ansible/ansible.pub
|
Reference in New Issue
Block a user