2026-02-10 09:42:16 +01:00
|
|
|
%YAML 1.2
|
|
|
|
|
---
|
|
|
|
|
version: 1.1
|
|
|
|
|
|
2026-02-10 10:59:30 +01:00
|
|
|
vps_domain_name:
|
|
|
|
|
description: The domain name of the VPS
|
|
|
|
|
examples:
|
|
|
|
|
- example.fr
|
|
|
|
|
|
2026-02-10 09:54:22 +01:00
|
|
|
nginx:
|
2026-02-10 09:59:01 +01:00
|
|
|
description: pedagogic html static file server
|
2026-02-10 10:03:19 +01:00
|
|
|
help: |-
|
2026-02-11 10:46:05 +01:00
|
|
|
This is a complete Ansible playbook to configure Nginx with basic authentication using htpasswd.
|
2026-02-10 10:03:19 +01:00
|
|
|
This playbook installs Nginx, configures a static website, and secures access with basic authentication.
|
2026-02-10 10:08:33 +01:00
|
|
|
|
2026-02-10 10:03:19 +01:00
|
|
|
steps:
|
2026-02-10 10:08:33 +01:00
|
|
|
|
2026-02-10 10:03:19 +01:00
|
|
|
- Installation of Nginx: The playbook installs Nginx and ensures it is started and enabled.
|
|
|
|
|
- Creation of the website directory: A directory is created to host the website files.
|
|
|
|
|
- Creation of a simple homepage: A simple HTML page is created for the website.
|
|
|
|
|
- Installation of apache2-utils: This package is necessary to use the htpasswd command.
|
|
|
|
|
- Creation of the htpasswd file: A .htpasswd file is created with a username and password.
|
|
|
|
|
- Configuration of the Nginx site: The nginx_site.conf.j2 template is used to configure Nginx with basic authentication.
|
|
|
|
|
- Activation of the Nginx site: The site is enabled by creating a symbolic link in the sites-enabled directory.
|
|
|
|
|
- Testing the Nginx configuration: The Nginx configuration is tested before restarting the service.
|
|
|
|
|
- Restarting Nginx: Nginx is restarted to apply the changes.
|
2026-02-10 09:42:16 +01:00
|
|
|
|
2026-02-11 11:08:50 +01:00
|
|
|
dependencies:
|
|
|
|
|
|
|
|
|
|
- ubuntu 24.04 linux distribution
|
|
|
|
|
|
|
|
|
|
|
2026-02-10 09:42:16 +01:00
|
|
|
domain_name:
|
2026-02-10 09:48:09 +01:00
|
|
|
description: domain name
|
|
|
|
|
examples:
|
2026-02-10 10:59:30 +01:00
|
|
|
- example.fr
|
2026-02-10 10:08:33 +01:00
|
|
|
type: domainname
|
2026-02-11 10:48:24 +01:00
|
|
|
default:
|
|
|
|
|
variable: __.vps_domain_name
|
2026-02-10 09:42:16 +01:00
|
|
|
|
|
|
|
|
email:
|
2026-02-10 10:20:51 +01:00
|
|
|
description: email for the domain name
|
|
|
|
|
help: This is for certbot
|
2026-02-10 09:54:22 +01:00
|
|
|
examples:
|
|
|
|
|
- contact@exemple.fr
|
2026-02-10 10:08:33 +01:00
|
|
|
type: mail
|
2026-02-10 09:48:09 +01:00
|
|
|
|
2026-02-10 10:19:14 +01:00
|
|
|
htpasswd_file:
|
2026-02-10 10:53:07 +01:00
|
|
|
description: htpassword user credential file name
|
2026-02-10 10:19:14 +01:00
|
|
|
type: unix_filename
|
2026-02-10 10:53:07 +01:00
|
|
|
params:
|
|
|
|
|
types:
|
|
|
|
|
- file
|
2026-02-11 10:48:24 +01:00
|
|
|
default: /etc/nginx/.htpasswd
|
2026-02-10 10:19:14 +01:00
|
|
|
|
2026-02-10 09:42:16 +01:00
|
|
|
users:
|
2026-02-10 10:53:07 +01:00
|
|
|
description: nginx authenticated user credentials
|
2026-02-10 09:42:16 +01:00
|
|
|
type: leadership
|
2026-02-10 09:48:09 +01:00
|
|
|
|
2026-02-10 09:42:16 +01:00
|
|
|
username:
|
2026-02-10 10:53:07 +01:00
|
|
|
description: nginx user
|
2026-02-10 09:42:16 +01:00
|
|
|
type: unix_user
|
2026-02-10 09:48:09 +01:00
|
|
|
|
2026-02-10 09:42:16 +01:00
|
|
|
password:
|
2026-02-10 10:53:07 +01:00
|
|
|
description: nginx password
|
2026-02-10 09:42:16 +01:00
|
|
|
type: secret
|
2026-02-10 10:08:33 +01:00
|
|
|
...
|