Removed default setup of static homepage

This commit is contained in:
2025-01-16 21:11:34 +01:00
parent 9095b00cfb
commit 12e272af22
8 changed files with 22 additions and 13 deletions

View File

@@ -0,0 +1,33 @@
# Nginx Homepage Role
This Ansible role configures an Nginx server to serve a static homepage. It handles domain configuration, SSL certificate retrieval with Let's Encrypt, and cloning the homepage content from a Git repository.
## Requirements
- Ansible 2.9 or higher
- Nginx installed on the target machine
- Git installed on the target machine (if cloning a repo)
- `nginx-https` and `git` roles available or configured if they are used as dependencies
## Role Variables
- `nginx_homepage_root`: The directory where the homepage content will be stored (default: `/usr/share/nginx/homepage`)
- `domain`: The domain name for the Nginx server configuration
- `administrator_email`: The email used for SSL certificate registration with Let's Encrypt
- `nginx_homepage_repository_address`: The Git repository address containing the homepage content
## Dependencies
- `nginx-https`: A role for setting up an HTTPS server
- `git`: A role for installing Git
## Example Playbook
```yaml
- hosts: servers
roles:
- { role: nginx-static-repository, domain: 'example.com', administrator_email: 'admin@example.com' }
```
## Author Information
This role was created in 2023 by Kevin Veen Birkenbach.

View File

@@ -0,0 +1,3 @@
dependencies:
- nginx-https
- git

View File

@@ -0,0 +1,16 @@
---
- name: "pull homepage from {{nginx_homepage_repository_address}}"
git:
repo: "{{nginx_homepage_repository_address}}"
dest: "{{nginx_homepage_root}}"
update: yes
ignore_errors: true
- name: configure {{top_domain}}.conf
template:
src: "static.nginx.conf.j2"
dest: "{{nginx_servers_directory}}{{top_domain}}.conf"
vars:
domain: "{{top_domain}}"
notify: restart nginx
when: run_once_nginx is not defined

View File

@@ -0,0 +1,26 @@
#default
server
{
server_name {{domain}};
{% include 'roles/letsencrypt/templates/ssl_header.j2' %}
{% if nginx_matomo_tracking | bool %}
{% include 'roles/nginx-matomo-tracking/templates/matomo-tracking.conf.j2' %}
{% endif %}
charset utf-8;
location /
{
root {{nginx_homepage_root}};
index index.html index.htm;
}
location /.well-known/ {
alias {{nginx_well_known_root}};
allow all;
default_type "text/plain";
autoindex on;
}
}