Git Product home page Git Product logo

ansistrano-symfony-deploy's Introduction

ansistrano-symfony-deploy

Build Status

A set of Ansible tasks for deploying PHP applications developed using the Symfony framework (incl. flex) onto *nix servers in a "Capistrano" fashion (releases, shared, current->releases/X).

This role is more or less just a collection of the most common post-installation setup tasks (i.e. getting a Composer executable, installing dependencies and autoloader, perform cache warming, deploy migrations etc). It does not itself deal with setting up the directory structures or getting files onto your servers - that part is handled by the more generic ansistrano-deploy role.

The way this is implemented is by defining a couple of the ansistrano_(before|after)_X vars (see the ansistrano docs for details).

Requirements

Due to shortcomings in the current version of Ansible, it is a requirement that the ansistrano-symfony-deploy and ansistrano-deploy share the same parent directory. This will be the normal case so shouldn't be an issue as long as you install via ansible-galaxy.

The tasks will probably not work for Windows target hosts (untested).

Role Variables

The defaults vars declared in this module:

symfony_env: prod
symfony_php_path: php # The PHP executable to use for all command line tasks

symfony_console_path: 'app/console' # If using Symfony 3+ this should be 'bin/console'

symfony_run_composer: true
symfony_composer_path: "{{ ansistrano_deploy_to }}/composer.phar"
symfony_composer_options: '--no-dev --optimize-autoloader --no-interaction'
symfony_composer_self_update: true # Always attempt a composer self-update
symfony_composer_version: 1.10.1 # Install specific composer version. If this variable is not set the latest stable version is installed

symfony_run_assets_install: true
symfony_assets_options: '--no-interaction'

symfony_run_assetic_dump: true
symfony_assetic_options: '--no-interaction'

symfony_run_cache_clear_and_warmup: true
symfony_cache_options: ''

###############################################################################
symfony_run_doctrine_migrations: false
symfony_doctrine_options: '--no-interaction'

symfony_run_mongodb_schema_update: false
symfony_mongodb_options: ''

Hooks

This role supports ansistrano like hooks before and after every task

ansistrano_symfony_before_composer_tasks_file
ansistrano_symfony_after_composer_tasks_file

ansistrano_symfony_before_assets_tasks_file
ansistrano_symfony_after_assets_tasks_file

ansistrano_symfony_before_assetic_tasks_file
ansistrano_symfony_after_assetic_tasks_file

ansistrano_symfony_before_cache_tasks_file
ansistrano_symfony_after_cache_tasks_file

ansistrano_symfony_before_doctrine_tasks_file
ansistrano_symfony_after_doctrine_tasks_file

ansistrano_symfony_before_mongodb_tasks_file
ansistrano_symfony_after_mongodb_tasks_file

In addition to this, please also refer to the list of variables used by ansistrano.

Note about ORM/ODM schema migrations

Database schema migrations can generally NOT be run in parallel across multiple hosts! For this reason, the symfony_run_doctrine_migrations and symfony_run_mongodb_schema_update options both come turned off by default.

In order to get around the parallel exection, you can do the following:

  1. Specify your own ansistrano_before_symlink_tasks_file, perhaps with the one in this project as a template (look in cbrunnkvist.ansistrano-symfony-deploy/config/steps/).
  2. Pick one of the following approaches:
  • (a) Organize hosts into groups such that the task will run on only the first host in some group: when: groups['www-production'][0] == inventory_hostname
  • (b) Use the run_once: true perhaps with delegate_to: some_primary_host (Docs: Playbook delegation)

Dependencies

Installing from the command line via ansible-galaxy install cbrunnkvist.ansistrano-symfony-deploy should pull down the external role as a dependency, so no extra step neccessary.

Example playbook

As a bare minimum, you probably need to declare the ansistrano_deploy_from and ansistrano_deploy_to variables in your play. Ansistrano defaults to using rsync from a local directory (again, see the ansistrano docs).

Let's assume there is a my-app-infrastructure/deploy.yml:

---
- hosts: all
  gather_facts: false
  vars:
    ansistrano_deploy_from: ../my-project-checkout
    ansistrano_deploy_to: /home/app-user/my-project-deploy/
    ansistrano_before_symlink_tasks_file: "{{playbook_dir}}/config/app_specific_setup.yml"
  roles:
    - cbrunnkvist.ansistrano-symfony-deploy

This playbook should be executed like any other, i.e. ansible-playbook -i some_hosts_file deploy.yml.

It probably makes sense to keep your one-off system prep tasks in a separate playbook, e.g. my-app-infrastructure/setup.yml.

License

MIT

Author Information

  • ansistrano-symfony-deploy, written by Conny Brunnkvist [email protected]
  • The underlying role is maintained by the ansistrano-deploy team
  • Some code was taken from/inspiried by the symfony2-deploy role by the Servergrove team

ansistrano-symfony-deploy's People

Contributors

bcodp avatar cbrunnkvist avatar scuben avatar simperfit avatar tiawaz avatar zokormazo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansistrano-symfony-deploy's Issues

new ansistrano-deploy role repository address

Hi, the ansistrano-deploy role is now here

https://github.com/ansistrano/deploy
https://galaxy.ansible.com/ansistrano/ansistrano-deploy

ansible-galaxy install --force ansistrano.ansistrano_deploy

in order to be able to use ansistrano-symfony-deploy again it would be necessary to update these files :

meta/main.yml
.travis.yml
README.md

I tried to create a branch in order to make a pull request but i got an access denied when i pushed it :(

include steps/* fails with ansible2

after updating ansible to v2 i see the following failure:

TASK [carlosbuenosvinos.ansistrano-deploy : ANSISTRANO | Create softlinks for shared paths] ***
TASK [carlosbuenosvinos.ansistrano-deploy : include] ***************************
included: /etc/ansible/roles/carlosbuenosvinos.ansistrano-deploy/tasks/../../cbrunnkvist.ansistrano-symfony-deploy/config/after_symlink_shared.yml for xxxx

TASK [carlosbuenosvinos.ansistrano-deploy : include] ***************************
fatal: [xxxx]: FAILED! => {"failed": true, "reason": "ERROR! the file_name 'xxxx/ansible/login-deploy/steps/composer.yml' does not exist, or is not readable"}

ansible seems to be looking for the steps/* files in the local playbook dir instead of the role dir.

Unclear whether "- include: {{some_var}}" makes sense or not

In its original inception, Ansible's include does not support a templated argument because the purpose of the statement is to split tasks into modules, not to support dynamic loading based on facts

For example, what if the variable is a fact (=in Ansible speak, a variable that gets declared once-per-host, after connection time, perhaps after setup (gather_facts) finishes. What file will be included? At which time? Include files have global side effects so the order in which they are invoked (=on behalf of perhaps hundreds of hosts) matter.

How come the include method that ansistrano-deploy uses today works? Is it purely a fluke? Should a role such as ansistrano-deploy be using events & handlers, rather than rely in dynamic includes?

Project slightly unmaintained

I will probably not continue working on this until next time I get to do a Symfony project. For now, I have added @gtrias as collaborator just in case so that we can possibly reuse the Travis/Galaxy setup (-and also avoid having to use the symfony_deploy_playbook_dir hack).

๐Ÿšง Apologies for the resulting mess, we will see whether we end up maintaining this or https://github.com/gtrias/ansistrano-symfony-deploy

Set webuser (apache,nginx) rights to app/cache folder

Hi,

When you deploy a new release, app/cache folder have yourappuser rights, often webuser (apache) needs to create/modify cache files.

I think is necessary set apache user rights over cache folder like:

cd {{ ansistrano_release_path.stdout }} && setfacl -R -m u:apache:rwX -m u:eplanning:rwX app/cache
cd {{ ansistrano_release_path.stdout }} && setfacl -dR -m u:apache:rwX -m u:eplanning:rwX app/cache

What do you think?

Fix Permissions

Where should I chown or chmod the files deployed as the permissions are not ok.

Problem with cleanup

Hello,

I'm using 3 releases for deployment. Sometimes, when it comes to cleanup,there's a file seems to bug the cleanup process :

TASK: [deployment | Clean up releases] ******************************** 
failed: [10.1.0.176] => {"changed": true, "cmd": "ls -1dt /home/www/client/project/releases/* | tail -n +$((3 + 1)) | xargs rm -rf", "delta": "0:00:03.683295", "end": "2015-10-02 17:29:43.029682", "rc": 123, "start": "2015-10-02 17:29:39.346387", "warnings": []}
stderr: rm: cannot remove `/home/www/client/project/releases/20151002095730Z': Directory not empty

The file in this directory is the app/logs/prod.log file.

Did you already get this problem ? Any idea about how to proceed ?

Thanks for your role !

FIX Permissions

In the capistrano I was having some writable folders and permission settings
..
run "sudo chown -R #{user}:#{webserver_user} #{deploy_to}"
run "sudo chown -RH root:www-data #{latest_release}/#{cache_path}"
..
Is there anything included here?

ansistrano_git_repo

Hi and thank you for this repo you provided.
I am wondering if is possible to use a certain branch for
ansistrano_git_repo and how please ?

composer self-update non stable version

Hello.
I'm deploy my project and get error
Problem 1 - ocramius/package-versions is locked to version 1.4.2 and an update of this package was not requested. - ocramius/package-versions 1.4.2 requires composer-plugin-api ^1.0.0 -> found composer-plugin-api[2.0.0] but it does not match your constraint. Problem 2 - symfony/flex is locked to version v1.4.8 and an update of this package was not requested. - symfony/flex v1.4.8 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.0.0] but it does not match your constraint. Problem 3 - ocramius/package-versions 1.4.2 requires composer-plugin-api ^1.0.0 -> found composer-plugin-api[2.0.0] but it does not match your constraint. - jean85/pretty-package-versions 1.2 requires ocramius/package-versions ^1.2.0 -> satisfiable by ocramius/package-versions[1.4.2]. - jean85/pretty-package-versions is locked to version 1.2 and an update of this package was not requested.

It's because composer have version
Composer version 2.0-dev (2.0-dev+d34ea60c488ad62e7944eac3d3e768b449ae767a) 2020-04-07 11:09:22

jean85/pretty-package-versions 1.4.2 can't work with composer-plugin-api 2.0.0

I'm try remove composer.phar, but deploy instruction still download dev version composer

How configure download version composer?

Stale project / looking for new maintainer

Since I'm not using this at all, and quite a few forks have appeared over the years, I would be glad to hand over maintenance to one or more persons who have some active stake in the Symfony ecosystem. Because I do not, anymore ๐Ÿ˜… and to be honest I have no idea of what the state of this playbook is at this point in time.

Should I:
A: archive the repo / make it read-only, and update the README with pointers to the most popular active fork
B: look for improvements from the best forks, play "benevolent dick-tator" and encourage someone to take over this repo, bring together the best features from different forks?
C: look for one or three people to add as repo admins, stop worrying about it

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.