Meza/Autodeployer

Meza has a feature called "Autodeployer" which will check for changes to Meza or your public config repository and automatically deploy those changes.

Requirements

edit
  1. Your public config (/opt/conf-meza/public) must be stored in a Git repository
  2. File permissions to Meza and public config must be such that the user running autodeploy (root recommended for now) can modify the repositories
  3. If your config is in a private repository, you'll need to configure SSH keys
  4. You must be running Meza 31.1.0 or greater

Usage

edit

Secret config

edit

Add to your Meza/Secret config the info about your Meza/Public config:

local_config_repo:
  repo: "https://github.com/example-user/config-public.git"
  version: "master"

This could be put in your public config since it's not sensitive information, but since it drives what version of your public config to use it causes a chicken-or-egg situation if you put it there.

Additionally, if you use Slack, you can setup notifications with the following. Additional notification systems (like email) intend to be created at some point.

autodeployer:
  slack_channel: "deploy-notifications"
  slack_token: "some/slack/token"
  slack_username: "Production Server Autodeployer"
  slack_icon_url: "https://example.com/path/to/a/globally/accessible/image.jpg"

This is sensitive information (the token, anyway) and thus should be in your secret config.

Public config

edit

Within your public config you should define which version of Meza to track.

#
# This will track a version of Meza. If there are changes to the version of Meza
# listed below, they will be detected and deployed to this server.
#
enforce_meza_version: master

The config above tracks the master version of Meza. Any changes pushed to the master branch of Meza will automatically be deployed to your server. Alternatively, if you want to use a specific version of Meza you could do the following:

enforce_meza_version: tags/31.1.0

Setup crontab

edit

Crontab is used to declare how often to check for changes. Hourly is recommended, to reduce the likelihood that two deploys occur concurrently. At some point Meza will prevent this from happening and more frequent autodeploys will be able to be scheduled.

Run sudo crontab -e to edit the root user's crontab, then paste the following to run an hourly check for changes:

0 * * * * /opt/meza/src/scripts/autodeployer/check-for-changes.sh > /opt/data-meza/logs/check-for-changes-`date "+\%Y-\%m-\%d_\%H\%M\%S"`.log 2>&1

Running nightly overwrite-from-another-server

edit

If you configure to be able to pull data from another server (see Meza/Importing data), you can create a backup server that pulls data from your production server nightly (or any other frequency). After the import settings are configured (again, see Meza/Importing data), simply add the following to root's crontab:

# Backup from production every night at 22:00. Don't run SMW rebuild data or search indexing
0 22 * * * /opt/meza/src/scripts/autodeployer/do-deploy.sh "Backup" "--overwrite --skip-tags smw-data,search-index" "deploy-overwrite-"

Troubleshooting

edit
  • The first time you run this, if you upgraded from a version of Meza that didn't have Autodeployer, you may need to run sudo meza setbaseconfig <insert-your-environment>