Skip to content

Commit 1337592

Browse files
committed
Merge pull request #40 from maschmann/sf3-compatibility
Sf3 compatibility
2 parents 8ededc8 + 07e24ee commit 1337592

File tree

8 files changed

+92
-39
lines changed

8 files changed

+92
-39
lines changed

.travis.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@ install:
2323

2424
script:
2525
# Check the role/playbook's syntax.
26-
- "ansible-playbook -i tests/inventory tests/test_2_1.yml --syntax-check"
27-
- "ansible-playbook -i tests/inventory tests/test_2_2.yml --syntax-check"
28-
- "ansible-playbook -i tests/inventory tests/test_2_3.yml --syntax-check"
29-
- "ansible-playbook -i tests/inventory tests/test_2_4.yml --syntax-check"
26+
#- "ansible-playbook -i tests/inventory tests/test_2_1.yml --syntax-check"
27+
#- "ansible-playbook -i tests/inventory tests/test_2_2.yml --syntax-check"
28+
#- "ansible-playbook -i tests/inventory tests/test_2_3.yml --syntax-check"
29+
#- "ansible-playbook -i tests/inventory tests/test_2_4.yml --syntax-check"
3030
- "ansible-playbook -i tests/inventory tests/test_2_5.yml --syntax-check"
3131
- "ansible-playbook -i tests/inventory tests/test_2_6.yml --syntax-check"
32-
#- "ansible-playbook -i tests/inventory tests/test_2_7.yml --syntax-check"
33-
#- "ansible-playbook -i tests/inventory tests/test_2_8.yml --syntax-check"
34-
#- "ansible-playbook -i tests/inventory tests/test_3_0.yml --syntax-check"
32+
- "ansible-playbook -i tests/inventory tests/test_2_7.yml --syntax-check"
33+
- "ansible-playbook -i tests/inventory tests/test_2_8.yml --syntax-check"
34+
- "ansible-playbook -i tests/inventory tests/test_3_0.yml --syntax-check"
3535
# Run playbooks
36-
- "ansible-playbook -i tests/inventory tests/test_2_1.yml --connection=local"
37-
- "ansible-playbook -i tests/inventory tests/test_2_2.yml --connection=local"
38-
- "ansible-playbook -i tests/inventory tests/test_2_3.yml --connection=local"
39-
- "ansible-playbook -i tests/inventory tests/test_2_4.yml --connection=local"
36+
#- "ansible-playbook -i tests/inventory tests/test_2_1.yml --connection=local"
37+
#- "ansible-playbook -i tests/inventory tests/test_2_2.yml --connection=local"
38+
#- "ansible-playbook -i tests/inventory tests/test_2_3.yml --connection=local"
39+
#- "ansible-playbook -i tests/inventory tests/test_2_4.yml --connection=local"
4040
- "ansible-playbook -i tests/inventory tests/test_2_5.yml --connection=local"
4141
- "ansible-playbook -i tests/inventory tests/test_2_6.yml --connection=local"
42-
#- "ansible-playbook -i tests/inventory tests/test_2_7.yml --connection=local"
43-
#- "ansible-playbook -i tests/inventory tests/test_2_8.yml --connection=local"
42+
- "ansible-playbook -i tests/inventory tests/test_2_7.yml --connection=local"
43+
- "ansible-playbook -i tests/inventory tests/test_2_8.yml --connection=local"
4444
#- "ansible-playbook -i tests/inventory tests/test_3_0.yml --connection=local"

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog
22

3+
## v2.1
4+
5+
* refactoring to have more control over folders when deploying
6+
* more tests for current symfony versions
7+
* compatibility with new symfony folder and command structure
8+
9+
## v2.0
10+
11+
* bugfixes for folders
12+
* stability release
13+
314
## v2.0.1-alpha
415

516
* bugfixes for parameters file

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,10 @@ These are the possible role variables - you only need to have a small set define
9292
symfony_project_php_path: php
9393
symfony_project_keep_releases: 5
9494
symfony_project_git_clone_depth: 1 # uses git shallow copy
95-
symfony_project_github_oauth_token: Auth token for github rate limits
95+
symfony_project_github_token: Auth token for github rate limits
9696
symfony_project_console_opts: ''
9797
symfony_project_console_command: 'app/console' # sf >= 3.0 bin/console
98+
symfony_project_config_dir: 'app/config' # symfony configuration dir
9899
symfony_project_parameters_file: parameters.yml # optional fixed parameters file in shared
99100
symfony_project_cache_command: cache:warmup
100101
@@ -106,6 +107,12 @@ These are the possible role variables - you only need to have a small set define
106107
symfony_project_fire_schema_update: False # rund mongodb schema update if installed
107108
symfony_project_fire_migrations: run doctrine migrations, if installed
108109
symfony_project_symlink_assets: run assets:create with symlink options
110+
111+
symfony_project_shared_folders: # folders to be linked from shared directory to release dir
112+
- {name: logs, src: app/logs, path: app/logs}
113+
114+
symfony_project_managed_folders: # folderst to be created/checked in release dir
115+
- {name: cache, path: app/cache}
109116
```
110117

111118
### Role variable defaults
@@ -185,6 +192,14 @@ Create ```<your deployment>/hooks/post_folder_creation.yml```:
185192
- name: hook | Symlink to release.
186193
file: state=link src="{{symfony_shared_dir}}/web/uploads" path="{{symfony_current_release_dir}}/web/uploads"
187194
```
195+
As an alternative to managing folders via hooks, you can also configure either the shared folders or the creation of folders in your release directory in your confguration:
196+
197+
```yaml
198+
---
199+
symfony_project_shared_folders: # folders to be linked from shared directory to release dir
200+
- {name: logs, src: app/logs, path: app/logs}
201+
- {name: uploads, src: web/uploads, path: web/uploads}
202+
```
188203

189204
## Dependencies
190205

defaults/main.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ symfony_project_git_clone_depth: 1
2020
symfony_project_github_token: ~
2121
symfony_project_console_opts: ''
2222
symfony_project_console_command: 'app/console'
23+
symfony_project_config_dir: 'app/config'
2324
symfony_project_parameters_file: parameters.yml
2425
symfony_project_cache_command: cache:warmup
2526

@@ -31,3 +32,11 @@ symfony_project_enable_cache_warmup: True
3132
symfony_project_fire_schema_update: False
3233
symfony_project_fire_migrations: False
3334
symfony_project_symlink_assets: True
35+
36+
# ensured to be absent in release and linked from shared
37+
symfony_project_shared_folders:
38+
- {name: logs, src: app/logs, path: app/logs}
39+
40+
# ensured to be present
41+
symfony_project_managed_folders:
42+
- {name: cache, path: app/cache}

tasks/00-facts.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
# simplify folder and command vars
33

44
- name: Check/define release name.
5-
set_fact: symfony_project_release={{ lookup('pipe', 'date +%Y%m%d%H%M%S') }}
5+
set_fact: symfony_project_release="{{ lookup('pipe', 'date +%Y%m%d%H%M%S') }}"
66
when: symfony_project_release == None
77

88
- name: Set symfony_current_release.
9-
set_fact: symfony_current_release={{symfony_project_release}}_{{symfony_project_branch}}
9+
set_fact: symfony_current_release="{{symfony_project_release}}_{{symfony_project_branch}}"
1010

1111
- name: Set symfony_current_release_dir.
12-
set_fact: symfony_current_release_dir={{symfony_project_root}}/releases/{{symfony_current_release}}
12+
set_fact: symfony_current_release_dir="{{symfony_project_root}}/releases/{{symfony_current_release}}"
1313

1414
- name: Set symfony_shared_dir.
15-
set_fact: symfony_shared_dir={{symfony_project_root}}/shared
15+
set_fact: symfony_shared_dir="{{symfony_project_root}}/shared"
1616

1717
- name: Set symfony_console.
18-
set_fact: symfony_console="{{symfony_current_release_dir}}/{{symfony_project_console_command}} --env={{symfony_project_env}}"
18+
set_fact: symfony_console="{{symfony_current_release_dir}}/{{symfony_project_console_command}} --env={{symfony_project_env}}"

tasks/10-config.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
---
22
- name: Check if config dir exists.
3-
stat: path={{symfony_current_release_dir}}/app/config
3+
stat: path={{symfony_current_release_dir}}/{{symfony_project_config_dir}}
44
register: config_dir
55

6+
- name: Set shared config dir.
7+
set_fact: symfony_shared_config_dir={{symfony_shared_dir}}/{{symfony_project_config_dir}}
8+
9+
- name: Set config dir.
10+
set_fact: symfony_config_dir={{symfony_current_release_dir}}/{{symfony_project_config_dir}}
11+
612
- name: Link configs dir if not yet exists.
7-
file: state=link src={{symfony_shared_dir}}/app/config path={{symfony_current_release_dir}}/app/config
13+
file: state=link src={{symfony_shared_config_dir}} path={{symfony_config_dir}}
814
when: config_dir.stat.exists == false
915

1016
- name: Check if parameters file exists.
11-
stat: path={{symfony_shared_dir}}/app/config/{{symfony_project_parameters_file}}
17+
stat: path={{symfony_shared_config_dir}}/{{symfony_project_parameters_file}}
1218
register: symfony_parameters
1319

1420
- name: Create symlink for parameters file from shared directory.
15-
file: state=link src={{symfony_project_root}}/shared/app/config/{{symfony_project_parameters_file}} path={{symfony_current_release_dir}}/app/config/{{symfony_project_parameters_file}}
21+
file: state=link src={{symfony_shared_config_dir}}/{{symfony_project_parameters_file}} path={{symfony_config_dir}}/{{symfony_project_parameters_file}}
1622
when: symfony_parameters.stat.exists

tasks/main.yml

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,42 @@
22
# tasks file for symfony2
33
- include: 00-facts.yml
44

5-
- name: Create/prepare necessary directories for release and shared data.
5+
- name: Create base deployment directories.
66
file: state=directory path={{item.path}}
77
with_items:
88
- { path: "{{symfony_current_release_dir}}" }
99
- { path: "{{symfony_shared_dir}}" }
10-
- { path: "{{symfony_shared_dir}}/app/config" }
11-
- { path: "{{symfony_shared_dir}}/app/logs" }
10+
11+
- name: Create managed shared directories.
12+
file: state=directory path="{{symfony_shared_dir}}/{{item.path}}"
13+
with_items: "{{symfony_project_shared_folders}}"
1214

1315
- name: Pull sources from the repository.
1416
git: repo={{symfony_project_repo}} dest={{symfony_current_release_dir}} version={{symfony_project_branch}} accept_hostkey=yes depth={{symfony_project_git_clone_depth}}
1517

16-
# will be replaced with symlink
17-
- name: Ensure logs directory is not present.
18-
file: state=absent path="{{symfony_current_release_dir}}/app/logs"
18+
- name: Ensure shared folders are absent in release.
19+
file: state=absent path="{{symfony_current_release_dir}}/{{item.path}}"
20+
with_items: "{{symfony_project_shared_folders}}"
21+
22+
- name: Ensure managed folders are present.
23+
file: state=directory path="{{symfony_current_release_dir}}/{{item.path}}"
24+
with_items: "{{symfony_project_managed_folders}}"
1925

20-
# read project's composer.json and store output
2126
- name: Read composer.json
2227
shell: cat {{symfony_current_release_dir}}/composer.json
2328
register: composer_content
2429

25-
- include: "{{ symfony_project_post_folder_creation_tasks | default('empty.yml') }}"
30+
- include: "{{symfony_project_post_folder_creation_tasks | default('empty.yml')}}"
2631

2732
- name: Create symlinks to shared directories.
28-
file: state=link src="{{symfony_shared_dir}}{{item.src}}" path="{{symfony_current_release_dir}}{{item.path}}"
29-
with_items:
30-
- { src: "/app/logs", path: "/app/logs" }
33+
file: state=link src="{{symfony_shared_dir}}/{{item.src}}" path="{{symfony_current_release_dir}}/{{item.path}}"
34+
with_items: "{{symfony_project_shared_folders}}"
3135

3236
- include: 10-config.yml
3337

3438
- include: 20-composer.yml
3539

36-
- include: "{{ symfony_project_pre_cache_warmup_tasks | default('empty.yml') }}"
40+
- include: "{{symfony_project_pre_cache_warmup_tasks | default('empty.yml')}}"
3741

3842
- include: 30-cache.yml
3943

@@ -44,11 +48,11 @@
4448
- name: Create release file.
4549
copy: content="{{symfony_current_release}}" dest="{{symfony_current_release_dir}}/RELEASE" mode=644
4650

47-
- include: "{{ symfony_project_pre_live_switch_tasks | default('empty.yml') }}"
51+
- include: "{{symfony_project_pre_live_switch_tasks | default('empty.yml')}}"
4852

4953
- name: Create symlink for release.
5054
file: state=link src="{{symfony_current_release_dir}}" path="{{symfony_project_root}}/current"
5155

52-
- include: "{{ symfony_project_post_live_switch_tasks | default('empty.yml') }}"
56+
- include: "{{symfony_project_post_live_switch_tasks | default('empty.yml')}}"
5357

5458
- include: 60-clean_releases.yml

tests/test_3_0.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,24 @@
1717
symfony_project_console_opts: '--no-debug'
1818

1919
symfony_project_release: ~
20-
symfony_project_branch: "3.0"
20+
symfony_project_branch: "3.0.2"
2121
symfony_project_php_path: php
2222
symfony_project_keep_releases: 5
2323
symfony_project_git_clone_depth: 1
2424

2525
symfony_project_manage_composer: True
26-
symfony_project_composer_opts: '--no-dev --optimize-autoloader --no-interaction'
26+
symfony_project_composer_opts: '--no-dev -o --no-interaction'
2727

2828
symfony_project_parameters_file: parameters.yml
2929

3030
symfony_project_enable_post_cmd: True
3131
symfony_project_fire_schema_update: True
3232
symfony_project_fire_migrations: True
33+
34+
symfony_project_console_command: 'bin/console'
35+
36+
symfony_project_shared_folders:
37+
- {name: logs, src: var/logs, path: var/logs}
38+
39+
symfony_project_managed_folders:
40+
- {name: cache, path: var/cache}

0 commit comments

Comments
 (0)