This cookbook provides an easy way to deploy a Symfony2 application, as well as run console commands on it.
activelamp_composer
cookbook
You might also need to install this on your node(s):
acl
package to support the use ofChef::Provider::SymfonyPermission::Setfacl
. You might have to use this if your nodes does not support thechmod +a ...
command. You can install this using your platform's package manager (.i.e.,apt
)
- Tested on Ubuntu/Debian only, but the deploy actions should work with any platform. However, there is no provider to handle
:set_permissions
on Windows at the moment.
NA
This resource simply extends the built-in deploy
resource, but provides sensible defaults that are relevant to most Symfony projects. For example, a symlink is automatically created for app/logs
into the shared folder so that they persist between deploys. web/uploads
is also automatically symlinked. You can override these links by specifying the shared_dirs
option in the resource.
- All actions supported by the
deploy
resource. :set_permissions
- Sets the permissions ofapp/logs
,app/cache
,web/uploads
and any other directories you specified underworld_writable_dirs
#Deploy a Symfony project
symfony_project "/path/to/project" do
repo 'git@github.com:foo_organization/bar_application.git'
revision 'v1.2'
git_ssh_wrapper '/tmp/ssh-wrapper.sh'
action [:deploy, :set_permissions]
composer_options({
:dev => true,
:quiet => false,
:verbosity => 2
})
parameters({
:database_user => 'root',
:database_password => node[:mysql][:server_root_password]
})
end
All options for the deploy
resource is applicable here. However here are additional options that are symfony_project
-specific:
Name | Default | Description |
---|---|---|
shared_dirs | {'logs' => 'app/logs','cache' => 'app/cache','uploads' => 'web/media/uploads','vendor' => 'vendor'} |
The directories to create under the shared directory and symlinked into every deployment. |
world_writable_dirs | ['app/logs', 'app/cache', 'web/uploads'] |
Directories that should be world writeable. |
permission_provider | Chef::Provider::SymfonyPermission::Chmod |
The provider that handles the setting of the appropriate permissions on the directories listed under world_writable_dirs . Only relevant on :set_permissions . You can also substitute this for Chef::Provider::SymfonyPermission::Setfacl if your prefer to use setfacl to set the permissions. |
web_user | "www-data" |
The user to whom permission will be granted/umasked. Only relevant on :set_permissions |
parameters | {} |
Parameters overrides. |
parameters_file | app/config/parameters.yml |
Path to the parameters file |
parameters_dist_file | app/config/parameters.yml.dist |
Path to the parameters file distributable. |
parameters_file_template | parameters.yml.erb |
The ERB template for the parameters file. Parameter overriding is disabled if this is set to nil . |
parameters_file_template_cookbook | nil |
The cookbook where the prefered template is located. This will default to the current cookbook. Specify :activelamp_symfony if you wish to use the built-in one. Use @parameters to access the container parameters which are merged from the contents of the distributable and the values in parameters . |
composer_options | { :action => [:download_phar, :install], :lock_file_only => true, :dev => false, :prefer_dist => true, :prefer_source => false, :optimize_autoloader => true} |
The options used when the composer resource is called internally during migrate . Refer to the activelamp_composer cookbook for available options. |
You can use this resource to interact with your Symfony application via the Symfony Console.
:run
(default) - Runs the command:nothing
#Run a Symfony Console command
app_console "/path/to/project/current" do
command 'assetic:dump --force'
environment 'prod'
quiet false
verbosity 3
user node[:user]
group node[:group]
end
Attribute | Default | Description |
---|---|---|
app | The name attribute | The project root of the Symfony application. |
command | nil |
The command to execute |
environment | :prod |
The environment to run the command in. Used in the --env flag |
quiet | true |
If true , adds the --quiet flag |
verbosity | 1 |
Value for the --verbose flag. |
user | nil | The user to execute the command as. |
group | nil | The group to execute the command as. |
console | php app/console |
The Symfony Console command to use. |
symfony_project "/path/to/project" do
repo 'git@github.com:foo_organization/bar_application.git'
revision 'v1.2'
git_ssh_wrapper '/tmp/ssh-wrapper.sh'
parameters({
:database_user => 'root',
:database_password => node[:mysql][:server_root_password],
:database_host => 'localhost'
})
user node[:deploy_user]
group node[:deploy_group]
permission_provider Chef::Provider::SymfonyPermission::Setfacl
world_writable_dirs.push('web/media/thumbnails')
action [:deploy, :set_permissions]
notifies :run, 'app_console[assetic-dump]'
end
app_console "assetic-dump" doo
app '/path/to/project/current'
command 'assetic:dump --force'
console 'php bin/console' # If you are using Symfony 3.0 directory structure.
user node[:deploy_user]
group node[:deploy_group]
action :nothing
end
Author: Bez Hermoso bez@activelamp.com
Author: ActiveLAMP
Copyright: 2012-2014, ActiveLAMP