Configuration
Magallanes allows you to deploy your application in any way you can dream up, and it’s thanks to the powerful and flexible configuration options that this is possible.
Initiating New Project
In order to use Magallanes we have to initialize a project. This is done with the init
command. Similar to git this will create a .mage
directory where all
the configuration, environments, custom tasks, and logs are stored.
To understand about directory structure in this tool, please read here.
Right now the most important file is .mage/config/general.yml
. In there is
stored the project name and notification email, and also if notification delivery and
logging are enabled. The log files store everything Magallanes does, all commands and
results, so if you need to debug something that’s the place to start with. The maxlogs
indicates how many logfiles are saved, when reached the older logs are deleted. These
are quantity of files not days.
Add An Environment
Now the fun begins. We have our project initiated so now is it’s time to add an environment.
An environment is to where we want to deploy our code and what to do with it. So an environment
will store the configuration of to where to copy the application and what to do with it once
deployed. Also we can configure our environment to work with releases, imagine it as a rudimentary
versioning of our deployments.
We will talk about releases
later.
With that last command we have just created a new environment named
production
. This will create the configuration
file .mage/config/environments/production.yml
.
We must edit that file in order to configure the environment.
Also if you want to know which environments you have already configured, you can run the following command and it will display the existing environments.
Configuring An Environment
Following the previous example we will edit the .mage/config/environments/production.yml
file to configure the environment. Let’s see the sections of the configuration file
and what we can setup there.
Deployment
Setting | Options and Examples |
---|---|
Deployment Strategy Deployment strategy Magallanes going to use to deploy. List available strategies: disabled, git-rebase, git-remote-cache, rsync, rsync-remote-cache, tar-gz. |
|
Username This is the username used for SSH connections. |
|
Application Source The location of the application, usually is the same directory where Magallanes is, but it could be any other path. Eg: ./something or ../hello-world or /Users/YourUser/hello |
|
Application Destination The remote directory where the application is gonna be copied. If you are working with releases this should not be the document root. |
|
Excludes Exclude directories and/or files when using `rsync` or `rsync-remote-cache`. These exclusions are relative to the site's source directory and cannot be outside the source directory. Magallanes always exclude `.mage` and `.git` directories. |
|
Excludes File If you have a long list of files and directories need to be exclude. Please use this instead of `excludes` |
|
Do not use tabs in configuration files
This will either lead to parsing errors, or Magallanes will revert to the default settings. Use spaces instead.
Hosts
In the hosts section we configure a list of hosts (IPs or hostnames) to where the rsync will run against. You can also specify a port number like in the example above. Also, note that you should be able to do an SSH connection to the host using ssh keys without passphrase, so you won’t be requested any password.
Tasks
In the tasks section we configure which tasks to run and when. You can look a complete list of built-in tasks here. Each task is executed in the configured order and in a specific part of the deployment, these moments are these:
Setting | Options and Examples |
---|---|
Pre Deploy Before deployments begins. Useful for vendor installation and scm update tasks. |
|
On Deploy Executed on each host after the code has been copied. Useful for cache warmup, symlinks creations, etc. |
|
Post Release Executed on each host after the release has been executed. |
|
Post Deploy After the deployment is completed. Useful for general tasks like cleanup a cache system. |
|
You can setup here your own tasks, bultin tasks always starts with a namespace of the task type it belongs (eg: scm, deployment, etc). On the other hand custom tasks don’t have a namespace.
(to be continue…)