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 [email protected]:yiisoft-contrib/server-salt.git yii-servers
cd yii-servers
git submodule update --init
You need salt-ssh
installed and have it configured with your SSH key.
Copy the roster.dist file to roster
and adjust it if you are not working on the live servers.
You need to configure your SSH key in the roster
file.
Install salt-ssh
via Python PIP:
apt-get install python3-pip
pip3 install salt
We are currently working with version 3004 or higher (check with salt-ssh --version
).
You may also use docker-compose as described below:
At the time of this writing it seems salt-ssh is not supported on Windows, so you need a linux VM or docker container to run it.
First copy your private ssh key to ssh/id_rsa
. If you have a password, remove it with ssh-keygen -p
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
TBD
Note: You need to run
salt-ssh
in the repository root directory as that is what contains theSaltfile
thatsalt-ssh
will read its configuration from.
- Configure servers in salt roster (copy
roster.dist
toroster
and 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.sls
topillar/<SERVERNAME>-secrets.sls
for these and fill out the missing config. - Run
salt-ssh -i '*' test.ping
to see if servers are set up correctly (-i
on 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>:
True
If 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 basic
For deployment, apply the state for the servers (which are defined in states/top.sls
):
salt-ssh '<SERVERNAME>' state.apply
You may specify test=True
, to see if the apply command would change anything:
salt-ssh '<SERVERNAME>' state.apply test=True
This 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
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:
discourse
see docs/discourse.mdnodebb
see docs/nodebb.md