mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-15 08:30:46 +02:00
Added database patch to wordpress
This commit is contained in:
parent
918355743f
commit
de15c42de8
@ -2,22 +2,22 @@
|
|||||||
command: >
|
command: >
|
||||||
docker exec --user root {{ espocrm_name }}
|
docker exec --user root {{ espocrm_name }}
|
||||||
sed -i "s/'host' => .*/'host' => '{{ database_host }}',/" {{ espocrm_config_file }}
|
sed -i "s/'host' => .*/'host' => '{{ database_host }}',/" {{ espocrm_config_file }}
|
||||||
notify: docker compose up
|
notify: docker compose restart
|
||||||
|
|
||||||
- name: Update DB name
|
- name: Update DB name
|
||||||
command: >
|
command: >
|
||||||
docker exec --user root {{ espocrm_name }}
|
docker exec --user root {{ espocrm_name }}
|
||||||
sed -i "s/'dbname' => .*/'dbname' => '{{ database_name }}',/" {{ espocrm_config_file }}
|
sed -i "s/'dbname' => .*/'dbname' => '{{ database_name }}',/" {{ espocrm_config_file }}
|
||||||
notify: docker compose up
|
notify: docker compose restart
|
||||||
|
|
||||||
- name: Update DB user
|
- name: Update DB user
|
||||||
command: >
|
command: >
|
||||||
docker exec --user root {{ espocrm_name }}
|
docker exec --user root {{ espocrm_name }}
|
||||||
sed -i "s/'user' => .*/'user' => '{{ database_username }}',/" {{ espocrm_config_file }}
|
sed -i "s/'user' => .*/'user' => '{{ database_username }}',/" {{ espocrm_config_file }}
|
||||||
notify: docker compose up
|
notify: docker compose restart
|
||||||
|
|
||||||
- name: Update DB password
|
- name: Update DB password
|
||||||
command: >
|
command: >
|
||||||
docker exec --user root {{ espocrm_name }}
|
docker exec --user root {{ espocrm_name }}
|
||||||
sed -i "s/'password' => .*/'password' => '{{ database_password }}',/" {{ espocrm_config_file }}
|
sed -i "s/'password' => .*/'password' => '{{ database_password }}',/" {{ espocrm_config_file }}
|
||||||
notify: docker compose up
|
notify: docker compose restart
|
||||||
|
@ -2,23 +2,28 @@
|
|||||||
command: >
|
command: >
|
||||||
docker exec --user root {{ moodle_container }}
|
docker exec --user root {{ moodle_container }}
|
||||||
sed -i "s/^\$CFG->dbhost *= *.*/\$CFG->dbhost = '{{ database_host }}';/" {{ moodle_config }}
|
sed -i "s/^\$CFG->dbhost *= *.*/\$CFG->dbhost = '{{ database_host }}';/" {{ moodle_config }}
|
||||||
|
notify: docker compose restart
|
||||||
|
|
||||||
- name: Update DB name
|
- name: Update DB name
|
||||||
command: >
|
command: >
|
||||||
docker exec --user root {{ moodle_container }}
|
docker exec --user root {{ moodle_container }}
|
||||||
sed -i "s/^\$CFG->dbname *= *.*/\$CFG->dbname = '{{ database_name }}';/" {{ moodle_config }}
|
sed -i "s/^\$CFG->dbname *= *.*/\$CFG->dbname = '{{ database_name }}';/" {{ moodle_config }}
|
||||||
|
notify: docker compose restart
|
||||||
|
|
||||||
- name: Update DB user
|
- name: Update DB user
|
||||||
command: >
|
command: >
|
||||||
docker exec --user root {{ moodle_container }}
|
docker exec --user root {{ moodle_container }}
|
||||||
sed -i "s/^\$CFG->dbuser *= *.*/\$CFG->dbuser = '{{ database_username }}';/" {{ moodle_config }}
|
sed -i "s/^\$CFG->dbuser *= *.*/\$CFG->dbuser = '{{ database_username }}';/" {{ moodle_config }}
|
||||||
|
notify: docker compose restart
|
||||||
|
|
||||||
- name: Update DB password
|
- name: Update DB password
|
||||||
command: >
|
command: >
|
||||||
docker exec --user root {{ moodle_container }}
|
docker exec --user root {{ moodle_container }}
|
||||||
sed -i "s/^\$CFG->dbpass *= *.*/\$CFG->dbpass = '{{ database_password }}';/" {{ moodle_config }}
|
sed -i "s/^\$CFG->dbpass *= *.*/\$CFG->dbpass = '{{ database_password }}';/" {{ moodle_config }}
|
||||||
|
notify: docker compose restart
|
||||||
|
|
||||||
- name: Update CFG->wwwroot via sed in container
|
- name: Update CFG->wwwroot via sed in container
|
||||||
command: >
|
command: >
|
||||||
docker exec --user root {{ moodle_container }}
|
docker exec --user root {{ moodle_container }}
|
||||||
sed -i -E "s|^(\$CFG->wwwroot[[:space:]]*=[[:space:]]*).*$|\1'{{ domains | get_url(application_id, WEB_PROTOCOL) }}';|" {{ moodle_config }}
|
sed -i -E "s|^(\$CFG->wwwroot[[:space:]]*=[[:space:]]*).*$|\1'{{ domains | get_url(application_id, WEB_PROTOCOL) }}';|" {{ moodle_config }}
|
||||||
|
notify: docker compose restart
|
||||||
|
@ -13,7 +13,7 @@ features:
|
|||||||
port-ui-desktop: true
|
port-ui-desktop: true
|
||||||
oidc: true
|
oidc: true
|
||||||
central_database: true
|
central_database: true
|
||||||
logout: true
|
logout: true
|
||||||
server:
|
server:
|
||||||
csp:
|
csp:
|
||||||
flags:
|
flags:
|
||||||
|
28
roles/web-app-wordpress/tasks/01_patch_config.yml
Normal file
28
roles/web-app-wordpress/tasks/01_patch_config.yml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# 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
|
||||||
|
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
|
||||||
|
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
|
||||||
|
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
|
||||||
|
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 }}
|
||||||
|
notify: docker compose restart
|
||||||
|
|
||||||
|
- name: "Flush handlers to reinitialize new database credentials"
|
||||||
|
meta: flush_handlers
|
@ -1,6 +1,6 @@
|
|||||||
- name: "Run WordPress core install via WP CLI"
|
- name: "Run WordPress core install via WP CLI"
|
||||||
command: >
|
command: >
|
||||||
docker-compose exec -T -u www-data application
|
docker exec -u {{ wordpress_user }} {{ wordpress_container }}
|
||||||
wp core install
|
wp core install
|
||||||
--url="{{ domains | get_url(application_id, WEB_PROTOCOL) }}"
|
--url="{{ domains | get_url(application_id, WEB_PROTOCOL) }}"
|
||||||
--title="{{ applications | get_app_conf(application_id, 'title', True) }}"
|
--title="{{ applications | get_app_conf(application_id, 'title', True) }}"
|
@ -25,13 +25,23 @@
|
|||||||
dest: "{{ host_msmtp_conf }}"
|
dest: "{{ host_msmtp_conf }}"
|
||||||
notify: docker compose up
|
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
|
||||||
|
register: wp_config_file_exists
|
||||||
|
changed_when: false
|
||||||
|
failed_when: false
|
||||||
|
|
||||||
|
- name: Patch WordPress wp-config.php with updated DB credentials
|
||||||
|
include_tasks: 01_patch_config.yml
|
||||||
|
when: wp_config_file_exists.rc == 0
|
||||||
|
|
||||||
- name: "Install wordpress"
|
- name: "Install wordpress"
|
||||||
include_tasks: install.yml
|
include_tasks: 02_install.yml
|
||||||
|
|
||||||
- name: "Install and activate WordPress plugins"
|
- name: "Install and activate WordPress plugins"
|
||||||
block:
|
block:
|
||||||
- name: "Iterate through WordPress plugins"
|
- name: "Iterate through WordPress plugins"
|
||||||
include_tasks: plugin.yml
|
include_tasks: 03_enable_plugin.yml
|
||||||
loop: "{{ wordpress_plugins }}"
|
loop: "{{ wordpress_plugins }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
label: "{{ item.key }}"
|
label: "{{ item.key }}"
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
application:
|
application:
|
||||||
{% include 'roles/docker-container/templates/base.yml.j2' %}
|
{% include 'roles/docker-container/templates/base.yml.j2' %}
|
||||||
image: {{ wordpress_custom_image }}
|
image: {{ wordpress_custom_image }}
|
||||||
container_name: {{ wordpress_name }}
|
container_name: {{ wordpress_container }}
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
ports:
|
ports:
|
||||||
|
@ -7,9 +7,11 @@ host_msmtp_conf: "{{docker_compose.directories.config}}msmtprc.conf"
|
|||||||
wordpress_max_upload_size: "{{ applications | get_app_conf(application_id, 'max_upload_size') }}"
|
wordpress_max_upload_size: "{{ applications | get_app_conf(application_id, 'max_upload_size') }}"
|
||||||
wordpress_custom_image: "wordpress_custom"
|
wordpress_custom_image: "wordpress_custom"
|
||||||
wordpress_docker_html_path: "/var/www/html"
|
wordpress_docker_html_path: "/var/www/html"
|
||||||
|
wordpress_docker_conf_path: "{{ wordpress_docker_html_path }}/wp-config.php"
|
||||||
wordpress_version: "{{ applications | get_app_conf(application_id, 'docker.services.wordpress.version', True) }}"
|
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_image: "{{ applications | get_app_conf(application_id, 'docker.services.wordpress.image', True) }}"
|
||||||
wordpress_name: "{{ applications | get_app_conf(application_id, 'docker.services.wordpress.name', 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_volume: "{{ applications | get_app_conf(application_id, 'docker.volumes.data', True) }}"
|
||||||
wordpress_domains: "{{ applications | get_app_conf(application_id, 'server.domains.canonical', 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_plugins: "{{ applications | get_app_conf(application_id, 'plugins', True) | dict2items }}"
|
||||||
|
wordpress_user: "www-data"
|
Loading…
x
Reference in New Issue
Block a user