mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-30 07:18:09 +02:00
Removed default setup of static homepage
This commit is contained in:
33
roles/nginx-static-repository/README.md
Normal file
33
roles/nginx-static-repository/README.md
Normal 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.
|
3
roles/nginx-static-repository/meta/main.yml
Normal file
3
roles/nginx-static-repository/meta/main.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
dependencies:
|
||||
- nginx-https
|
||||
- git
|
16
roles/nginx-static-repository/tasks/main.yml
Normal file
16
roles/nginx-static-repository/tasks/main.yml
Normal 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
|
26
roles/nginx-static-repository/templates/static.nginx.conf.j2
Normal file
26
roles/nginx-static-repository/templates/static.nginx.conf.j2
Normal 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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user