ansible-playbook-static-sit.../roles/static-server/tasks/setup_site.yml
2023-11-10 14:21:47 +01:00

22 lines
1.1 KiB
YAML

- name: Create site user group
ansible.builtin.group: name="{{ site.user }}" state=present
- name: Create site user
user: name="{{ site.user }}" shell=/bin/bash home="{{ static_site_server_base_path }}/{{ site.user }}" createhome=yes group="{{ site.user }}" groups= state=present
- name: Ensure public path is present
ansible.builtin.file: path="{{ static_site_server_base_path }}/{{ site.user }}/public" owner="{{ site.user }}" group="{{ site.user }}" mode=0700 state=directory
- name: Ensure .ssh path is present
ansible.builtin.file: path="{{ static_site_server_base_path }}/{{ site.user }}/.ssh" owner="{{ static_site_user }}" group="{{ static_site_group }}" mode=0700 state=directory
- name: Seting up authorized keys
ansible.posix.authorized_key:
user: "{{ site.user }}"
key: "{{ site.key }}"
state: present
- name: Ensure correct permissions for authorized keys file
ansible.builtin.file: path="{{ static_site_server_base_path }}/{{ site.user }}/.ssh/authorized_keys" owner="{{ static_site_user }}" group="{{ static_site_group }}" mode=0600 state=file