cbrunnkvist / ansistrano-symfony-deploy

Common post-deploy tasks for Symfony projects, using ansistrano (a Capistrano-style Ansible role)
MIT License
68 stars 26 forks source link

Add option Env variables for composer install #15

Closed jycamier closed 7 years ago

jycamier commented 7 years ago

Symfony default composer.json comes with the command Incenteev\ParameterHandler\ScriptHandler::buildParameters which can use environment variables to build the parameters.yml file (see https://github.com/Incenteev/ParameterHandler#using-environment-variables-to-set-the-parameters).

Here's a part of the compoer.json

    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web",
        "symfony-assets-install": "relative",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml",
            "keep-outdated": true,
            "env-map": {
                "database_host": "DATABASE_HOST",
                "database_port": "DATABASE_PORT",
                "database_name": "DATABASE_NAME",
                "database_user": "DATABASE_USER",
                "database_password": "DATABASE_PASSWORD"
            }
        }
    }

And the ansible playbook exemple

---
- 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"
    symfony_composer_environment:
      DATABASE_HOST: localhost
      DATABASE_PORT: 3306
      DATABASE_NAME: my_database
      DATABASE_USER: foo
      DATABASE_PASSWORD: bar
  roles:
    - cbrunnkvist.ansistrano-symfony-deploy