This repository contains Saltstack state files for provisioning Yii Framework servers.
Dependencies:
- https://github.com/cebe-cc/salt-basic
- https://github.com/cebe-cc/salt-nginx
- https://github.com/cebe-cc/salt-php
Clone the repo and install submodules:
git clone git@github.com:yiisoft-contrib/server-salt.git yii-servers
cd yii-servers
git -c core.autocrlf=false -c core.eol=lf submodule update --init
cp roster.dist rosterCopy your private ssh key to ssh/id_rsa. If you have a password, remove it with ssh-keygen -p -f ssh/id_rsa -N '' since salt-ssh doesn't support entering a password.
Then run the following:
# build the container
docker compose build
# start a bash shell in the container
docker compose run --rm ct bash
# run salt-ssh commands, e.g.:
salt-ssh -i '*' test.ping- Configure servers in salt roster (copy
roster.disttorosterand adjust it as needed) - For some servers you need salt pillar data with secrets that are not part of the public repo. Copy
pillar/<SERVERNAME>-secrets.dist.slstopillar/<SERVERNAME>-secrets.slsfor these and fill out the missing config. For the prod servers clone the secrets repo and link them. - Run
salt-ssh -i '*' test.pingto see if servers are set up correctly (-ion the first run to automatically accept the host keys).
For setting up a new server you need to have your SSH public key added to /root/.ssh/authorized_keys.
Run salt-ssh -i '<SERVERNAME>' test.ping to test the setup. It should respond with
<SERVERNAME>:
TrueIf the server is set up correctly we apply the basic state to install some common software and configure basic stuff:
salt-ssh '<SERVERNAME>' state.apply basicFor deployment, apply the state for the servers (which are defined in states/top.sls):
salt-ssh '<SERVERNAME>' state.applyYou may specify test=True, to see if the apply command would change anything:
salt-ssh '<SERVERNAME>' state.apply test=TrueThis will apply the states as defined in states/top.sls.
To apply a specific states, you can specify it:
salt-ssh '<SERVERNAME>' state.apply <task><task> is one of the following states (as described below under "Salt States"):
- Discourse Forum:
discourse - Yii Website:
yiiframework - Yii GitHub bot:
yiibot
Use the Debian 13 upgrade runbook to upgrade the existing website host from Bullseye through Bookworm to Trixie. The separately invoked debian-upgrade Salt state stages the console helper.
The website state tracks the latest Nginx mainline package and its matching image-filter module from the official Nginx APT repository. Provisioning requires version 1.31.9 or newer. If the host's Debian suite lacks patched packages, Salt stops the Nginx upgrade before replacing the installed packages. Use a Debian suite that publishes patched mainline packages, such as Bookworm or Trixie.
To record production deploys for yiiframework.com, create a Sentry Organization Auth Token with the org:ci scope. Add the token and your Sentry organization and project slugs to the private pillar/site-secrets.sls file (see the example pillar). Keep the token out of the repository.
yiisite:
sentry:
auth_token: <organization auth token>
organization: <organization slug>
project: <project slug>When all three settings are present, Salt uses the deployed Git commit SHA as the Sentry release version and records a production deploy. If any setting is missing or blank, Salt skips Sentry reporting and continues the deployment. The app uses SENTRY_DSN separately for error reporting.
Note that salt will only return and display any output when all states are applied. On the first run this may take a long time, for discourse for example, their setup script says:
This process may take anywhere between a few minutes to an hour, depending on your network speed
Please be patient
For the forum states there is more documentation available here:
discoursesee docs/discourse.mdnodebbsee docs/nodebb.md