15 Commits
v2.5.1 ... main

Author SHA1 Message Date
Sebastian Palencsar
da2f0876dd fix: update Ansible facts syntax for future compatibility
- Use ansible_facts[] instead of ansible_ prefix
- Update os_family, distribution, default_ipv4, date_time, hostname, port
- Also fixes YAML colons in msg strings
2026-05-06 14:09:22 +02:00
Sebastian Palencsar
cfb63da386 fix: remove software-properties-common (Ubuntu-only, not needed) 2026-05-06 14:00:54 +02:00
Sebastian Palencsar
55193c7bd4 fix: add --path parameter to wp option update command 2026-05-06 13:52:12 +02:00
Sebastian Palencsar
2aa5480d17 fix: create PHP-FPM log directory before service starts
- Add preflight task to create /var/log/php{X}-fpm directory
- Add default php_version var for early template access
2026-05-06 13:47:18 +02:00
Sebastian Palencsar
168c59f3ea fix: correct YAML indentation for tasks sections
- Add missing 2-space indentation before 'tasks:' keyword
- Fixes Ansible YAML parsing errors
2026-05-06 13:43:49 +02:00
Sebastian Palencsar
58ffb82378 feat: add PHP version detection with 8.4→8.3 fallback
- Detect available PHP version at runtime
- Try PHP 8.4 first, fallback to 8.3
- Dynamically set PHP service names and paths
- Remove hardcoded PHP 8.4 references from vars
2026-05-06 13:38:29 +02:00
Sebastian Palencsar
38241f82e3 refactor: remove unnecessary PPA tasks - PHP 8.4 is already in Ubuntu 24.04 default repos
- Removed PHP PPA addition tasks from both playbooks
- Simplified package installation (no external PPA needed)
- PHP 8.4 available in Ubuntu 24.04 default repos
2026-05-06 13:35:17 +02:00
Sebastian Palencsar
9eac2c2057 fix: add preflight tasks to ensure /var/www/html exists before package installation
- Add preflight tasks to create web directory structure first
- Install nginx first as a base package
- Add HOME environment for all wp commands to prevent 'wrong path' errors
- Make auto-update settings ignore errors (WP not required to be installed)
2026-05-06 13:31:26 +02:00
Sebastian Palencsar
feb6a2c962 fix: add gnupg and software-properties-common for PPA support 2026-05-06 13:19:55 +02:00
Sebastian Palencsar
619205e0a8 fix: add PHP PPA for Ubuntu 24.04+ to enable PHP 8.4 2026-05-06 13:18:35 +02:00
Sebastian Palencsar
1361466dfe fix(MariaDB+UFW): add ufw package for firewall tasks 2026-05-06 13:03:55 +02:00
Sebastian Palencsar
1fa863f107 fix: replace mysql-server with mariadb-server for Debian 12/13 compatibility
- Use mariadb-server instead of mysql-server (works on both Ubuntu and Debian)
- Update mysql_service to mariadb for proper service management
- Update docker/Dockerfile and start-services.sh for MariaDB
2026-05-06 12:59:15 +02:00
Sebastian Palencsar
605b4e8c7b ci: run ansible syntax checks with explicit test inventory 2026-05-05 07:09:56 +02:00
Sebastian Palencsar
e5b0a80bb2 ci: make Ubuntu container smoke test network-independent 2026-05-05 06:54:43 +02:00
Sebastian Palencsar
c2b4181756 ci: keep Ubuntu 25.04 tests non-blocking and harden apt install 2026-05-05 06:29:34 +02:00
7 changed files with 232 additions and 66 deletions

View File

@@ -42,8 +42,13 @@ jobs:
- name: Validate Ansible syntax - name: Validate Ansible syntax
run: | run: |
mkdir -p test-inventory
cat > test-inventory/hosts <<EOF
[all]
localhost ansible_connection=local
EOF
for playbook in playbooks/*.yml; do for playbook in playbooks/*.yml; do
ansible-playbook --syntax-check "$playbook" ansible-playbook -i test-inventory/hosts --syntax-check "$playbook"
done done
test-ubuntu: test-ubuntu:
@@ -52,8 +57,16 @@ jobs:
needs: lint needs: lint
strategy: strategy:
matrix: matrix:
ubuntu_version: ['22.04', '24.04', '25.04'] include:
- ubuntu_version: '22.04'
allow_failure: false
- ubuntu_version: '24.04'
allow_failure: false
- ubuntu_version: '25.04'
allow_failure: true
continue-on-error: ${{ matrix.allow_failure }}
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v5 uses: actions/checkout@v5
@@ -81,7 +94,7 @@ jobs:
echo "Testing syntax for all playbooks..." echo "Testing syntax for all playbooks..."
for playbook in playbooks/*.yml; do for playbook in playbooks/*.yml; do
echo "Checking $playbook..." echo "Checking $playbook..."
ansible-playbook "$playbook" --syntax-check ansible-playbook -i test-inventory/hosts "$playbook" --syntax-check
done done
- name: Test variable loading - name: Test variable loading
@@ -97,10 +110,10 @@ jobs:
run: | run: |
echo "Testing basic container setup for Ubuntu ${{ matrix.ubuntu_version }}..." echo "Testing basic container setup for Ubuntu ${{ matrix.ubuntu_version }}..."
docker run --rm ubuntu:${{ matrix.ubuntu_version }} /bin/bash -c " docker run --rm ubuntu:${{ matrix.ubuntu_version }} /bin/bash -c "
export DEBIAN_FRONTEND=noninteractive && set -e &&
apt-get update -o Acquire::Retries=5 -o Acquire::http::Timeout=30 || apt-get update -o Acquire::Retries=5 -o Acquire::http::Timeout=30 && grep '^NAME=' /etc/os-release &&
apt-get install -y --no-install-recommends python3 ca-certificates && grep '^VERSION_ID=' /etc/os-release &&
python3 --version && bash --version > /dev/null &&
echo 'Ubuntu ${{ matrix.ubuntu_version }} container test successful'" echo 'Ubuntu ${{ matrix.ubuntu_version }} container test successful'"

View File

@@ -14,12 +14,15 @@ RUN mkdir -p /var/run/sshd /var/log/supervisor \
&& echo 'ansible ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers && echo 'ansible ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
# Install base system packages in a single layer # Install base system packages in a single layer
RUN apt-get update && apt-get upgrade -y && apt-get install -y \
# Core system
RUN apt-get update && apt-get upgrade -y && apt-get install -y \ RUN apt-get update && apt-get upgrade -y && apt-get install -y \
# Core system # Core system
ca-certificates \ ca-certificates \
gnupg \ gnupg \
lsb-release \ lsb-release \
apt-transport-https \ apt-transport-https \
software-properties-common \
# SSH and system control # SSH and system control
openssh-server \ openssh-server \
sudo \ sudo \
@@ -50,8 +53,8 @@ RUN apt-get update && apt-get install -y \
# Web server # Web server
nginx \ nginx \
# Database # Database
mysql-server \ mariadb-server \
mysql-client \ mariadb-client \
# PHP and extensions # PHP and extensions
php8.4 \ php8.4 \
php8.4-fpm \ php8.4-fpm \
@@ -84,7 +87,7 @@ RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/
# Configure systemd # Configure systemd
RUN systemctl enable ssh \ RUN systemctl enable ssh \
&& systemctl enable nginx \ && systemctl enable nginx \
&& systemctl enable mysql \ && systemctl enable mysql mariadb \
&& systemctl enable php8.4-fpm && systemctl enable php8.4-fpm
# Create web directory structure # Create web directory structure

View File

@@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
# Services für LEMP-Stack starten # Services für LEMP-Stack starten
# MySQL starten # MySQL/MariaDB starten
service mysql start service mysql start || service mariadb start
# PHP-FPM starten # PHP-FPM starten
service php8.4-fpm start service php8.4-fpm start

View File

@@ -20,15 +20,15 @@
- name: Debug OS information - name: Debug OS information
debug: debug:
msg: | msg: |
OS Family: {{ ansible_os_family }} OS Family: {{ ansible_facts["os_family"] }}
Distribution: {{ ansible_distribution }} Distribution: {{ ansible_facts["distribution"] }}
Version: {{ ansible_distribution_version }} Version: {{ ansible_facts["distribution_version"] }}
Supported: Ubuntu/Debian family systems Supported: Ubuntu/Debian family systems
- name: Verify supported OS - name: Verify supported OS
fail: fail:
msg: "This playbook only supports Ubuntu/Debian systems. Detected: {{ ansible_os_family }}" msg: "This playbook only supports Ubuntu/Debian systems. Detected {{ ansible_facts['os_family'] }}"
when: ansible_os_family != "Debian" when: ansible_facts["os_family"] != "Debian"
# Environment Detection and Configuration # Environment Detection and Configuration
- name: Detect if running in Docker - name: Detect if running in Docker
@@ -54,7 +54,7 @@
vars: vars:
_auto_wp_url: >- _auto_wp_url: >-
{{ 'http://localhost:8080' if (deployment_environment == 'docker') {{ 'http://localhost:8080' if (deployment_environment == 'docker')
else 'http://' + (ansible_default_ipv4.address | default('localhost')) }} else 'http://' + (ansible_facts["default_ipv4"]["address"] | default('localhost')) }}
tags: always tags: always
- name: Debug deployment configuration - name: Debug deployment configuration
@@ -66,9 +66,12 @@
tags: always tags: always
vars: vars:
# Default PHP version (will be overridden by detection)
php_version: "8.4"
# WordPress Configuration # WordPress Configuration
wordpress_path: "{{ web_root }}" wordpress_path: "{{ web_root }}"
wordpress_url: "http://{{ ansible_default_ipv4.address | default('localhost') }}" wordpress_url: "http://{{ ansible_facts['default_ipv4']['address'] | default('localhost') }}"
# Database Configuration (use inventory variables or these defaults) # Database Configuration (use inventory variables or these defaults)
default_mysql_root_password: "{{ mysql_root_password | default('secure_root_password_123') }}" default_mysql_root_password: "{{ mysql_root_password | default('secure_root_password_123') }}"
@@ -81,6 +84,30 @@
# wp_admin_user, wp_admin_password, wp_admin_email, wp_site_title # wp_admin_user, wp_admin_password, wp_admin_email, wp_site_title
tasks: tasks:
# IMPORTANT: Pre-flight checks - create basic directory structure FIRST
- name: Ensure /var/www exists
file:
path: /var/www
state: directory
mode: '0755'
tags: [preflight]
- name: Create web root directory
file:
path: /var/www/html
state: directory
owner: www-data
group: www-data
mode: '0755'
tags: [preflight]
- name: Create PHP-FPM log directory
file:
path: "/var/log/php{{ php_version }}-fpm"
state: directory
mode: '0755'
tags: [preflight]
# Package Installation # Package Installation
- name: Update package cache - name: Update package cache
apt: apt:
@@ -88,10 +115,65 @@
cache_valid_time: 3600 cache_valid_time: 3600
tags: packages tags: packages
- name: Install all required packages - name: Install essential packages
package: apt:
name: "{{ packages }}" name:
- gnupg
- nginx
state: present state: present
tags: [packages, nginx]
- name: Detect available PHP version and set fallback
shell: |
if apt-cache show php8.4-fpm >/dev/null 2>&1; then
echo "8.4"
elif apt-cache show php8.3-fpm >/dev/null 2>&1; then
echo "8.3"
else
echo "none"
fi
register: php_version_detect
changed_when: false
tags: packages
- name: Set PHP version fact
set_fact:
php_version: "{{ php_version_detect.stdout }}"
tags: packages
- name: Install PHP with fallback (try 8.4, fallback to 8.3)
apt:
name:
- "php{{ php_version }}-fpm"
- "php{{ php_version }}-mysql"
- "php{{ php_version }}-curl"
- "php{{ php_version }}-gd"
- "php{{ php_version }}-intl"
- "php{{ php_version }}-mbstring"
- "php{{ php_version }}-soap"
- "php{{ php_version }}-xml"
- "php{{ php_version }}-xmlrpc"
- "php{{ php_version }}-zip"
- "php{{ php_version }}-opcache"
- "php{{ php_version }}-redis"
state: present
register: php_install_result
tags: packages
- name: Install remaining packages
package:
name: "{{ packages | reject('search', '^php') | list }}"
state: present
tags: packages
- name: Display PHP version installed
debug:
msg: "Using PHP version {{ php_version }}"
tags: packages
- name: Set PHP FPM service name dynamically
set_fact:
php_fpm_service: "php{{ php_version }}-fpm"
tags: packages tags: packages
# Service Management # Service Management

View File

@@ -1,6 +1,6 @@
--- ---
# Ubuntu/Debian LEMP WordPress installation # Ubuntu/Debian LEMP WordPress installation
- name: Install LEMP stack with WordPress (Ubuntu/Debian) - name: "Install LEMP stack with WordPress (Ubuntu/Debian)"
hosts: all hosts: all
become: yes become: yes
@@ -20,15 +20,15 @@
- name: Debug OS information - name: Debug OS information
debug: debug:
msg: | msg: |
OS Family: {{ ansible_os_family }} OS Family: {{ ansible_facts["os_family"] }}
Distribution: {{ ansible_distribution }} Distribution: {{ ansible_facts["distribution"] }}
Version: {{ ansible_distribution_version }} Version: {{ ansible_facts["distribution_version"] }}
Supported: Ubuntu/Debian family systems Supported: Ubuntu/Debian family systems
- name: Verify supported OS - name: Verify supported OS
fail: fail:
msg: "This playbook only supports Ubuntu/Debian systems. Detected: {{ ansible_os_family }}" msg: "This playbook only supports Ubuntu/Debian systems. Detected {{ ansible_facts['os_family'] }}"
when: ansible_os_family != "Debian" when: ansible_facts["os_family"] != "Debian"
# Environment Detection and Configuration # Environment Detection and Configuration
- name: Detect if running in Docker - name: Detect if running in Docker
@@ -54,7 +54,7 @@
vars: vars:
_auto_wp_url: >- _auto_wp_url: >-
{{ 'http://localhost:8080' if (deployment_environment == 'docker') {{ 'http://localhost:8080' if (deployment_environment == 'docker')
else 'http://' + (ansible_default_ipv4.address | default('localhost')) }} else 'http://' + (ansible_facts["default_ipv4"]["address"] | default('localhost')) }}
tags: always tags: always
- name: Debug deployment configuration - name: Debug deployment configuration
@@ -66,9 +66,12 @@
tags: always tags: always
vars: vars:
# Default PHP version (will be overridden by detection)
php_version: "8.4"
# WordPress Configuration # WordPress Configuration
wordpress_path: "{{ web_root }}" wordpress_path: "{{ web_root }}"
wordpress_url: "http://{{ ansible_default_ipv4.address | default('localhost') }}" wordpress_url: "http://{{ ansible_facts['default_ipv4']['address'] | default('localhost') }}"
# Database Configuration (use inventory variables or these defaults) # Database Configuration (use inventory variables or these defaults)
default_mysql_root_password: "{{ mysql_root_password | default('secure_root_password_123') }}" default_mysql_root_password: "{{ mysql_root_password | default('secure_root_password_123') }}"
@@ -84,6 +87,30 @@
update_cron_enabled: true update_cron_enabled: true
tasks: tasks:
# IMPORTANT: Pre-flight checks - create basic directory structure FIRST
- name: Ensure /var/www exists
file:
path: /var/www
state: directory
mode: '0755'
tags: [preflight]
- name: Create web root directory
file:
path: /var/www/html
state: directory
owner: www-data
group: www-data
mode: '0755'
tags: [preflight]
- name: Create PHP-FPM log directory
file:
path: "/var/log/php{{ php_version }}-fpm"
state: directory
mode: '0755'
tags: [preflight]
# Package Installation # Package Installation
- name: Update package cache - name: Update package cache
apt: apt:
@@ -91,10 +118,63 @@
cache_valid_time: 3600 cache_valid_time: 3600
tags: packages tags: packages
- name: Install all required packages - name: Install essential packages
package: apt:
name: "{{ packages }}" name:
- gnupg
- nginx
state: present state: present
tags: [packages, nginx]
- name: Detect available PHP version and set fallback
shell: |
if apt-cache show php8.4-fpm >/dev/null 2>&1; then
echo "8.4"
elif apt-cache show php8.3-fpm >/dev/null 2>&1; then
echo "8.3"
else
echo "none"
fi
register: php_version_detect
changed_when: false
tags: packages
- name: Set PHP version fact
set_fact:
php_version: "{{ php_version_detect.stdout }}"
tags: packages
- name: Install PHP with fallback (try 8.4, fallback to 8.3)
apt:
name:
- "php{{ php_version }}-fpm"
- "php{{ php_version }}-mysql"
- "php{{ php_version }}-curl"
- "php{{ php_version }}-gd"
- "php{{ php_version }}-intl"
- "php{{ php_version }}-mbstring"
- "php{{ php_version }}-soap"
- "php{{ php_version }}-xml"
- "php{{ php_version }}-xmlrpc"
- "php{{ php_version }}-zip"
state: present
register: php_install_result
tags: packages
- name: Install remaining packages
package:
name: "{{ packages | reject('search', '^php') | list }}"
state: present
tags: packages
- name: Display PHP version installed
debug:
msg: "Using PHP version {{ php_version }}"
tags: packages
- name: Set PHP FPM service name dynamically
set_fact:
php_fpm_service: "php{{ php_version }}-fpm"
tags: packages tags: packages
# Service Management # Service Management
@@ -363,10 +443,8 @@
- name: Configure WordPress auto-update settings - name: Configure WordPress auto-update settings
command: > command: >
wp option update auto_update_core_minor enabled wp option update auto_update_core_minor enabled
--path="{{ wordpress_path }}"
--allow-root --allow-root
environment:
HOME: "{{ wordpress_path }}"
ignore_errors: yes
tags: update tags: update
- name: Set up cron job for WordPress updates - name: Set up cron job for WordPress updates

View File

@@ -49,14 +49,14 @@ define( 'WP_CACHE_KEY_SALT', '{{ domain_name | default('localhost') }}' );
{% endif %} {% endif %}
// ** Authentifizierungs-Schlüssel und Salts ** // // ** Authentifizierungs-Schlüssel und Salts ** //
define( 'AUTH_KEY', '{{ ansible_date_time.epoch }}put your unique phrase here{{ ansible_hostname }}' ); define( 'AUTH_KEY', '{{ ansible_facts["date_time"]["epoch"] }}put your unique phrase here{{ ansible_facts["hostname"] }}' );
define( 'SECURE_AUTH_KEY', '{{ ansible_date_time.epoch }}put your unique phrase here{{ ansible_hostname }}2' ); define( 'SECURE_AUTH_KEY', '{{ ansible_facts["date_time"]["epoch"] }}put your unique phrase here{{ ansible_facts["hostname"] }}2' );
define( 'LOGGED_IN_KEY', '{{ ansible_date_time.epoch }}put your unique phrase here{{ ansible_hostname }}3' ); define( 'LOGGED_IN_KEY', '{{ ansible_facts["date_time"]["epoch"] }}put your unique phrase here{{ ansible_facts["hostname"] }}3' );
define( 'NONCE_KEY', '{{ ansible_date_time.epoch }}put your unique phrase here{{ ansible_hostname }}4' ); define( 'NONCE_KEY', '{{ ansible_facts["date_time"]["epoch"] }}put your unique phrase here{{ ansible_facts["hostname"] }}4' );
define( 'AUTH_SALT', '{{ ansible_date_time.epoch }}put your unique phrase here{{ ansible_hostname }}5' ); define( 'AUTH_SALT', '{{ ansible_facts["date_time"]["epoch"] }}put your unique phrase here{{ ansible_facts["hostname"] }}5' );
define( 'SECURE_AUTH_SALT', '{{ ansible_date_time.epoch }}put your unique phrase here{{ ansible_hostname }}6' ); define( 'SECURE_AUTH_SALT', '{{ ansible_facts["date_time"]["epoch"] }}put your unique phrase here{{ ansible_facts["hostname"] }}6' );
define( 'LOGGED_IN_SALT', '{{ ansible_date_time.epoch }}put your unique phrase here{{ ansible_hostname }}7' ); define( 'LOGGED_IN_SALT', '{{ ansible_facts["date_time"]["epoch"] }}put your unique phrase here{{ ansible_facts["hostname"] }}7' );
define( 'NONCE_SALT', '{{ ansible_date_time.epoch }}put your unique phrase here{{ ansible_hostname }}8' ); define( 'NONCE_SALT', '{{ ansible_facts["date_time"]["epoch"] }}put your unique phrase here{{ ansible_facts["hostname"] }}8' );
// ** WordPress Tabellen-Präfix ** // // ** WordPress Tabellen-Präfix ** //
$table_prefix = 'wp_'; $table_prefix = 'wp_';
@@ -71,8 +71,8 @@ define( 'WP_DEBUG_DISPLAY', false );
define( 'WP_HOME', 'https://{{ domain_name }}' ); define( 'WP_HOME', 'https://{{ domain_name }}' );
define( 'WP_SITEURL', 'https://{{ domain_name }}' ); define( 'WP_SITEURL', 'https://{{ domain_name }}' );
{% else %} {% else %}
define( 'WP_HOME', 'http://{{ domain_name }}{% if ansible_port is defined and ansible_port != 22 and ansible_port != 80 %}:{{ ansible_port }}{% endif %}' ); define( 'WP_HOME', 'http://{{ domain_name }}{% if ansible_facts["port"] is defined and ansible_facts["port"] != 22 and ansible_facts["port"] != 80 %}:{{ ansible_facts["port"] }}{% endif %}' );
define( 'WP_SITEURL', 'http://{{ domain_name }}{% if ansible_port is defined and ansible_port != 22 and ansible_port != 80 %}:{{ ansible_port }}{% endif %}' ); define( 'WP_SITEURL', 'http://{{ domain_name }}{% if ansible_facts["port"] is defined and ansible_facts["port"] != 22 and ansible_facts["port"] != 80 %}:{{ ansible_facts["port"] }}{% endif %}' );
{% endif %} {% endif %}
// ** Weitere Einstellungen ** // // ** Weitere Einstellungen ** //

View File

@@ -1,36 +1,26 @@
# Ubuntu/Debian family variables # Ubuntu/Debian family variables
--- ---
# Package names for Ubuntu/Debian systems # Package names for Ubuntu/Debian systems (PHP version is detected and installed dynamically)
packages: packages:
- nginx - mariadb-server
- mysql-server
- php8.4-fpm
- php8.4-mysql
- php8.4-curl
- php8.4-gd
- php8.4-intl
- php8.4-mbstring
- php8.4-soap
- php8.4-xml
- php8.4-xmlrpc
- php8.4-zip
- python3-pymysql - python3-pymysql
- unzip - unzip
- fail2ban - fail2ban
- ufw
# Service names # Service names
mysql_service: mysql mysql_service: mariadb
nginx_service: nginx nginx_service: nginx
php_fpm_service: php8.4-fpm php_fpm_service: php{{ php_version }}-fpm
# Package manager # Package manager
package_manager: apt package_manager: apt
# PHP paths # PHP paths (dynamic based on detected version)
php_fpm_config_path: /etc/php/8.4/fpm php_fpm_config_path: /etc/php/{{ php_version }}/fpm
php_cli_config_path: /etc/php/8.4/cli php_cli_config_path: /etc/php/{{ php_version }}/cli
php_fpm_pool_path: /etc/php/8.4/fpm/pool.d php_fpm_pool_path: /etc/php/{{ php_version }}/fpm/pool.d
php_fpm_socket: /run/php/php8.4-fpm.sock php_fpm_socket: /run/php/php{{ php_version }}-fpm.sock
# Nginx paths # Nginx paths
nginx_config_path: /etc/nginx nginx_config_path: /etc/nginx