Skip to content

Commit

Permalink
feat: allow deleting files after deployment (#44)
Browse files Browse the repository at this point in the history
* feat: allow deleting files after deployment

* Update remove_files.yml

* doc: add remove files documentation
  • Loading branch information
thislg authored Sep 20, 2023
1 parent 0ac454b commit 6454ab8
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 2 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Common deploy tasks for projects made at Le Phare.
* [Messenger](docs/symfony/messenger.md)
* [Secrets](docs/symfony/secrets.md)
* [Permissions](docs/permissions.md)
* [Remove files](docs/remove_files.md)

## Role Variables

Expand Down Expand Up @@ -79,7 +80,10 @@ The defaults vars declared in this module:
lephare_permission_paths: [ "{{ ansistrano_release_path.stdout }}/var/cache", "{{ ansistrano_shared_path }}/var/logs" ]
lephare_permission_users: [ "www-data", "{{ ansible_user }}" ]

Additionnaly, this module change some defaults vars from `cbrunnkvist.ansistrano-symfony-deploy` and `ansistrano.deploy`
lephare_remove_files: false
lephare_remove_files_paths: []

Additionally, this module change some defaults vars from `cbrunnkvist.ansistrano-symfony-deploy` and `ansistrano.deploy`

ansistrano_after_symlink_tasks_file: "../../lephare.ansible-deploy/config/after_symlink.yml"
ansistrano_before_symlink_tasks_file: "../../lephare.ansible-deploy/config/before_symlink.yml"
Expand Down Expand Up @@ -115,7 +119,7 @@ Additionnaly, this module change some defaults vars from `cbrunnkvist.ansistrano

### Dump database before composer

**NB: Ony works with postgres installed on the app node**
**NB: Only works with postgres installed on the app node**

Backup la base de données de la version courante lors du déploiement. Un fichier portant le nom de
la base de données est placer dans la release courante.
Expand Down
3 changes: 3 additions & 0 deletions config/before_symlink.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@

- include_tasks: "../../lephare.ansible-deploy/config/steps/couscous.yml"
when: lephare_couscous_enable

- include_tasks: "../../lephare.ansible-deploy/config/steps/remove_files.yml"
when: lephare_remove_files
5 changes: 5 additions & 0 deletions config/steps/remove_files.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- name: LEPHARE | remove files
file:
state: absent
path: "{{ item }}"
loop: "{{ (lephare_remove_files_paths | flatten ) }}"
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ lephare_couscous_self_update: true

lephare_dump_database: false

lephare_remove_files: false
lephare_remove_files_paths: []

# Symfony messenger defaults
symfony_messenger_enable: false
symfony_messenger_strategy: crontab
Expand Down
20 changes: 20 additions & 0 deletions docs/remove_files.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Remove files

## Condition

`lephare_remove_files` must be set to `true`.

## When

During `lephare_before_symlink_tasks_file`

## Description

If enabled, files present in `lephare_remove_files_paths` will be removed from release. This is useful to ensure some files are not present in production even if they are committed in your repository.

## Variables

| Variable | Type | Default | Description |
| -------------------------- | -------- | ----------------- | --------------------------------- |
| lephare_remove_files | boolean | `false` | Toggles remove files feature |
| lephare_remove_files_paths | string[] | `[]` | List of files to remove |

0 comments on commit 6454ab8

Please sign in to comment.