|
1 | 1 | --- |
2 | 2 | # tasks file for symfony2 |
3 | | -- name: Create the release {{symfony2_project_release}} directory. |
4 | | - file: state=directory path={{symfony2_project_root}}/releases/{{symfony2_project_release}} |
5 | | -- name: Create the shared directory. |
6 | | - file: state=directory path={{symfony2_project_root}}/shared |
7 | | -- name: Create the shared/app/config directory. |
8 | | - file: state=directory path={{symfony2_project_root}}/shared/app/config |
9 | | -- name: Create the shared/web/uploads directory. |
10 | | - file: state=directory path={{symfony2_project_root}}/shared/web/uploads |
11 | | -- name: Create the shared/app/logs directory. |
12 | | - file: state=directory path={{symfony2_project_root}}/shared/app/logs |
| 3 | +- name: Create/prepare directories for release and shared data. |
| 4 | + file: state=directory path={{item.path}} |
| 5 | + with_items: |
| 6 | + - { path: "{{symfony2_project_root}}/releases/{{symfony2_project_release}}" } |
| 7 | + - { path: "{{symfony2_project_root}}/shared" } |
| 8 | + - { path: "{{symfony2_project_root}}/shared/app/config" } |
| 9 | + - { path: "{{symfony2_project_root}}/shared/app/uploads" } |
| 10 | + - { path: "{{symfony2_project_root}}/shared/app/logs" } |
| 11 | + |
13 | 12 | - name: Pull sources from the repository. |
14 | | - git: repo={{symfony2_project_repo}} dest={{symfony2_project_root}}/releases/{{symfony2_project_release}} version={{symfony2_project_branch}} |
15 | | -- name: Check if shared/app/config/parameters.ini exists |
| 13 | + git: repo={{symfony2_project_repo}} dest={{symfony2_project_root}}/releases/{{symfony2_project_release}} version={{symfony2_project_branch}} accept_hostkey=yes |
| 14 | + |
| 15 | +- name: Clean out versioning. |
| 16 | + file: state=absent path={{symfony2_project_root}}/releases/{{symfony2_project_release}}/.git |
| 17 | + when: symfony2_project_clean_versioning == true |
| 18 | + |
| 19 | +- name: Create symlinks to shared directories. |
| 20 | + file: state=link src={{item.src}} path={{item.path}} |
| 21 | + with_items: |
| 22 | + - { src: "{{symfony2_project_root}}/shared/web/uploads", path: "{{symfony2_project_root}}/releases/{{symfony2_project_release}}/uploads" } |
| 23 | + - { src: "{{symfony2_project_root}}/shared/app/logs", path: "{{symfony2_project_root}}/releases/{{symfony2_project_release}}/logs" } |
| 24 | + |
| 25 | +- name: Check if shared/app/config/parameters.ini exists. |
16 | 26 | stat: path={{symfony2_project_root}}/shared/app/config/parameters.ini |
17 | 27 | register: parameters_ini |
18 | | -- name: Create symlink for app/config/parameters.ini from shared directory |
| 28 | + |
| 29 | +- name: Create symlink for app/config/parameters.ini from shared directory. |
19 | 30 | 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 |
20 | 31 | when: parameters_ini.stat.exists |
21 | | -- name: Create app/logs symlink |
22 | | - file: state=link src={{symfony2_project_root}}/shared/app/logs path={{symfony2_project_root}}/releases/{{symfony2_project_release}}/app/logs |
23 | | -- name: Create web/uploads symlink |
24 | | - file: state=link src={{symfony2_project_root}}/shared/web/uploads path={{symfony2_project_root}}/releases/{{symfony2_project_release}}/web/uploads |
25 | | -- name: Install composer |
26 | | - get_url: url=https://getcomposer.org/composer.phar dest={{symfony2_project_root}}/composer.phar mode=0755 validate_certs=no |
27 | | -- name: Run composer install |
28 | | - 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}} |
29 | | -- name: Dump assets |
| 32 | + |
| 33 | +- name: Check if composer exists. |
| 34 | + stat: path={{symfony2_project_composer_path}} |
| 35 | + register: composer_file |
| 36 | + |
| 37 | +- name: Install composer. |
| 38 | + get_url: url=https://getcomposer.org/composer.phar dest={{symfony2_project_composer_path}} mode=0755 validate_certs=no |
| 39 | + when: composer_file.stat.exists == false |
| 40 | + |
| 41 | +- name: Update composer if already exists. |
| 42 | + shell: "{{symfony2_project_composer_path}} selfupdate" |
| 43 | + when: composer_file.stat.exists == true |
| 44 | + |
| 45 | +- name: Run composer install. |
| 46 | + shell: cd {{symfony2_project_root}}/releases/{{symfony2_project_release}} && {{symfony2_project_php_path}} {{symfony2_project_root}}/composer.phar install {{symfony2_project_composer_opts}} |
| 47 | + |
| 48 | +- name: Dump assets. |
30 | 49 | 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}} |
31 | | -- name: Run migrations |
| 50 | + |
| 51 | +- name: Run migrations. |
32 | 52 | 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 |
33 | | -- name: Create symlink |
| 53 | + |
| 54 | +- name: Create symlink. |
34 | 55 | file: state=link src={{symfony2_project_root}}/releases/{{symfony2_project_release}} path={{symfony2_project_root}}/current |
| 56 | + |
35 | 57 | - name: Cleanup releases. |
36 | 58 | shell: cd {{symfony2_project_root}}/releases && ls -t1 | tail -n +$(({{symfony2_project_keep_releases}}+1)) | xargs -n1 rm -rf |
0 commit comments