Skip to content

dcastello/symfony2-ansible-deploy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deploying Symfony2 with Ansible

Installation

Choose a directory to clone the project. The directory doesn't need to be inside Symfony structure.

    cd /path/to/somewhere/deploys
    git clone git@github.com:dcastello/symfony2-ansible-deploy

Configuration

Main files

  • production: Production servers inventory
  • staging: Development servers inventory
  • group_vars/devservers: List of variable to fill for development environment (Symfony2 and database vars)
  • group_vars/prodservers: List of variable to fill for production environment (Symfony2 and database vars)

group_vars variable list

    symfony2_project_root: '/var/www/dev.example.com'
    symfony2_project_name: 'My Project'
    symfony2_project_repo: 'url to your GIT repo'
    symfony2_project_branch: master
    symfony2_project_php_path: /usr/local/bin/php
    symfony2_project_env: dev
    symfony2_project_console_opts: ''
    symfony2_project_composer_opts: ''
    database_driver: 'pdo_mysql'
    database_port: null
    database_host: 'localhost'
    database_name: 'name'
    database_user: 'user'
    database_password: 'passwd'
    ansible_ssh_user: user

Production/Staging inventory example

    # staging
    [devservers]
    dev.example.com
    # production
    [prodservers]
    example.com

Task list by role

Setup tasks

  • Generate release directory name
  • Create release dir
  • Create shared dir
  • Create shared/web/uploads dir
  • Create shared/app/logs dir
  • Create shared/app/config dir
  • Generate parameters.yml from template to shared/app/config
  • Install composer

Deploy tasks

  • Generate release directory name
  • Pull sources from the repository
  • Set permissions to cache directory
  • Create app/logs symlink
  • Create web/uploads symlink
  • Create app/config/parameters.yml symlink
  • Run composer install
  • Dump assets
  • Migrating database
  • Create symlink to new release

Examples

The project has two main roles: setup and deploy. Setup is used to create the main structure and deploy to next deployments.

    $ ansible-playbook -i <host inventory> <playbook>

To create main structure for development environment:

    $ ansible-playbook -i /path/to/devserver /path/to/deploy_setup.yml

Second deploy and next deploys:

    $ ansible-playbook -i /path/to/devserver /path/to/deploy.yml

TODO

  • Rollback functionality
  • Limit number of releases available

About

Deploying Symfony2 applications with Ansible

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published