From da2f0876dd45412b93353070b2bf9aae31ce9aa9 Mon Sep 17 00:00:00 2001 From: Sebastian Palencsar Date: Wed, 6 May 2026 14:09:22 +0200 Subject: [PATCH] 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 --- playbooks/lemp-wordpress-ultimate.yml | 14 +++++++------- playbooks/lemp-wordpress.yml | 14 +++++++------- templates/wp-config.php.j2 | 20 ++++++++++---------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/playbooks/lemp-wordpress-ultimate.yml b/playbooks/lemp-wordpress-ultimate.yml index 78c3e63..c3118e9 100755 --- a/playbooks/lemp-wordpress-ultimate.yml +++ b/playbooks/lemp-wordpress-ultimate.yml @@ -20,15 +20,15 @@ - name: Debug OS information debug: msg: | - OS Family: {{ ansible_os_family }} - Distribution: {{ ansible_distribution }} - Version: {{ ansible_distribution_version }} + OS Family: {{ ansible_facts["os_family"] }} + Distribution: {{ ansible_facts["distribution"] }} + Version: {{ ansible_facts["distribution_version"] }} Supported: Ubuntu/Debian family systems - name: Verify supported OS fail: - msg: "This playbook only supports Ubuntu/Debian systems. Detected: {{ ansible_os_family }}" - when: ansible_os_family != "Debian" + msg: "This playbook only supports Ubuntu/Debian systems. Detected {{ ansible_facts['os_family'] }}" + when: ansible_facts["os_family"] != "Debian" # Environment Detection and Configuration - name: Detect if running in Docker @@ -54,7 +54,7 @@ vars: _auto_wp_url: >- {{ '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 - name: Debug deployment configuration @@ -71,7 +71,7 @@ # WordPress Configuration 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) default_mysql_root_password: "{{ mysql_root_password | default('secure_root_password_123') }}" diff --git a/playbooks/lemp-wordpress.yml b/playbooks/lemp-wordpress.yml index 39ef93d..8334865 100755 --- a/playbooks/lemp-wordpress.yml +++ b/playbooks/lemp-wordpress.yml @@ -20,15 +20,15 @@ - name: Debug OS information debug: msg: | - OS Family: {{ ansible_os_family }} - Distribution: {{ ansible_distribution }} - Version: {{ ansible_distribution_version }} + OS Family: {{ ansible_facts["os_family"] }} + Distribution: {{ ansible_facts["distribution"] }} + Version: {{ ansible_facts["distribution_version"] }} Supported: Ubuntu/Debian family systems - name: Verify supported OS fail: - msg: "This playbook only supports Ubuntu/Debian systems. Detected: {{ ansible_os_family }}" - when: ansible_os_family != "Debian" + msg: "This playbook only supports Ubuntu/Debian systems. Detected {{ ansible_facts['os_family'] }}" + when: ansible_facts["os_family"] != "Debian" # Environment Detection and Configuration - name: Detect if running in Docker @@ -54,7 +54,7 @@ vars: _auto_wp_url: >- {{ '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 - name: Debug deployment configuration @@ -71,7 +71,7 @@ # WordPress Configuration 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) default_mysql_root_password: "{{ mysql_root_password | default('secure_root_password_123') }}" diff --git a/templates/wp-config.php.j2 b/templates/wp-config.php.j2 index 7533e36..6ac429c 100755 --- a/templates/wp-config.php.j2 +++ b/templates/wp-config.php.j2 @@ -49,14 +49,14 @@ define( 'WP_CACHE_KEY_SALT', '{{ domain_name | default('localhost') }}' ); {% endif %} // ** Authentifizierungs-Schlüssel und Salts ** // -define( 'AUTH_KEY', '{{ ansible_date_time.epoch }}put your unique phrase here{{ ansible_hostname }}' ); -define( 'SECURE_AUTH_KEY', '{{ ansible_date_time.epoch }}put your unique phrase here{{ ansible_hostname }}2' ); -define( 'LOGGED_IN_KEY', '{{ ansible_date_time.epoch }}put your unique phrase here{{ ansible_hostname }}3' ); -define( 'NONCE_KEY', '{{ ansible_date_time.epoch }}put your unique phrase here{{ ansible_hostname }}4' ); -define( 'AUTH_SALT', '{{ ansible_date_time.epoch }}put your unique phrase here{{ ansible_hostname }}5' ); -define( 'SECURE_AUTH_SALT', '{{ ansible_date_time.epoch }}put your unique phrase here{{ ansible_hostname }}6' ); -define( 'LOGGED_IN_SALT', '{{ ansible_date_time.epoch }}put your unique phrase here{{ ansible_hostname }}7' ); -define( 'NONCE_SALT', '{{ ansible_date_time.epoch }}put your unique phrase here{{ ansible_hostname }}8' ); +define( 'AUTH_KEY', '{{ ansible_facts["date_time"]["epoch"] }}put your unique phrase here{{ ansible_facts["hostname"] }}' ); +define( 'SECURE_AUTH_KEY', '{{ ansible_facts["date_time"]["epoch"] }}put your unique phrase here{{ ansible_facts["hostname"] }}2' ); +define( 'LOGGED_IN_KEY', '{{ ansible_facts["date_time"]["epoch"] }}put your unique phrase here{{ ansible_facts["hostname"] }}3' ); +define( 'NONCE_KEY', '{{ ansible_facts["date_time"]["epoch"] }}put your unique phrase here{{ ansible_facts["hostname"] }}4' ); +define( 'AUTH_SALT', '{{ ansible_facts["date_time"]["epoch"] }}put your unique phrase here{{ ansible_facts["hostname"] }}5' ); +define( 'SECURE_AUTH_SALT', '{{ ansible_facts["date_time"]["epoch"] }}put your unique phrase here{{ ansible_facts["hostname"] }}6' ); +define( 'LOGGED_IN_SALT', '{{ ansible_facts["date_time"]["epoch"] }}put your unique phrase here{{ ansible_facts["hostname"] }}7' ); +define( 'NONCE_SALT', '{{ ansible_facts["date_time"]["epoch"] }}put your unique phrase here{{ ansible_facts["hostname"] }}8' ); // ** WordPress Tabellen-Präfix ** // $table_prefix = 'wp_'; @@ -71,8 +71,8 @@ define( 'WP_DEBUG_DISPLAY', false ); define( 'WP_HOME', 'https://{{ domain_name }}' ); define( 'WP_SITEURL', 'https://{{ domain_name }}' ); {% 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_SITEURL', '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_facts["port"] is defined and ansible_facts["port"] != 22 and ansible_facts["port"] != 80 %}:{{ ansible_facts["port"] }}{% endif %}' ); {% endif %} // ** Weitere Einstellungen ** //