Initial commit

This commit is contained in:
2023-11-10 14:21:47 +01:00
commit 4a08e4aa37
13 changed files with 917 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
---
- name: Ensure Static Sits are setup
ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_site.yml"
with_items: "{{ static_sites }}"
loop_control:
loop_var: site
no_log: true

View File

@@ -0,0 +1,22 @@
---
- name: Run static_site_server installation tasks
tags:
- setup-all
- setup-static_site_server
- install-all
- install-static_site_server
block:
- when: static_site_server_enabled | bool
ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml"
- when: static_site_server_enabled | bool
ansible.builtin.include_tasks: "{{ role_path }}/tasks/install.yml"
- name: Run static_site_server uninstallation tasks
tags:
- setup-all
- setup-static_site_server
block:
- when: not static_site_server_enabled | bool
ansible.builtin.include_tasks: "{{ role_path }}/tasks/uninstall.yml"

View File

@@ -0,0 +1,21 @@
- 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

View File

@@ -0,0 +1,8 @@
---
- name: Ensure Static Sits are setup
ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_site.yml"
with_items: "{{ static_sites }}"
loop_control:
loop_var: site
no_log: true

View File

@@ -0,0 +1,9 @@
---
- name: Fail if required static_site_server settings not defined
ansible.builtin.fail:
msg: >
You need to define a required configuration setting (`{{ item }}`).
when: "vars[item] == ''"
with_items:
- static_sites