Skip to content

Commit

Permalink
Merge branch 'maschmann-cleanup-and-introduction-of-item-iterator'
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Aschmann committed May 22, 2015
2 parents df78d6a + 278b233 commit 23c1df8
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 24 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Changelog

## v0.1

* structural refactoring (creating files, directories, ...)
* added cleanup-script to remove old releases
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ Role Variables
symfony2_project_env: prod
symfony2_project_console_opts: ''
symfony2_project_composer_opts: '--no-dev --optimize-autoloader'
<<<<<<< HEAD
symfony2_project_keep_releases: 5
=======
symfony2_project_clean_versioning: true
>>>>>>> 86069b4780bce7951c4324a6312b1d99b37fa6e8
```

Dependencies
Expand Down
4 changes: 4 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
symfony2_project_release: 1
symfony2_project_branch: master
symfony2_project_php_path: php
<<<<<<< HEAD
symfony2_project_keep_releases: 5
=======
symfony2_project_clean_versioning: true
>>>>>>> 86069b4780bce7951c4324a6312b1d99b37fa6e8
70 changes: 46 additions & 24 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,58 @@
---
# tasks file for symfony2
- name: Create the release {{symfony2_project_release}} directory.
file: state=directory path={{symfony2_project_root}}/releases/{{symfony2_project_release}}
- name: Create the shared directory.
file: state=directory path={{symfony2_project_root}}/shared
- name: Create the shared/app/config directory.
file: state=directory path={{symfony2_project_root}}/shared/app/config
- name: Create the shared/web/uploads directory.
file: state=directory path={{symfony2_project_root}}/shared/web/uploads
- name: Create the shared/app/logs directory.
file: state=directory path={{symfony2_project_root}}/shared/app/logs
- name: Create/prepare directories for release and shared data.
file: state=directory path={{item.path}}
with_items:
- { path: "{{symfony2_project_root}}/releases/{{symfony2_project_release}}" }
- { path: "{{symfony2_project_root}}/shared" }
- { path: "{{symfony2_project_root}}/shared/app/config" }
- { path: "{{symfony2_project_root}}/shared/app/uploads" }
- { path: "{{symfony2_project_root}}/shared/app/logs" }

- name: Pull sources from the repository.
git: repo={{symfony2_project_repo}} dest={{symfony2_project_root}}/releases/{{symfony2_project_release}} version={{symfony2_project_branch}}
- name: Check if shared/app/config/parameters.ini exists
git: repo={{symfony2_project_repo}} dest={{symfony2_project_root}}/releases/{{symfony2_project_release}} version={{symfony2_project_branch}} accept_hostkey=yes

- name: Clean out versioning.
file: state=absent path={{symfony2_project_root}}/releases/{{symfony2_project_release}}/.git
when: symfony2_project_clean_versioning == true

- name: Create symlinks to shared directories.
file: state=link src={{item.src}} path={{item.path}}
with_items:
- { src: "{{symfony2_project_root}}/shared/web/uploads", path: "{{symfony2_project_root}}/releases/{{symfony2_project_release}}/uploads" }
- { src: "{{symfony2_project_root}}/shared/app/logs", path: "{{symfony2_project_root}}/releases/{{symfony2_project_release}}/logs" }

- name: Check if shared/app/config/parameters.ini exists.
stat: path={{symfony2_project_root}}/shared/app/config/parameters.ini
register: parameters_ini
- name: Create symlink for app/config/parameters.ini from shared directory

- name: Create symlink for app/config/parameters.ini from shared directory.
shell: ln -s {{symfony2_project_root}}/shared/app/config/parameters.ini {{symfony2_project_root}}/releases/{{symfony2_project_release}}/app/config/parameters.ini creates={{symfony2_project_root}}/releases/{{symfony2_project_release}}/app/config/parameters.ini
when: parameters_ini.stat.exists
- name: Create app/logs symlink
file: state=link src={{symfony2_project_root}}/shared/app/logs path={{symfony2_project_root}}/releases/{{symfony2_project_release}}/app/logs
- name: Create web/uploads symlink
file: state=link src={{symfony2_project_root}}/shared/web/uploads path={{symfony2_project_root}}/releases/{{symfony2_project_release}}/web/uploads
- name: Install composer
get_url: url=https://getcomposer.org/composer.phar dest={{symfony2_project_root}}/composer.phar mode=0755 validate_certs=no
- name: Run composer install
shell: cd {{symfony2_project_root}}/releases/{{symfony2_project_release}} && export SYMFONY_ENV={{symfony2_project_env}}; {{symfony2_project_php_path}} {{symfony2_project_root}}/composer.phar install {{symfony2_project_composer_opts}}
- name: Dump assets

- name: Check if composer exists.
stat: path={{symfony2_project_composer_path}}
register: composer_file

- name: Install composer.
get_url: url=https://getcomposer.org/composer.phar dest={{symfony2_project_composer_path}} mode=0755 validate_certs=no
when: composer_file.stat.exists == false

- name: Update composer if already exists.
shell: "{{symfony2_project_composer_path}} selfupdate"
when: composer_file.stat.exists == true

- name: Run composer install.
shell: cd {{symfony2_project_root}}/releases/{{symfony2_project_release}} && {{symfony2_project_php_path}} {{symfony2_project_root}}/composer.phar install {{symfony2_project_composer_opts}}

- name: Dump assets.
shell: cd {{symfony2_project_root}}/releases/{{symfony2_project_release}} && {{symfony2_project_php_path}} app/console assetic:dump --env={{symfony2_project_env}} {{symfony2_project_console_opts}}
- name: Run migrations

- name: Run migrations.
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

- 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

0 comments on commit 23c1df8

Please sign in to comment.