mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-11-05 12:48:14 +00:00
- networks: add web-app-drupal subnet 192.168.104.80/28 - ports: map localhost http port 8060 - add role files: tasks, vars, schema, users, templates (Dockerfile, docker-compose, settings.local.php, upload.ini) - add docs: README.md and Administration.md Ref: https://chatgpt.com/share/690535c5-b55c-800f-8556-5335a6b8a33f
20 lines
878 B
YAML
20 lines
878 B
YAML
- name: "Set trusted_host_patterns for canonical domains"
|
|
vars:
|
|
patterns: "{{ DRUPAL_DOMAINS
|
|
| map('regex_replace','\\\\.','\\\\\\\\.')
|
|
| map('regex_replace','^','^')
|
|
| map('regex_replace','$','$')
|
|
| list }}"
|
|
php_array: "{{ patterns | to_json }}"
|
|
command: >
|
|
docker exec -u root {{ DRUPAL_CONTAINER }} bash -lc
|
|
"php -r '
|
|
$f="{{ DRUPAL_DOCKER_CONF_PATH }}/settings.local.php";
|
|
$c=file_exists($f)?file_get_contents($f):"<?php\n";
|
|
// Remove existing assignment of $settings[\"trusted_host_patterns\"] (if any)
|
|
$c=preg_replace(\"/(\\\\$settings\\['trusted_host_patterns'\\]\\s*=).*?;/s\", \"\", $c);
|
|
$c.="\n\$settings[\'trusted_host_patterns\'] = ".var_export(json_decode("{{ php_array|e }}", true), true).";\n";
|
|
file_put_contents($f,$c);
|
|
'"
|
|
changed_when: true
|