diff --git a/README.md b/README.md index 2f11b0d4f..43c3a8e0a 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ Role Variables symfony2_project_env: prod symfony2_project_console_opts: '' symfony2_project_composer_opts: '--no-dev --optimize-autoloader' + symfony2_project_keep_releases: 5 ``` Dependencies diff --git a/defaults/main.yml b/defaults/main.yml index 40bbbc3bc..26eb43f22 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -4,3 +4,4 @@ symfony2_project_release: 1 symfony2_project_branch: master symfony2_project_php_path: php +symfony2_project_keep_releases: 5 diff --git a/tasks/main.yml b/tasks/main.yml index acf2a0051..6aecf4ed0 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -32,3 +32,5 @@ shell: cd {{symfony2_project_root}}/releases/{{symfony2_project_release}} && if $(grep doctrine-migrations-bundle composer.json); then {{symfony2_project_php_path}} app/console doctrine:migrations:migrate -n; fi - name: Create symlink file: state=link src={{symfony2_project_root}}/releases/{{symfony2_project_release}} path={{symfony2_project_root}}/current +- name: Cleanup releases. + shell: cd {{symfony2_project_root}}/releases && ls -t1 | tail -n +$(({{symfony2_project_keep_releases}}+1)) | xargs -n1 rm -rf