mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-30 15:28:12 +02:00
Optimized docker handlers for espocrm and wordpress
This commit is contained in:
@@ -1,24 +1,24 @@
|
||||
# The seeds need to be executed as root, because www-data isn't allowed to create files in the wordpress directory
|
||||
|
||||
- name: Update DB host in wp-config.php
|
||||
- name: Update DB host in {{ wordpress_config_file }}
|
||||
command: >
|
||||
docker exec --user root {{ wordpress_container }}
|
||||
sed -i "s/define(\s*'DB_HOST'\s*,\s*'[^']*'\s*);/define( 'DB_HOST', '{{ database_host }}:{{ database_port }}' );/i" {{ wordpress_docker_conf_path }}
|
||||
notify: docker compose restart
|
||||
|
||||
- name: Update DB name in wp-config.php
|
||||
- name: Update DB name in {{ wordpress_config_file }}
|
||||
command: >
|
||||
docker exec --user root {{ wordpress_container }}
|
||||
sed -i "s/define(\s*'DB_NAME'\s*,\s*'[^']*'\s*);/define( 'DB_NAME', '{{ database_name }}' );/i" {{ wordpress_docker_conf_path }}
|
||||
notify: docker compose restart
|
||||
|
||||
- name: Update DB user in wp-config.php
|
||||
- name: Update DB user in {{ wordpress_config_file }}
|
||||
command: >
|
||||
docker exec --user root {{ wordpress_container }}
|
||||
sed -i "s/define(\s*'DB_USER'\s*,\s*'[^']*'\s*);/define( 'DB_USER', '{{ database_username }}' );/i" {{ wordpress_docker_conf_path }}
|
||||
notify: docker compose restart
|
||||
|
||||
- name: Update DB password in wp-config.php
|
||||
- name: Update DB password in {{ wordpress_config_file }}
|
||||
command: >
|
||||
docker exec --user root {{ wordpress_container }}
|
||||
sed -i "s/define(\s*'DB_PASSWORD'\s*,\s*'[^']*'\s*);/define( 'DB_PASSWORD', '{{ database_password }}' );/i" {{ wordpress_docker_conf_path }}
|
||||
|
@@ -2,6 +2,8 @@
|
||||
- name: "load docker and db for {{application_id}}"
|
||||
include_role:
|
||||
name: cmp-db-docker
|
||||
vars:
|
||||
docker_compose_flush_handlers: false
|
||||
|
||||
- name: "Include role srv-proxy-6-6-domain for {{ application_id }}"
|
||||
include_role:
|
||||
@@ -25,13 +27,16 @@
|
||||
dest: "{{ host_msmtp_conf }}"
|
||||
notify: docker compose up
|
||||
|
||||
- name: Check if wp-config.php exists in WordPress
|
||||
command: docker exec -u {{ wordpress_user }} {{ wordpress_container }} test -f {{ wordpress_docker_html_path }}/wp-config.php
|
||||
- name: Flush handlers to make {{ wordpress_config_file }} available before patch
|
||||
meta: flush_handlers
|
||||
|
||||
- name: Check if {{ wordpress_config_file }} exists in WordPress
|
||||
command: docker exec -u {{ wordpress_user }} {{ wordpress_container }} test -f {{ wordpress_config_path }}
|
||||
register: wp_config_file_exists
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
|
||||
- name: Patch WordPress wp-config.php with updated DB credentials
|
||||
- name: Patch WordPress {{ wordpress_config_file }} with updated DB credentials
|
||||
include_tasks: 01_patch_config.yml
|
||||
when: wp_config_file_exists.rc == 0
|
||||
|
||||
|
@@ -7,11 +7,13 @@ host_msmtp_conf: "{{docker_compose.directories.config}}msmtprc.conf"
|
||||
wordpress_max_upload_size: "{{ applications | get_app_conf(application_id, 'max_upload_size') }}"
|
||||
wordpress_custom_image: "wordpress_custom"
|
||||
wordpress_docker_html_path: "/var/www/html"
|
||||
wordpress_docker_conf_path: "{{ wordpress_docker_html_path }}/wp-config.php"
|
||||
wordpress_docker_conf_path: "{{ wordpress_config_path }}"
|
||||
wordpress_version: "{{ applications | get_app_conf(application_id, 'docker.services.wordpress.version', True) }}"
|
||||
wordpress_image: "{{ applications | get_app_conf(application_id, 'docker.services.wordpress.image', True) }}"
|
||||
wordpress_container: "{{ applications | get_app_conf(application_id, 'docker.services.wordpress.name', True) }}"
|
||||
wordpress_volume: "{{ applications | get_app_conf(application_id, 'docker.volumes.data', True) }}"
|
||||
wordpress_domains: "{{ applications | get_app_conf(application_id, 'server.domains.canonical', True) }}"
|
||||
wordpress_plugins: "{{ applications | get_app_conf(application_id, 'plugins', True) | dict2items }}"
|
||||
wordpress_user: "www-data"
|
||||
wordpress_user: "www-data"
|
||||
wordpress_config_file: "wp-config.php"
|
||||
wordpress_config_path: "{{ wordpress_docker_html_path }}/{{ wordpress_config_file }}"
|
Reference in New Issue
Block a user