diff --git a/inventory/docker.yml b/inventory/docker.yml index 68a68c2..eb89ca8 100644 --- a/inventory/docker.yml +++ b/inventory/docker.yml @@ -1,6 +1,6 @@ # Docker Testing Environment Inventory # For testing deployments before production - +--- wordpress_servers: hosts: docker-test: @@ -10,22 +10,22 @@ wordpress_servers: ansible_ssh_pass: ansible123 ansible_become_pass: ansible123 domain_name: localhost - + # SSL Configuration (usually disabled for testing) ssl_enabled: false - + # WordPress Database (Test credentials) mysql_root_password: "test_root_password" wordpress_db_name: "wordpress" wordpress_db_user: "wp_user" wordpress_db_password: "test_wp_password" - + # WordPress Admin (Test credentials) wp_admin_user: "admin" wp_admin_password: "test_admin_password" wp_admin_email: "admin@localhost" wp_site_title: "Test WordPress Site" - + # Ultimate Features (for testing Ultimate-Playbook) enable_redis: true enable_opcache: true diff --git a/inventory/production.yml b/inventory/production.yml index b6555a0..609c0f5 100644 --- a/inventory/production.yml +++ b/inventory/production.yml @@ -1,6 +1,6 @@ # Production Server Configuration # SECURITY: Change all passwords before deployment! - +--- wordpress_servers: hosts: your-server.example.com: @@ -9,23 +9,23 @@ wordpress_servers: # ansible_ssh_pass: "your_password" # Use SSH keys instead! # ansible_become_pass: "your_sudo_password" # Use passwordless sudo instead! domain_name: example.com - + # SSL Configuration ssl_enabled: false # Set to true for HTTPS with Let's Encrypt ssl_email: admin@example.com # Required if ssl_enabled=true - + # WordPress Database (CHANGE THESE!) mysql_root_password: "CHANGE_ME_ROOT_PASSWORD" wordpress_db_name: "wordpress" wordpress_db_user: "wp_user" wordpress_db_password: "CHANGE_ME_WP_PASSWORD" - + # WordPress Admin (CHANGE THESE!) wp_admin_user: "admin" wp_admin_password: "CHANGE_ME_ADMIN_PASSWORD" wp_admin_email: "admin@example.com" wp_site_title: "My WordPress Site" - + # Ultimate Performance Features (for lemp-wordpress-ultimate.yml) enable_redis: false # Redis object caching enable_opcache: false # PHP OPcache optimization diff --git a/playbooks/lemp-wordpress-ultimate.yml b/playbooks/lemp-wordpress-ultimate.yml index 2cede98..8dacb78 100644 --- a/playbooks/lemp-wordpress-ultimate.yml +++ b/playbooks/lemp-wordpress-ultimate.yml @@ -44,14 +44,17 @@ - name: Set deployment environment (auto-detect or override) set_fact: - deployment_environment: "{{ deployment_environment | default('docker' if docker_env.stat.exists else 'bare_metal') }}" + deployment_environment: >- + {{ deployment_environment | default('docker' if docker_env.stat.exists else 'bare_metal') }} tags: always - name: Set WordPress site URL with smart defaults set_fact: wp_site_url: "{{ wp_site_url | default(_auto_wp_url) }}" vars: - _auto_wp_url: "{{ 'http://localhost:8080' if (deployment_environment == 'docker') else 'http://' + (ansible_default_ipv4.address | default('localhost')) }}" + _auto_wp_url: >- + {{ 'http://localhost:8080' if (deployment_environment == 'docker') + else 'http://' + (ansible_default_ipv4.address | default('localhost')) }} tags: always - name: Debug deployment configuration @@ -223,7 +226,7 @@ -keyout {{ ssl_cert_key_path | default('/etc/ssl/private/nginx-selfsigned.key') }} -out {{ ssl_cert_path | default('/etc/ssl/certs/nginx-selfsigned.crt') }} -subj "/C=DE/ST=State/L=City/O=Organization/OU=OrgUnit/CN={{ domain_name }}" - when: + when: - ssl_enabled | default(false) - not (ssl_cert_path is defined and ssl_cert_key_path is defined) tags: ssl @@ -231,7 +234,9 @@ # Nginx Configuration - name: Create Nginx configuration for WordPress template: - src: ../templates/{% if ssl_enabled | default(false) %}wordpress-ssl.nginx.j2{% else %}wordpress.nginx.j2{% endif %} + src: >- + ../templates/{% if ssl_enabled | default(false) %}wordpress-ssl.nginx.j2{% + else %}wordpress.nginx.j2{% endif %} dest: "{{ nginx_sites_available }}/wordpress" backup: yes notify: restart nginx @@ -505,7 +510,7 @@ block: | # Ultimate Performance optimizations (unique directives only) keepalive_requests 1000; - + # Enhanced Gzip compression gzip_vary on; gzip_min_length 1000; @@ -520,18 +525,18 @@ application/xml+rss application/atom+xml image/svg+xml; - + # Buffer sizes client_body_buffer_size 128k; client_max_body_size 64m; client_header_buffer_size 1k; large_client_header_buffers 4 4k; - + # Timeouts client_body_timeout 12; client_header_timeout 12; send_timeout 10; - + # Cache for file handles open_file_cache max=200000 inactive=20s; open_file_cache_valid 30s; @@ -554,7 +559,8 @@ - name: Display Nginx optimization status debug: - msg: "Nginx performance optimization {{ 'ENABLED' if enable_nginx_optimization | default(false) else 'DISABLED' }}" + msg: >- + Nginx performance optimization {{ 'ENABLED' if enable_nginx_optimization | default(false) else 'DISABLED' }} tags: nginx-optimization handlers: diff --git a/playbooks/lemp-wordpress.yml b/playbooks/lemp-wordpress.yml index 933dd2c..60926a1 100644 --- a/playbooks/lemp-wordpress.yml +++ b/playbooks/lemp-wordpress.yml @@ -44,14 +44,17 @@ - name: Set deployment environment (auto-detect or override) set_fact: - deployment_environment: "{{ deployment_environment | default('docker' if docker_env.stat.exists else 'bare_metal') }}" + deployment_environment: >- + {{ deployment_environment | default('docker' if docker_env.stat.exists else 'bare_metal') }} tags: always - name: Set WordPress site URL with smart defaults set_fact: wp_site_url: "{{ wp_site_url | default(_auto_wp_url) }}" vars: - _auto_wp_url: "{{ 'http://localhost:8080' if (deployment_environment == 'docker') else 'http://' + (ansible_default_ipv4.address | default('localhost')) }}" + _auto_wp_url: >- + {{ 'http://localhost:8080' if (deployment_environment == 'docker') + else 'http://' + (ansible_default_ipv4.address | default('localhost')) }} tags: always - name: Debug deployment configuration @@ -223,7 +226,7 @@ -keyout {{ ssl_cert_key_path | default('/etc/ssl/private/nginx-selfsigned.key') }} -out {{ ssl_cert_path | default('/etc/ssl/certs/nginx-selfsigned.crt') }} -subj "/C=DE/ST=State/L=City/O=Organization/OU=OrgUnit/CN={{ domain_name }}" - when: + when: - ssl_enabled | default(false) - not (ssl_cert_path is defined and ssl_cert_key_path is defined) tags: ssl @@ -231,7 +234,9 @@ # Nginx Configuration - name: Configure Nginx for WordPress template: - src: ../templates/{% if ssl_enabled | default(false) %}wordpress-ssl.nginx.j2{% else %}wordpress.nginx.j2{% endif %} + src: >- + ../templates/{% if ssl_enabled | default(false) %}wordpress-ssl.nginx.j2{% + else %}wordpress.nginx.j2{% endif %} dest: "{{ nginx_sites_available }}/wordpress" notify: restart nginx tags: nginx