Refactor: Organize Ansible project structure
- Reorganized Ansible project structure to follow best practices. - Created dedicated directories: , , , , and . - Categorized playbooks into (host-specific) and (service-specific). - Moved all roles into the directory and standardized their naming conventions. - Relocated to for better variable management. - Renamed to to reflect its global variable scope. - Created to correctly set the to the new directory. - Moved and into the directory. - Added to providing explanations for common commands. - Cleaned up directories from all individual roles to centralize version control.
This commit is contained in:
27
roles/linux_config_init/tasks/create_user.yml
Normal file
27
roles/linux_config_init/tasks/create_user.yml
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
- name: Adding user
|
||||
ansible.builtin.user:
|
||||
name: "{{ user }}"
|
||||
uid: "{{ uid }}"
|
||||
shell: /bin/bash
|
||||
groups: sudo
|
||||
|
||||
- name: Setting ssh key
|
||||
ansible.builtin.blockinfile:
|
||||
state: present
|
||||
owner: "{{ user }}"
|
||||
group: "{{ user }}"
|
||||
insertafter: EOF
|
||||
path: /home/{{ user }}/.ssh/authorized_keys
|
||||
mode: "0644"
|
||||
create: true
|
||||
block: |
|
||||
{{ ssh_key }}
|
||||
when: ssh_key is defined
|
||||
|
||||
- name: Set permissions to .ssh folder
|
||||
ansible.builtin.file:
|
||||
path: /home/{{ user }}/.ssh
|
||||
owner: "{{ user }}"
|
||||
group: "{{ user }}"
|
||||
mode: "0711"
|
||||
Reference in New Issue
Block a user