Commit 3e15d5d2 authored by Visay Keo's avatar Visay Keo

[FEATURE] Allow setting to search replace db content

parent 4ecc1221
CHANGELOG
=========
3.0-dev
-------
3.0.7
-----
- [FEATURE] Allow setting to search replace db content
- [IMP] Set data directory list to sync in variable
3.0.6
......
......@@ -161,6 +161,27 @@ To execute this task only, run this command:
bin-dir/syncontent --ansible-tags=db
```
For TYPO3, most of the time after restoring data, the domain records need to be adjusted to match your local setup.
In this case, you can provide a list of pair value so that this tool can search and replace it before restoring to your
local system.
To do that, create a file called `main.yml` in `ansible/roles/database/defaults/` directory and add the following content:
```
---
# Content replacement in database
replacement:
1:
search: live-domain.com
replace: local-site:8080
2:
search: live-domain2.net
replace: domain2.local-site:8080
```
`replacement`, `search` and `replace` are keyword but for `1` and `2` you can use any strings to define your content type.
Just add more array list with `search` and `replace` pair if needed.
### 3. cleanup
The last step is to run some necessary commands needed by the framework for the application to work.
......
......@@ -5,6 +5,11 @@
synchronize: mode=pull src="{{ remote_dump }}" dest="/tmp/{{ ssh_user }}/db_dump.sql"
when: not from_cache|bool
- name: Search and replace content in database dump
local_action: replace dest="/tmp/{{ ssh_user }}/db_dump.sql" regexp="{{ item.value.search }}" replace="{{ item.value.replace }}"
with_dict: replacement | default({})
when: not from_cache|bool
- name: Drop local database
local_action: shell {{ bin_path }}/dockertypo3 run db mysqladmin -h db -u root -proot drop dockertypo3 -f
chdir="{{ local_path }}"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment