diff --git a/README.md b/README.md index f6559632..505f2974 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ Contact me for more details: ## Showcases The following list showcases the extensive range of solutions that CyMaIS incorporates, each playing a vital role in providing a comprehensive, efficient, and secure IT infrastructure setup: -[ELK Stack](./roles/docker-elk), [Intel Driver](./roles/driver-intel), [Nginx Docker Reverse Proxy](./roles/nginx-docker-reverse-proxy), [Sudo](./roles/sudo), [Funkwhale](./roles/docker-funkwhale), [MSI Keyboard Color Driver](./roles/driver-msi-keyboard-color), [Nginx Domain Redirect](./roles/nginx-domain-redirect), [GnuCash](./roles/pc-gnucash), [Backup Data to USB](./roles/backup-data-to-usb), [Gitea](./roles/docker-gitea), [Non-Free Driver](./roles/driver-non-free), [Nginx Homepage](./roles/nginx-static-repository), [Jrnl](./roles/pc-jrnl), [Systemd Notifier](./roles/systemd-notifier), [Backup Docker to Local](./roles/backup-docker-to-local), [Jenkins](./roles/docker-jenkins), [Git](./roles/git), [Nginx HTTPS](./roles/nginx-https), [Latex](./roles/pc-latex), [Email Notifier](./roles/systemd-notifier-email), [Remote to Local Backup Solution](./roles/backup-remote-to-local), [Joomla](./roles/docker-joomla), [Heal Defect Docker Installations](./roles/heal-docker), [Nginx Matomo Tracking](./roles/nginx-matomo-tracking), [LibreOffice](./roles/pc-libreoffice), [Telegram Notifier](./roles/systemd-notifier-telegram), [Listmonk](./roles/docker-listmonk), [Btrfs Health Check](./roles/health-btrfs), [Nginx WWW Redirect](./roles/nginx-www-redirect), [Network Analyze Tools](./roles/pc-network-analyze-tools), [System Security](./roles/system-security), [Mailu](./roles/docker-mailu), [Disc Space Health Check](./roles/health-disc-space), [Administrator Tools](./roles/pc-administrator-tools), [Nextcloud Client](./roles/pc-nextcloud), [Swapfile Setup](./roles/system-swapfile), [Backups Cleanup](./roles/cleanup-backups-service), [Mastodon](./roles/docker-mastodon), [Docker Container Health Checker](./roles/health-docker-container), [Blu-ray Player Tools](./roles/pc-bluray-player-tools), [Office](./roles/pc-office), [Update Solutions](./roles/update), [Matomo](./roles/docker-matomo), [Docker Volumes Health Checker](./roles/health-docker-volumes), [Caffeine](./roles/pc-caffeine), [Qbittorrent](./roles/pc-qbittorrent), [Update Apt](./roles/update-apt), [Disc Space Cleanup](./roles/cleanup-disc-space), [Matrix](./roles/docker-matrix), [Health Journalctl](./roles/health-journalctl), [Designer Tools](./roles/pc-designer-tools), [Security Tools](./roles/pc-security-tools), [Update Docker](./roles/update-docker), [Failed Docker Backups Cleanup](./roles/cleanup-failed-docker-backups), [MediaWiki](./roles/docker-mediawiki), [Nginx Health Checker](./roles/health-nginx), [Developer Tools](./roles/pc-developer-tools), [Spotify](./roles/pc-spotify), [Update Pacman](./roles/update-pacman), [Client Wireguard](./roles/client-wireguard), [MyBB](./roles/docker-mybb), [Developer Tools for Arduino](./roles/pc-developer-tools-arduino), [SSH](./roles/pc-ssh), [Update Yay](./roles/update-yay), [Client Setup for Wireguard Behind Firewall](./roles/client-wireguard-behind-firewall), [Nextcloud Server](./roles/docker-nextcloud), [Hunspell](./roles/hunspell), [Developer Tools for Bash](./roles/pc-developer-tools-bash), [Streaming Tools](./roles/pc-streaming-tools), [Administrator](./roles/user-administrator), [Docker](./roles/docker), [Peertube](./roles/docker-peertube), [Java](./roles/java), [Developer Tools for Java](./roles/pc-developer-tools-java), [Tor Browser](./roles/pc-torbrowser), [Video Conference](./roles/pc-video-conference), [Wireguard](./roles/wireguard), [Akaunting](./roles/docker-akaunting), [Pixelfed](./roles/docker-pixelfed), [Journalctl](./roles/journalctl), [Developer Tools for PHP](./roles/pc-developer-tools-php), [Virtual Box](./roles/pc-virtual-box), [Postfix](./roles/postfix), [Attendize](./roles/docker-attendize), [Wordpress](./roles/docker-wordpress), [Locales](./roles/locales), [Docker for End Users](./roles/pc-docker), [Games](./roles/pc-games), [Python Pip](./roles/python-pip), [Discourse](./roles/docker-discourse), [Epson Multiprinter Driver](./roles/driver-epson-multiprinter), [Nginx Certbot](./roles/nginx-certbot), [Git](./roles/pc-git), [SSHD](./roles/sshd), [YOURLS](./roles/docker-yourls), [BigBlueButton](./roles/docker-bigbluebutton),[System Maintenance Lock](./roles/system-maintenance-lock),[Open Project](./roles/docker-openproject)... +[ELK Stack](./roles/docker-elk), [Intel Driver](./roles/driver-intel), [Nginx Docker Reverse Proxy](./roles/nginx-docker-reverse-proxy), [Sudo](./roles/sudo), [Funkwhale](./roles/docker-funkwhale), [MSI Keyboard Color Driver](./roles/driver-msi-keyboard-color), [Nginx Domain Redirect](./roles/nginx-domain-redirect), [GnuCash](./roles/pc-gnucash), [Backup Data to USB](./roles/backup-data-to-usb), [Gitea](./roles/docker-gitea), [Non-Free Driver](./roles/driver-non-free), [Nginx Homepage](./roles/nginx-static-repository), [Jrnl](./roles/pc-jrnl), [Systemd Notifier](./roles/systemd-notifier), [Backup Docker to Local](./roles/backup-docker-to-local), [Jenkins](./roles/docker-jenkins), [Git](./roles/git), [Nginx HTTPS](./roles/nginx-https), [Latex](./roles/pc-latex), [Email Notifier](./roles/systemd-notifier-email), [Remote to Local Backup Solution](./roles/backup-remote-to-local), [Joomla](./roles/docker-joomla), [Heal Defect Docker Installations](./roles/heal-docker), [Nginx Matomo Tracking](./roles/nginx-global-matomo), [LibreOffice](./roles/pc-libreoffice), [Telegram Notifier](./roles/systemd-notifier-telegram), [Listmonk](./roles/docker-listmonk), [Btrfs Health Check](./roles/health-btrfs), [Nginx WWW Redirect](./roles/nginx-global-www), [Network Analyze Tools](./roles/pc-network-analyze-tools), [System Security](./roles/system-security), [Mailu](./roles/docker-mailu), [Disc Space Health Check](./roles/health-disc-space), [Administrator Tools](./roles/pc-administrator-tools), [Nextcloud Client](./roles/pc-nextcloud), [Swapfile Setup](./roles/system-swapfile), [Backups Cleanup](./roles/cleanup-backups-service), [Mastodon](./roles/docker-mastodon), [Docker Container Health Checker](./roles/health-docker-container), [Blu-ray Player Tools](./roles/pc-bluray-player-tools), [Office](./roles/pc-office), [Update Solutions](./roles/update), [Matomo](./roles/docker-matomo), [Docker Volumes Health Checker](./roles/health-docker-volumes), [Caffeine](./roles/pc-caffeine), [Qbittorrent](./roles/pc-qbittorrent), [Update Apt](./roles/update-apt), [Disc Space Cleanup](./roles/cleanup-disc-space), [Matrix](./roles/docker-matrix), [Health Journalctl](./roles/health-journalctl), [Designer Tools](./roles/pc-designer-tools), [Security Tools](./roles/pc-security-tools), [Update Docker](./roles/update-docker), [Failed Docker Backups Cleanup](./roles/cleanup-failed-docker-backups), [MediaWiki](./roles/docker-mediawiki), [Nginx Health Checker](./roles/health-nginx), [Developer Tools](./roles/pc-developer-tools), [Spotify](./roles/pc-spotify), [Update Pacman](./roles/update-pacman), [Client Wireguard](./roles/client-wireguard), [MyBB](./roles/docker-mybb), [Developer Tools for Arduino](./roles/pc-developer-tools-arduino), [SSH](./roles/pc-ssh), [Update Yay](./roles/update-yay), [Client Setup for Wireguard Behind Firewall](./roles/client-wireguard-behind-firewall), [Nextcloud Server](./roles/docker-nextcloud), [Hunspell](./roles/hunspell), [Developer Tools for Bash](./roles/pc-developer-tools-bash), [Streaming Tools](./roles/pc-streaming-tools), [Administrator](./roles/user-administrator), [Docker](./roles/docker), [Peertube](./roles/docker-peertube), [Java](./roles/java), [Developer Tools for Java](./roles/pc-developer-tools-java), [Tor Browser](./roles/pc-torbrowser), [Video Conference](./roles/pc-video-conference), [Wireguard](./roles/wireguard), [Akaunting](./roles/docker-akaunting), [Pixelfed](./roles/docker-pixelfed), [Journalctl](./roles/journalctl), [Developer Tools for PHP](./roles/pc-developer-tools-php), [Virtual Box](./roles/pc-virtual-box), [Postfix](./roles/postfix), [Attendize](./roles/docker-attendize), [Wordpress](./roles/docker-wordpress), [Locales](./roles/locales), [Docker for End Users](./roles/pc-docker), [Games](./roles/pc-games), [Python Pip](./roles/python-pip), [Discourse](./roles/docker-discourse), [Epson Multiprinter Driver](./roles/driver-epson-multiprinter), [Nginx Certbot](./roles/nginx-certbot), [Git](./roles/pc-git), [SSHD](./roles/sshd), [YOURLS](./roles/docker-yourls), [BigBlueButton](./roles/docker-bigbluebutton),[System Maintenance Lock](./roles/system-maintenance-lock),[Open Project](./roles/docker-openproject)... ## License diff --git a/SERVER_APPLICATIONS.md b/SERVER_APPLICATIONS.md index d3644eaf..a08ce046 100644 --- a/SERVER_APPLICATIONS.md +++ b/SERVER_APPLICATIONS.md @@ -21,9 +21,9 @@ Focuses on web server roles and applications, covering SSL certificates, Nginx c - **[Nginx-Docker-Reverse-Proxy](./roles/nginx-docker-reverse-proxy/)**: Sets up a reverse proxy for Docker containers. - **[nginx-static-repository](./roles/nginx-static-repository/)**: Configures a homepage for Nginx. - **[Nginx-Https](./roles/nginx-https/)**: Enables HTTPS configuration for Nginx. -- **[Nginx-Matomo-Tracking](./roles/nginx-matomo-tracking/)**: Integrates Matomo tracking with Nginx. +- **[nginx-global-matomo](./roles/nginx-global-matomo/)**: Integrates Matomo tracking with Nginx. - **[Nginx-Domain-Redirect](./roles/nginx-domain-redirect/)**: Manages URL redirects in Nginx. -- **[Nginx-WWW-Redirect](./roles/nginx-www-redirect/)**: Redirects all domains with the prefix www. from www.domain.tld to domain.tld +- **[nginx-global-www](./roles/nginx-global-www/)**: Redirects all domains with the prefix www. from www.domain.tld to domain.tld - **[Nginx-Certbot](./roles/nginx-certbot/)**: Integrates Certbot with Nginx for SSL certificates. - **[Postfix](./roles/postfix/)**: Setup for the Postfix mail transfer agent. diff --git a/group_vars/all/05_nginx.yml b/group_vars/all/05_nginx.yml index 1595d778..8878a4ae 100644 --- a/group_vars/all/05_nginx.yml +++ b/group_vars/all/05_nginx.yml @@ -11,8 +11,10 @@ nginx: streams: "/etc/nginx/conf.d/streams/" # Contains streams configuration e.g. for ldaps well_known: "/usr/share/nginx/well-known/" # Path where well-known files are stored homepage: "/usr/share/nginx/homepage/" # Path where the static homepage files are stored. @todo Move this variable to the role + global: "/var/www/global/" # Directory containing files which will be globaly accessable + user: "http" # Default nginx user in ArchLinux ## Nginx static repository nginx_static_repository_address: NULL #This should contain the url to an git repository which has a static homepage included and an index.html file. @todo move this variable to the role -nginx_matomo_tracking: false # Activates matomo tracking on all html pages \ No newline at end of file +global_matomo_tracking_enabled: false # Activates matomo tracking on all html pages \ No newline at end of file diff --git a/group_vars/all/13_theming.yml b/group_vars/all/13_theming.yml new file mode 100644 index 00000000..28e18dd3 --- /dev/null +++ b/group_vars/all/13_theming.yml @@ -0,0 +1,20 @@ +global_theming: + enabled: true + css: + colors: + primary: "#007BFF" # Main brand color (e.g., buttons, highlights) + secondary: "#0056B3" # Secondary color (e.g., navigation, footers) + background: "#FFFFFF" # Background color (light mode) + background_dark: "#1E1E1E" # Background color (dark mode) + text: "#333333" # Main text color (dark mode text: "#EAEAEA") + accent: "#FF9900" # Accent color (used for highlights, CTAs) + success: "#28A745" # Success color (e.g., confirmation messages) + warning: "#FFC107" # Warning color (e.g., alerts, notifications) + error: "#DC3545" # Error color (e.g., form validation errors) + info: "#17A2B8" # Information color (e.g., tooltips, messages) + link: "#0056B3" # Link color (often matches primary/secondary) + button_text: "#FFFFFF" # Button text color + shadow: "rgba(0, 0, 0, 0.1)" # Shadow color for UI elements + border: "#DDDDDD" # Border color for UI components + +global_theming_enabled: false # Needs to be set to true in every vars/main.yml of every role which supports this \ No newline at end of file diff --git a/playbook.servers.yml b/playbook.servers.yml index cd0bbb79..36b127d8 100644 --- a/playbook.servers.yml +++ b/playbook.servers.yml @@ -242,6 +242,6 @@ hosts: www_redirect become: true roles: - - role: nginx-www-redirect + - role: nginx-global-www - import_playbook: playbook.destructor.yml \ No newline at end of file diff --git a/roles/docker-bigbluebutton/tasks/main.yml b/roles/docker-bigbluebutton/tasks/main.yml index 6df0343d..ed58b6dc 100644 --- a/roles/docker-bigbluebutton/tasks/main.yml +++ b/roles/docker-bigbluebutton/tasks/main.yml @@ -6,8 +6,8 @@ # Leave this in the code until big blue button was working for a while. # This is necessary due to the reason that big blue button wasn't fully tested after refactoring # -#- name: "include task certbot-matomo.yml" -# include_tasks: certbot-matomo.yml +#- name: "include task certbot-and-globals.yml" +# include_tasks: certbot-and-globals.yml # #- name: configure {{domain}}.conf # template: diff --git a/roles/docker-gitea/README.md b/roles/docker-gitea/README.md index 0527d8ae..7b915cca 100644 --- a/roles/docker-gitea/README.md +++ b/roles/docker-gitea/README.md @@ -26,4 +26,8 @@ To access the database execute docker-compose exec -it database /bin/mysql -u gitea -p ``` ## bash in application -docker-compose exec -it application /bin/sh \ No newline at end of file +docker-compose exec -it application /bin/sh + +## More Information +- [Gitea LDAP integration](https://docs.gitea.com/usage/authentication) +- [Gitea Alternatives](https://chatgpt.com/share/67a5f599-c9b0-800f-87fe-49a3b61263e6) \ No newline at end of file diff --git a/roles/docker-mastodon/tasks/create-domains.yml b/roles/docker-mastodon/tasks/create-domains.yml index 9a370ded..6c672eeb 100644 --- a/roles/docker-mastodon/tasks/create-domains.yml +++ b/roles/docker-mastodon/tasks/create-domains.yml @@ -1,5 +1,5 @@ -- name: "include task certbot-matomo.yml" - include_tasks: certbot-matomo.yml +- name: "include task certbot-and-globals.yml" + include_tasks: certbot-and-globals.yml - name: configure {{domain}}.conf template: diff --git a/roles/docker-mastodon/templates/mastodon.conf.j2 b/roles/docker-mastodon/templates/mastodon.conf.j2 index 0bb1e11e..855cd5f6 100644 --- a/roles/docker-mastodon/templates/mastodon.conf.j2 +++ b/roles/docker-mastodon/templates/mastodon.conf.j2 @@ -8,10 +8,7 @@ server { {% include 'roles/letsencrypt/templates/ssl_header.j2' %} - {% if nginx_matomo_tracking | bool %} - {% include 'roles/nginx-matomo-tracking/templates/matomo-tracking.conf.j2' %} - {% endif %} - + {% include 'roles/nginx-global/templates/global.includes.conf.j2'%} keepalive_timeout 70; sendfile on; diff --git a/roles/docker-matrix-compose/tasks/main.yml b/roles/docker-matrix-compose/tasks/main.yml index c83be0e5..b0124275 100644 --- a/roles/docker-matrix-compose/tasks/main.yml +++ b/roles/docker-matrix-compose/tasks/main.yml @@ -3,8 +3,8 @@ include_role: name: docker-central-database -- name: "include task certbot-matomo.yml" - include_tasks: certbot-matomo.yml +- name: "include task certbot-and-globals.yml" + include_tasks: certbot-and-globals.yml vars: domain: "{{domains.matrix_synapse}}" http_port: "{{ports.localhost.http_ports.matrix_synapse}}" diff --git a/roles/docker-matrix-compose/templates/nginx.conf.j2 b/roles/docker-matrix-compose/templates/nginx.conf.j2 index 2695045e..5ec80060 100644 --- a/roles/docker-matrix-compose/templates/nginx.conf.j2 +++ b/roles/docker-matrix-compose/templates/nginx.conf.j2 @@ -10,9 +10,6 @@ server { listen 8448 ssl default_server; listen [::]:8448 ssl default_server; - {% if nginx_matomo_tracking | bool %} - {% include 'roles/nginx-matomo-tracking/templates/matomo-tracking.conf.j2' %} - {% endif %} - + {% include 'roles/nginx-global/templates/global.includes.conf.j2'%} {% include 'roles/nginx-docker-reverse-proxy/templates/proxy_pass.conf.j2' %} } \ No newline at end of file diff --git a/roles/docker-nextcloud/tasks/main.yml b/roles/docker-nextcloud/tasks/main.yml index e2294b80..ed6cc681 100644 --- a/roles/docker-nextcloud/tasks/main.yml +++ b/roles/docker-nextcloud/tasks/main.yml @@ -3,8 +3,8 @@ include_role: name: docker-central-database -- name: "include task certbot-matomo.yml" - include_tasks: certbot-matomo.yml +- name: "include task certbot-and-globals.yml" + include_tasks: certbot-and-globals.yml - name: configure {{domain}}.conf template: diff --git a/roles/docker-nextcloud/templates/nextcloud.conf.j2 b/roles/docker-nextcloud/templates/nextcloud.conf.j2 index 007fcfe7..abb076d4 100644 --- a/roles/docker-nextcloud/templates/nextcloud.conf.j2 +++ b/roles/docker-nextcloud/templates/nextcloud.conf.j2 @@ -4,10 +4,7 @@ server {% include 'roles/letsencrypt/templates/ssl_header.j2' %} - {% if nginx_matomo_tracking | bool %} - {% include 'roles/nginx-matomo-tracking/templates/matomo-tracking.conf.j2' %} - {% endif %} - + {% include 'roles/nginx-global/templates/global.includes.conf.j2'%} # Remove X-Powered-By, which is an information leak fastcgi_hide_header X-Powered-By; diff --git a/roles/docker-peertube/tasks/create-domains.yml b/roles/docker-peertube/tasks/create-domains.yml index b96f2043..fc330f98 100644 --- a/roles/docker-peertube/tasks/create-domains.yml +++ b/roles/docker-peertube/tasks/create-domains.yml @@ -1,5 +1,5 @@ -- name: "include task certbot-matomo.yml" - include_tasks: certbot-matomo.yml +- name: "include task certbot-and-globals.yml" + include_tasks: certbot-and-globals.yml - name: configure {{domain}}.conf template: diff --git a/roles/docker-peertube/templates/peertube.conf.j2 b/roles/docker-peertube/templates/peertube.conf.j2 index ece8161e..639fe051 100644 --- a/roles/docker-peertube/templates/peertube.conf.j2 +++ b/roles/docker-peertube/templates/peertube.conf.j2 @@ -3,11 +3,7 @@ server { {% include 'roles/letsencrypt/templates/ssl_header.j2' %} - {% if nginx_matomo_tracking | bool %} - {% include 'roles/nginx-matomo-tracking/templates/matomo-tracking.conf.j2' %} - {% endif %} - - + {% include 'roles/nginx-global/templates/global.includes.conf.j2'%} ## # Application ## diff --git a/roles/docker-portfolio/vars/main.yml b/roles/docker-portfolio/vars/main.yml index fc2605e4..2284ce84 100644 --- a/roles/docker-portfolio/vars/main.yml +++ b/roles/docker-portfolio/vars/main.yml @@ -1,2 +1,3 @@ -application_id: "portfolio" -repository_address: "https://github.com/kevinveenbirkenbach/portfolio" +application_id: "portfolio" +repository_address: "https://github.com/kevinveenbirkenbach/portfolio" +global_theming_enabled: true # Activate Global CSS for Portfolio diff --git a/roles/health-nginx/templates/health-nginx.py.j2 b/roles/health-nginx/templates/health-nginx.py.j2 index 48e82d11..ce4062b5 100644 --- a/roles/health-nginx/templates/health-nginx.py.j2 +++ b/roles/health-nginx/templates/health-nginx.py.j2 @@ -31,7 +31,7 @@ for filename in os.listdir(config_path): # Determine expected status codes based on the domain if domain == '{{domains.listmonk}}': expected_statuses = [404] -{% if nginx_matomo_tracking | bool %} +{% if global_matomo_tracking_enabled | bool %} elif parts[0] == 'www' or domain in redirected_domains: expected_statuses = [301] {% endif %} diff --git a/roles/nginx-docker-reverse-proxy/templates/domain.conf.j2 b/roles/nginx-docker-reverse-proxy/templates/domain.conf.j2 index 6b261601..067ecc4e 100644 --- a/roles/nginx-docker-reverse-proxy/templates/domain.conf.j2 +++ b/roles/nginx-docker-reverse-proxy/templates/domain.conf.j2 @@ -21,11 +21,8 @@ server } {% endif %} - {% if nginx_matomo_tracking | bool %} - # Include Matomo Tracking Code - {% include 'roles/nginx-matomo-tracking/templates/matomo-tracking.conf.j2' %} - {% endif %} - + {% include 'roles/nginx-global/templates/global.includes.conf.j2'%} + {% if nginx_docker_reverse_proxy_extra_configuration is defined %} # Additional Domain Specific Configuration {{nginx_docker_reverse_proxy_extra_configuration}} diff --git a/roles/nginx-global-css/README.md b/roles/nginx-global-css/README.md new file mode 100644 index 00000000..026cb855 --- /dev/null +++ b/roles/nginx-global-css/README.md @@ -0,0 +1,43 @@ +# 🌍 Nginx Global Theming Role + +This **Ansible role** provides a **global theming solution** for Nginx-based web applications. It ensures a **consistent look and feel** across multiple applications by injecting a **unified global.css** with customizable theming options. +--- + +## 🚀 Features +✅ **Automatic CSS Deployment** – Injects `global.css` into all Nginx-served applications. +✅ **Dynamic Theming** – Uses `global_theming.css.colors` from Ansible variables for **full customization**. +✅ **Bootstrap Override Support** – Ensures Bootstrap-based apps use the **unified global styles**. +✅ **Versioning System** – Prevents caching issues with automatic **timestamp-based versioning**. +✅ **Dark Mode Support** – Automatically adapts to user preferences. +✅ **Runs Once Per Deployment** – Avoids redundant executions with `run_once_nginx_global_css`. + +--- + +## 📂 File Structure + +``` +. +├── tasks/ +│ ├── main.yml # Main Ansible tasks for deploying the global CSS +├── vars/ +│ ├── main.yml # Global variables (CSS paths, file names, etc.) +├── templates/ +│ ├── global.css.j2 # Jinja2 template for generating the global CSS +│ ├── location.conf.j2 # Nginx configuration for serving global.css +│ ├── sub_filter.conf.j2 # Injects the global CSS link into served pages +└── README.md # You are here 🚀 +``` + +--- + +## 🎨 Theming Details + +The **CSS template (`global.css.j2`)** dynamically applies the defined theme colors and ensures **Bootstrap, buttons, alerts, forms, and other UI elements** follow the **unified design**. + +## 🛠️ Contribution +Feel free to **fork, modify, and improve** this role! Contributions are always welcome. 🛠️🔥 + +--- + +🚀 **Happy Theming!** 🎨✨ +*Created by [Kevin Veen-Birkenbach](https://www.veen.world) with the assistance of [ChatGPT](https://chatgpt.com/share/67a5fea3-4d5c-800f-8bc4-605712c02c9b). \ No newline at end of file diff --git a/roles/nginx-global-css/tasks/main.yml b/roles/nginx-global-css/tasks/main.yml new file mode 100644 index 00000000..16635ef4 --- /dev/null +++ b/roles/nginx-global-css/tasks/main.yml @@ -0,0 +1,28 @@ +- name: Get the current Unix timestamp as version + set_fact: + global_css_version: "{{ ansible_date_time.epoch }}" + when: run_once_nginx_global_css is not defined + +- name: Ensure {{nginx.directories.global}} directory exists + file: + path: "{{nginx.directories.global}}" + state: directory + owner: "{{nginx.user}}" + group: "{{nginx.user}}" + mode: '0755' + when: run_once_nginx_global_css is not defined + +- name: Deploy global.css from template + template: + src: global.css.j2 + dest: "{{global_css_destination}}" + owner: "{{nginx.user}}" + group: "{{nginx.user}}" + mode: '0644' + when: run_once_nginx_global_css is not defined + +- name: run the global css tasks once + set_fact: + run_once_nginx_global_css: true + when: run_once_nginx_global_css is not defined + diff --git a/roles/nginx-global-css/templates/global.css.j2 b/roles/nginx-global-css/templates/global.css.j2 new file mode 100644 index 00000000..a113585c --- /dev/null +++ b/roles/nginx-global-css/templates/global.css.j2 @@ -0,0 +1,151 @@ +/* Global Theming Styles - Overrides Application Defaults */ +:root { + --primary-color: {{ global_theming.css.colors.primary }}; + --secondary-color: {{ global_theming.css.colors.secondary }}; + --background-color: {{ global_theming.css.colors.background }}; + --background-dark-color: {{ global_theming.css.colors.background_dark }}; + --text-color: {{ global_theming.css.colors.text }}; + --accent-color: {{ global_theming.css.colors.accent }}; + --success-color: {{ global_theming.css.colors.success }}; + --warning-color: {{ global_theming.css.colors.warning }}; + --error-color: {{ global_theming.css.colors.error }}; + --info-color: {{ global_theming.css.colors.info }}; + --link-color: {{ global_theming.css.colors.link }}; + --button-text-color: {{ global_theming.css.colors.button_text }}; + --shadow-color: {{ global_theming.css.colors.shadow }}; + --border-color: {{ global_theming.css.colors.border }}; +} + +/* Bootstrap Overrides */ +:root { + --bs-primary: var(--primary-color); + --bs-secondary: var(--secondary-color); + --bs-body-bg: var(--background-color); + --bs-body-color: var(--text-color); + --bs-danger: var(--error-color); + --bs-warning: var(--warning-color); + --bs-success: var(--success-color); + --bs-info: var(--info-color); + --bs-link-color: var(--link-color); + --bs-btn-color: var(--button-text-color); +} + +/* Ensure Styles Take Priority */ +*, +*::before, +*::after { + all: unset; + all: revert; +} + +/* Global Defaults */ +body { + background-color: var(--background-color) !important; + color: var(--text-color) !important; + font-family: Arial, sans-serif; + line-height: 1.6; +} + +/* Links */ +a { + color: var(--link-color) !important; + text-decoration: none; +} +a:hover { + text-decoration: underline; +} + +/* Buttons */ +button, .btn { + background-color: var(--primary-color) !important; + color: var(--button-text-color) !important; + border: 1px solid var(--border-color) !important; + box-shadow: 2px 2px 5px var(--shadow-color) !important; + padding: 10px 15px; + border-radius: 5px; + font-weight: bold; + cursor: pointer; +} +button:hover, .btn:hover { + filter: brightness(0.9); +} + +/* Success, Warning, Error States */ +.success, .alert-success { + background-color: var(--success-color) !important; + color: white !important; +} +.warning, .alert-warning { + background-color: var(--warning-color) !important; + color: black !important; +} +.error, .alert-danger { + background-color: var(--error-color) !important; + color: white !important; +} +.info, .alert-info { + background-color: var(--info-color) !important; + color: white !important; +} + +/* Inputs & Forms */ +input, textarea, select { + background-color: var(--background-color) !important; + color: var(--text-color) !important; + border: 1px solid var(--border-color) !important; + padding: 8px; + border-radius: 4px; +} +input:focus, textarea:focus, select:focus { + border-color: var(--primary-color) !important; + outline: none; + box-shadow: 0 0 5px var(--shadow-color); +} + +/* Navigation */ +.navbar, .navbar-light, .navbar-dark { + background-color: var(--primary-color) !important; + color: var(--button-text-color) !important; +} +.navbar a { + color: var(--button-text-color) !important; +} + +/* Tables */ +table { + width: 100%; + border-collapse: collapse; +} +th, td { + padding: 10px; + border: 1px solid var(--border-color); +} +thead { + background-color: var(--primary-color); + color: var(--button-text-color); +} + +/* Cards / Containers */ +.card { + background-color: var(--background-color) !important; + box-shadow: 2px 2px 10px var(--shadow-color) !important; + border: 1px solid var(--border-color); + border-radius: 8px; +} + +/* Dark Mode */ +@media (prefers-color-scheme: dark) { + body { + background-color: var(--background-dark-color) !important; + color: var(--text-color) !important; + } + input, textarea, select { + background-color: var(--background-dark-color) !important; + color: var(--text-color) !important; + } +} + +/* Enforce Style Priority */ +html, body, * { + !important; +} \ No newline at end of file diff --git a/roles/nginx-global-css/templates/location.conf.j2 b/roles/nginx-global-css/templates/location.conf.j2 new file mode 100644 index 00000000..6486c6ff --- /dev/null +++ b/roles/nginx-global-css/templates/location.conf.j2 @@ -0,0 +1,3 @@ +location = /global.css { + root {{nginx.directories.global}}; +} \ No newline at end of file diff --git a/roles/nginx-global-css/templates/sub_filter.conf.j2 b/roles/nginx-global-css/templates/sub_filter.conf.j2 new file mode 100644 index 00000000..c1bb5619 --- /dev/null +++ b/roles/nginx-global-css/templates/sub_filter.conf.j2 @@ -0,0 +1 @@ +sub_filter '' ''; \ No newline at end of file diff --git a/roles/nginx-global-css/vars/main.yml b/roles/nginx-global-css/vars/main.yml new file mode 100644 index 00000000..7f87bc9e --- /dev/null +++ b/roles/nginx-global-css/vars/main.yml @@ -0,0 +1 @@ +global_css_destination: "{{nginx.directories.global}}global.css" \ No newline at end of file diff --git a/roles/nginx-matomo-tracking/README.md b/roles/nginx-global-matomo/README.md similarity index 77% rename from roles/nginx-matomo-tracking/README.md rename to roles/nginx-global-matomo/README.md index 4d66428f..61ac9a0c 100644 --- a/roles/nginx-matomo-tracking/README.md +++ b/roles/nginx-global-matomo/README.md @@ -25,11 +25,11 @@ To enable Matomo tracking on your Nginx website, include the role in your playbo ```yaml - hosts: webserver roles: - - { role: nginx-matomo-tracking, matomo_domain: 'matomo.example.com', base_domain: 'example.com', matomo_site_id: '1' } + - { role: nginx-global-matomo, matomo_domain: 'matomo.example.com', base_domain: 'example.com', matomo_site_id: '1' } ``` ## Customization -You can customize the tracking script and the noscript image tracker by editing the `matomo-tracking.js.j2` and `matomo-tracking.conf.j2` templates. +You can customize the tracking script and the noscript image tracker by editing the `matomo-tracking.js.j2` and `matomo.subfilter.conf.j2` templates. ## Author Information -This role was created in 2023 by Kevin Veen Birkenbach, providing a seamless way to add Matomo analytics to any website served via Nginx. \ No newline at end of file +This role was created in 2023 by [Kevin Veen Birkenbach](https://www.veen.world/), providing a seamless way to add Matomo analytics to any website served via Nginx. \ No newline at end of file diff --git a/roles/nginx-matomo-tracking/tasks/main.yml b/roles/nginx-global-matomo/tasks/main.yml similarity index 100% rename from roles/nginx-matomo-tracking/tasks/main.yml rename to roles/nginx-global-matomo/tasks/main.yml diff --git a/roles/nginx-matomo-tracking/templates/matomo-tracking.conf.j2 b/roles/nginx-global-matomo/templates/matomo-tracking.conf.j2 similarity index 84% rename from roles/nginx-matomo-tracking/templates/matomo-tracking.conf.j2 rename to roles/nginx-global-matomo/templates/matomo-tracking.conf.j2 index a5e716de..29fd7a06 100644 --- a/roles/nginx-matomo-tracking/templates/matomo-tracking.conf.j2 +++ b/roles/nginx-global-matomo/templates/matomo-tracking.conf.j2 @@ -3,5 +3,4 @@ add_header Content-Security-Policy: ""; # sub filters to integrate matomo tracking code in nginx websites sub_filter '' ''; -sub_filter '' ''; -sub_filter_once off; \ No newline at end of file +sub_filter '' ''; \ No newline at end of file diff --git a/roles/nginx-matomo-tracking/templates/matomo-tracking.js.j2 b/roles/nginx-global-matomo/templates/matomo-tracking.js.j2 similarity index 100% rename from roles/nginx-matomo-tracking/templates/matomo-tracking.js.j2 rename to roles/nginx-global-matomo/templates/matomo-tracking.js.j2 diff --git a/roles/nginx-matomo-tracking/vars/main.yml b/roles/nginx-global-matomo/vars/main.yml similarity index 100% rename from roles/nginx-matomo-tracking/vars/main.yml rename to roles/nginx-global-matomo/vars/main.yml diff --git a/roles/nginx-www-redirect/README.md b/roles/nginx-global-www/README.md similarity index 67% rename from roles/nginx-www-redirect/README.md rename to roles/nginx-global-www/README.md index ab2bf92b..c5888f99 100644 --- a/roles/nginx-www-redirect/README.md +++ b/roles/nginx-global-www/README.md @@ -1,7 +1,7 @@ -# README.md for nginx-www-redirect Role +# README.md for nginx-global-www Role ## Overview -The `nginx-www-redirect` role is designed to automate the process of setting up redirects from `www.domain.tld` to `domain.tld` for all domains and subdomains configured within the `{{nginx.directories.http.servers}}` directory. This role dynamically identifies configuration files following the pattern `*domain.tld.conf` and creates corresponding redirection rules. +The `nginx-global-www` role is designed to automate the process of setting up redirects from `www.domain.tld` to `domain.tld` for all domains and subdomains configured within the `{{nginx.directories.http.servers}}` directory. This role dynamically identifies configuration files following the pattern `*domain.tld.conf` and creates corresponding redirection rules. ## Role Description This role performs several key tasks: @@ -20,7 +20,7 @@ Example playbook: ```yaml - hosts: web-servers roles: - - nginx-www-redirect + - nginx-global-www ``` ## Requirements @@ -34,4 +34,4 @@ Example playbook: --- -This `nginx-www-redirect` role was crafted with insights and guidance provided by ChatGPT, an advanced AI language model from OpenAI. The development process, including the discussions with ChatGPT that shaped this role, can be [here](https://chat.openai.com/share/a68e3574-f543-467d-aea7-0895f0e00bbb) explored in detail. \ No newline at end of file +This `nginx-global-www` role was crafted by [Kevin Veen-Birkenbach](https://www.veen.world) with insights and guidance provided by ChatGPT, an advanced AI language model from OpenAI. The development process, including the discussions with ChatGPT that shaped this role, can be [here](https://chat.openai.com/share/a68e3574-f543-467d-aea7-0895f0e00bbb) explored in detail. \ No newline at end of file diff --git a/roles/nginx-www-redirect/meta/main.yml b/roles/nginx-global-www/meta/main.yml similarity index 100% rename from roles/nginx-www-redirect/meta/main.yml rename to roles/nginx-global-www/meta/main.yml diff --git a/roles/nginx-www-redirect/tasks/main.yml b/roles/nginx-global-www/tasks/main.yml similarity index 100% rename from roles/nginx-www-redirect/tasks/main.yml rename to roles/nginx-global-www/tasks/main.yml diff --git a/roles/nginx-www-redirect/templates/www.wildcard.conf.j2 b/roles/nginx-global-www/templates/www.wildcard.conf.j2 similarity index 100% rename from roles/nginx-www-redirect/templates/www.wildcard.conf.j2 rename to roles/nginx-global-www/templates/www.wildcard.conf.j2 diff --git a/roles/nginx-www-redirect/vars/main.yml b/roles/nginx-global-www/vars/main.yml similarity index 100% rename from roles/nginx-www-redirect/vars/main.yml rename to roles/nginx-global-www/vars/main.yml diff --git a/roles/nginx-global/tasks/main.yml b/roles/nginx-global/tasks/main.yml new file mode 100644 index 00000000..09183451 --- /dev/null +++ b/roles/nginx-global/tasks/main.yml @@ -0,0 +1,13 @@ +- name: Activate Global Matomo tracking + include_role: + name: nginx-global-matomo + when: global_matomo_tracking_enabled | bool and domain is defined # @toto: Do I try run without is defined checking for domain + +- name: Activate Global CSS + include_role: + name: nginx-global-css + when: + - global_theming_enabled | bool + - run_once_nginx_global_css is not defined +# - nginx-global-www Has to be loaded somehow different +# @todo implement better loading \ No newline at end of file diff --git a/roles/nginx-global/templates/global.includes.conf.j2 b/roles/nginx-global/templates/global.includes.conf.j2 new file mode 100644 index 00000000..fec07ead --- /dev/null +++ b/roles/nginx-global/templates/global.includes.conf.j2 @@ -0,0 +1,15 @@ +# Allow multiple sub_filters +sub_filter_once off; +sub_filter_types text/html; + +{% if global_matomo_tracking_enabled | bool %} + # Include Global Matomo Tracking + {% include 'roles/nginx-global-matomo/templates/matomo-tracking.conf.j2' %} +{% endif %} + +{% if global_theming_enabled | bool %} + # Include Global Theming + {% include 'roles/nginx-global-css/templates/sub_filter.conf.j2' %} + # Include Global CSS Location + {% include 'roles/nginx-global-css/templates/location.conf.j2' %} +{% endif %} diff --git a/roles/nginx-static-repository/templates/static.nginx.conf.j2 b/roles/nginx-static-repository/templates/static.nginx.conf.j2 index 4f5ed8a9..3af422b0 100644 --- a/roles/nginx-static-repository/templates/static.nginx.conf.j2 +++ b/roles/nginx-static-repository/templates/static.nginx.conf.j2 @@ -5,10 +5,7 @@ server {% include 'roles/letsencrypt/templates/ssl_header.j2' %} - {% if nginx_matomo_tracking | bool %} - {% include 'roles/nginx-matomo-tracking/templates/matomo-tracking.conf.j2' %} - {% endif %} - + {% include 'roles/nginx-global/templates/global.includes.conf.j2'%} charset utf-8; location / diff --git a/roles/nginx/tasks/main.yml b/roles/nginx/tasks/main.yml index 9e82e8b5..c5b237b2 100644 --- a/roles/nginx/tasks/main.yml +++ b/roles/nginx/tasks/main.yml @@ -9,7 +9,7 @@ name: nginx-mod-headers-more state: present notify: restart nginx - when: run_once_nginx is not defined and nginx_matomo_tracking | bool + when: run_once_nginx is not defined and global_matomo_tracking_enabled | bool - name: "Delete {{nginx.directories.configuration}} directory, when mode_reset" file: @@ -33,8 +33,8 @@ notify: restart nginx when: run_once_nginx is not defined -- name: "include task certbot-matomo.yml" - include_tasks: certbot-matomo.yml +- name: "include task certbot-and-globals.yml" + include_tasks: certbot-and-globals.yml vars: domain: "{{primary_domain}}" when: run_once_nginx is not defined diff --git a/roles/nginx/templates/nginx.conf.j2 b/roles/nginx/templates/nginx.conf.j2 index 552bb9bf..a114f6c6 100644 --- a/roles/nginx/templates/nginx.conf.j2 +++ b/roles/nginx/templates/nginx.conf.j2 @@ -1,4 +1,4 @@ -{% if nginx_matomo_tracking | bool %} +{% if global_matomo_tracking_enabled | bool %} load_module /usr/lib/nginx/modules/ngx_http_headers_more_filter_module.so; {% endif %} diff --git a/tasks/certbot-matomo.yml b/tasks/certbot-and-globals.yml similarity index 50% rename from tasks/certbot-matomo.yml rename to tasks/certbot-and-globals.yml index 7a63bdbc..8a09f152 100644 --- a/tasks/certbot-matomo.yml +++ b/tasks/certbot-and-globals.yml @@ -1,5 +1,6 @@ - name: "include task receive certbot certificate" include_tasks: recieve-certbot-certificate.yml -- name: "include task implement-matomo-tracking.yml" - include_tasks: implement-matomo-tracking.yml \ No newline at end of file +- name: Load global Nginx Configuration + include_role: + name: nginx-global \ No newline at end of file diff --git a/tasks/create-proxy-with-domain-replace.yml b/tasks/create-proxy-with-domain-replace.yml index 713969fc..8f76a672 100644 --- a/tasks/create-proxy-with-domain-replace.yml +++ b/tasks/create-proxy-with-domain-replace.yml @@ -1,5 +1,5 @@ -- name: "include task certbot-matomo.yml" - include_tasks: certbot-matomo.yml +- name: "include task certbot-and-globals.yml" + include_tasks: certbot-and-globals.yml - name: "include task create-domain-conf.yml" include_tasks: create-domain-conf.yml diff --git a/tasks/implement-matomo-tracking.yml b/tasks/implement-matomo-tracking.yml deleted file mode 100644 index bbebfd24..00000000 --- a/tasks/implement-matomo-tracking.yml +++ /dev/null @@ -1,4 +0,0 @@ -- name: Activate NGINX matomo tracking - include_role: - name: nginx-matomo-tracking - when: nginx_matomo_tracking | bool and domain is defined \ No newline at end of file diff --git a/tasks/nginx-docker-proxy-domain.yml b/tasks/nginx-docker-proxy-domain.yml index 12a949dc..10f83c7c 100644 --- a/tasks/nginx-docker-proxy-domain.yml +++ b/tasks/nginx-docker-proxy-domain.yml @@ -1,5 +1,5 @@ -- name: "include task certbot-matomo.yml" - include_tasks: certbot-matomo.yml +- name: "include task certbot-and-globals.yml" + include_tasks: certbot-and-globals.yml - name: "include task create-domain-conf.yml" include_tasks: create-domain-conf.yml