Choose a directory to clone the project. The directory doesn't need to be inside Symfony structure.
cd /path/to/somewhere/deploys
git clone [email protected]:dcastello/symfony2-ansible-deploy
- 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)
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
# staging
[devservers]
dev.example.com
# production
[prodservers]
example.com
- 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
- 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
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
- Rollback functionality
- Limit number of releases available