Skip to content

Commit dc924f6

Browse files
committed
refactored directory handling, added travis tests
1 parent 8ededc8 commit dc924f6

File tree

6 files changed

+56
-29
lines changed

6 files changed

+56
-29
lines changed

.travis.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ script:
2929
- "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
3636
- "ansible-playbook -i tests/inventory tests/test_2_1.yml --connection=local"
3737
- "ansible-playbook -i tests/inventory tests/test_2_2.yml --connection=local"
3838
- "ansible-playbook -i tests/inventory tests/test_2_3.yml --connection=local"
3939
- "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"
44-
#- "ansible-playbook -i tests/inventory tests/test_3_0.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"
44+
- "ansible-playbook -i tests/inventory tests/test_3_0.yml --connection=local"

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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,11 @@
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)