Skip to content

Commit

Permalink
feat: anonymization using DbToolsBundle
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmirloup committed Jan 20, 2025
1 parent 25242ec commit 347dbe6
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 17 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,29 @@ db_pull_local_database_name: postgres
db_pull_local_database_password: root
db_pull_local_database_port: 5432
db_pull_anonymization_database_user: postgres
db_pull_anonymization_database_host: localhost
db_pull_anonymization_database_name: postgres
db_pull_anonymization_database_password: root
db_pull_anonymization_database_port: 5432
db_pull_anonymization_database_url: "postgresql://{{ db_pull_anonymization_database_user }}:{{ db_pull_anonymization_database_password }}@{{ db_pull_anonymization_database_host }}:{{ db_pull_anonymization_database_port }}/{{ db_pull_anonymization_database_name }}?serverVersion=15"
db_pull_max_age: -1d
db_pull_database_type: postgres
db_pull_skip_restore: false
db_pull_exclude_table: []
db_pull_exclude_table_data: []
db_pull_anonymize: false
db_pull_anonymization_command: >-
chdir={{ ansistrano_deploy_to }}/current
DATABASE_URL="{{ db_pull_anonymization_database_url }}"
APP_ENV={{ symfony_env }}
php bin/console db-tools:anonymize --local-database --no-restore -n {{ db_pull_remote_backup_path }}/{{ db_pull_remote_database_name }}-{{ ansible_date_time.iso8601 }}.dump
```

Example Playbook
Expand Down
15 changes: 15 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ db_pull_local_database_name: postgres
db_pull_local_database_password: root
db_pull_local_database_port: 5432

db_pull_anonymization_database_user: postgres
db_pull_anonymization_database_host: localhost
db_pull_anonymization_database_name: postgres
db_pull_anonymization_database_password: root
db_pull_anonymization_database_port: 5432

db_pull_anonymization_database_url: "postgresql://{{ db_pull_anonymization_database_user }}:{{ db_pull_anonymization_database_password }}@{{ db_pull_anonymization_database_host }}:{{ db_pull_anonymization_database_port }}/{{ db_pull_anonymization_database_name }}?serverVersion=15"

db_pull_max_age: -1d

db_pull_database_type: postgres
Expand All @@ -23,3 +31,10 @@ db_pull_skip_restore: false

db_pull_exclude_table: []
db_pull_exclude_table_data: []

db_pull_anonymize: false
db_pull_anonymization_command: >-
chdir={{ ansistrano_deploy_to }}/current
DATABASE_URL="{{ db_pull_anonymization_database_url }}"
APP_ENV={{ symfony_env }}
php bin/console db-tools:anonymize --local-database --no-restore -n {{ db_pull_remote_backup_path }}/{{ db_pull_remote_database_name }}-{{ ansible_date_time.iso8601 }}.dump
4 changes: 2 additions & 2 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ galaxy_info:
author: Erwan Richard
description: One way sync between remote and local databases
company: Le Phare
issue_tracker_url: https://github.com/erichard/ansible-database-sync
issue_tracker_url: https://github.com/le-phare/ansible-db-pull/issues

license: MIT

min_ansible_version: 1.2
min_ansible_version: "1.2"

galaxy_tags:
- database
Expand Down
4 changes: 4 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
- include_tasks: "{{ db_pull_database_type }}/dump.yml"
when: local_dump.matched == 0

- name: Anonymize using DbToolsBundle
shell: {{ db_pull_anonymization_database_url }}
when: db_pull_anonymize

- name: Ensure database dump folder exists
delegate_to: localhost
become: false
Expand Down
8 changes: 0 additions & 8 deletions tasks/mysql.yml

This file was deleted.

7 changes: 0 additions & 7 deletions tasks/postgres.yml

This file was deleted.

0 comments on commit 347dbe6

Please sign in to comment.