aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md36
1 files changed, 33 insertions, 3 deletions
diff --git a/README.md b/README.md
index 7ef856b..2e5333b 100644
--- a/README.md
+++ b/README.md
@@ -44,8 +44,11 @@ You can get this dashboard [here](https://grafana.com/grafana/dashboards/15980).
2. Clone you fork with `git clone`
3. Change directory to this repo `cd vps`.
4. Setup repo by running all of the following:
-```
+```sh
+# install dependencies for this project in a venv
make install
+# remove my vault files
+rm -f hosts.vault group_vars/all/vault
# copy all the example files
cp -a vaultid.example vaultid
cp -a hosts.example hosts
@@ -60,13 +63,13 @@ cp -a group_vars/all/vault.example group_vars/all/vault
5. Modify the [vars](./group_vars/all/vars.yaml/) file per your needs.
Encrypt your hosts file, and secret vars before uploading to git:
-```
+```sh
ansible-vault encrypt --vault-id vaultid --output hosts.vault hosts
ansible-vault encrypt --vault-id vaultid --output group_vars/all/vault group_vars/all/vault
```
## Deploy
-```
+```sh
# run main playbook with "base" tag
make file=playbooks/deploy.yaml tags="base"
# run main playbook with your apps
@@ -75,6 +78,33 @@ make file=playbooks/deploy.yaml tags="[csv list]"
make file=playbooks/vps.yaml
```
+## Example CI/CD
+For the sites that I host, I like to let the owners manage their own source-code on Gitlab, which gets auto deployed to my setup thanks to the `website` tag. This way I don't need to be involved for most day-to-day updates. Eg. `.gitlab-ci.yml`:
+```yaml
+image: 'python:3-slim-buster'
+before_script:
+ - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )'
+ - eval $(ssh-agent -s)
+ - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
+ - mkdir -p ~/.ssh
+ - chmod 700 ~/.ssh
+ - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" >> ~/.ssh/config'
+stages:
+ - deploy
+deploy-job:
+ stage: deploy
+ script:
+ - apt update -y && apt install -y git make sshpass
+ - echo "Deploying application..."
+ - git clone --branch master --depth 1 https://gitlab.com/kdam0/vps.git
+ - cd vps
+ - echo $VAULT_PASS > vaultid
+ - make install
+ - make run file=playbooks/deploy.yaml tags="website" args="-v"
+ - echo "Application successfully deployed!"
+```
+> You need to have the vars `VAULT_PASS`, and `SSH_PRIVATE_KEY` set in the CI/CD settings for each such repo.
+
## Future Plans
1. Documentation for each role.
2. Backups.