Files
ansible_uni_deploy/roles/create_user/tasks/main.yml
warezjoe 5bbc551106 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.
2026-01-26 11:54:00 +01:00

49 lines
1.1 KiB
YAML

---
# tasks file for create_user
- name: Adding group
ansible.builtin.group:
name: "{{ primary_group }}"
gid: "{{ gid }}"
state: present
when: gid != 65534
- name: Adding user
ansible.builtin.user:
name: "{{ user }}"
group: "{{ primary_group }}"
uid: "{{ uid }}"
shell: "{{ shell }}"
groups: "{{ secondary_groups }}"
home: "{{ home }}"
password: "{{ password }}"
create_home: "{{ create_home }}"
- name: Dowload ssh key
ansible.builtin.uri:
url: "{{ user_ssh_key_url }}"
method: GET
return_content: true
register: ssh_key
when: user_ssh_key_url is defined
- name: Setting ssh key
ansible.builtin.blockinfile:
state: present
owner: "{{ user }}"
group: "{{ primary_group }}"
insertafter: EOF
path: /home/{{ user }}/.ssh/authorized_keys
mode: '0644'
create: true
block: |
{{ ssh_key.content }}
when: user_ssh_key_url is defined
- name: Set permissions to .ssh folder
ansible.builtin.file:
path: /home/{{ user }}/.ssh
owner: "{{ user }}"
group: "{{ primary_group }}"
mode: '0711'
when: user_ssh_key_url is defined