Skip to content

Commit

Permalink
Fixes for v0.2, added tests and .travis.yml
Browse files Browse the repository at this point in the history
fixed merge errors
fixed deployment issues with config if already exists in project
fixed issue with missing SYMFONY_ENV while composer install
fixed composer path variable missing
added tests directory and travis.yml for testing
  • Loading branch information
maschmann committed May 22, 2015
1 parent 23c1df8 commit b76dec3
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 22 deletions.
19 changes: 19 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
language: python
python: "2.7"

before_install:
# Make sure everything's up to date.
- sudo apt-get update -qq

install:
# Install Ansible.
- pip install ansible

# Add ansible.cfg to pick up roles path.
- "printf '[defaults]\nroles_path = ../' > ansible.cfg"

script:
# Check the role/playbook's syntax.
- "ansible-playbook -i tests/inventory tests/test.yml --syntax-check"
- "ansible-playbook -i tests/inventory tests/test.yml --connection=local --sudo"
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## v0.2
* fixed merge errors
* fixed deployment issues with config if already exists in project
* fixed issue with missing SYMFONY_ENV while composer install
* fixed composer path variable missing
* added tests directory and travis.yml for testing

## v0.1

* structural refactoring (creating files, directories, ...)
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,16 @@ Role Variables
- vars:
symfony2_project_root: Path where application will be deployed on server.
symfony2_project_name: Name of project.
symfony2_project_composer_path: path where composer.phar will be stored (e.g. project_root/shared)
symfony2_project_repo: URL of git repository.
symfony2_project_release: Release number, can be numeric, we recommend to set it to release date/time, 20140327100911
symfony2_project_branch: git branch to deploy.
symfony2_project_php_path: /usr/local/php54/bin/php
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
5 changes: 1 addition & 4 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@
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
symfony2_project_clean_versioning: true
10 changes: 1 addition & 9 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ galaxy_info:
author: servergrove
description:
company: ServerGrove
# Some suggested licenses:
# - BSD (default)
# - MIT
# - GPLv2
# - GPLv3
# - Apache
# - CC-BY
license: MIT
min_ansible_version: 1.2
#
Expand Down Expand Up @@ -118,5 +111,4 @@ dependencies: []
# List your role dependencies here, one per line. Only
# dependencies available via galaxy should be listed here.
# Be sure to remove the '[]' above if you add dependencies
# to this list.

# to this list.
24 changes: 18 additions & 6 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
- { 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" }
- { path: "{{symfony2_project_root}}/shared/web/uploads" }

- name: Pull sources from the repository.
git: repo={{symfony2_project_repo}} dest={{symfony2_project_root}}/releases/{{symfony2_project_release}} version={{symfony2_project_branch}} accept_hostkey=yes
Expand All @@ -16,11 +16,23 @@
file: state=absent path={{symfony2_project_root}}/releases/{{symfony2_project_release}}/.git
when: symfony2_project_clean_versioning == true

# will be replaced with symlink
- name: Ensure logs directory is not present.
file: state=absent path={{symfony2_project_root}}/releases/{{symfony2_project_release}}/app/logs

- 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" }
- { src: "{{symfony2_project_root}}/shared/app/logs", path: "{{symfony2_project_root}}/releases/{{symfony2_project_release}}/app/logs" }
- { src: "{{symfony2_project_root}}/shared/web/uploads", path: "{{symfony2_project_root}}/releases/{{symfony2_project_release}}/web/uploads" }

- name: Check if config dir exists.
stat: path={{symfony2_project_root}}/releases/{{symfony2_project_release}}/app/config
register: config_dir

- name: Link configs dir if not yet exists.
file: state=link src={{symfony2_project_root}}/shared/app/config path={{symfony2_project_root}}/releases/{{symfony2_project_release}}/app/config
when: config_dir.stat.exists == false

- name: Check if shared/app/config/parameters.ini exists.
stat: path={{symfony2_project_root}}/shared/app/config/parameters.ini
Expand All @@ -31,19 +43,19 @@
when: parameters_ini.stat.exists

- name: Check if composer exists.
stat: path={{symfony2_project_composer_path}}
stat: path={{symfony2_project_composer_path}}/composer.phar
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"
shell: "{{symfony2_project_composer_path}}/composer.phar 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}}
shell: cd {{symfony2_project_root}}/releases/{{symfony2_project_release}} && export SYMFONY_ENV={{symfony2_project_env}} && {{symfony2_project_php_path}} {{symfony2_project_composer_path}}/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}}
Expand Down
1 change: 1 addition & 0 deletions tests/inventory
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
localhost
19 changes: 19 additions & 0 deletions tests/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
- hosts: localhost
remote_user: root
roles:
- ansible-symfony2

vars:
symfony2_project_root: ~/test_app
symfony2_project_name: travis-test
symfony2_project_composer_path: ~/test_app/shared
symfony2_project_repo: git@github.com:symfony/symfony-standard.git
symfony2_project_release: 1
symfony2_project_branch: "2.6"
symfony2_project_php_path: /usr/bin/php
symfony2_project_env: prod
symfony2_project_console_opts: '--no-debug'
symfony2_project_composer_opts: '--no-dev --optimize-autoloader'
symfony2_project_keep_releases: 5
symfony2_project_clean_versioning: true

0 comments on commit b76dec3

Please sign in to comment.