https://github.com/microdevops-com/gitlab-server-job
Run commands on servers via Salt or Salt-SSH inside GitLab pipelines
https://github.com/microdevops-com/gitlab-server-job
gitlab-ci saltstack
Last synced: 29 days ago
JSON representation
Run commands on servers via Salt or Salt-SSH inside GitLab pipelines
- Host: GitHub
- URL: https://github.com/microdevops-com/gitlab-server-job
- Owner: microdevops-com
- License: gpl-3.0
- Created: 2019-09-07T17:26:44.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-08-06T13:19:38.000Z (almost 3 years ago)
- Last Synced: 2025-03-17T11:50:43.811Z (over 1 year ago)
- Topics: gitlab-ci, saltstack
- Language: Shell
- Homepage:
- Size: 53.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gitlab-server-job
Run salt states or commands on servers via Salt or SSH inside GitLab pipeline jobs, multiple Salt Masters with failover supported.
# Usage
## Inside Pipelines
Should be added as git submodule for Salt Master repo with .gitlab-ci.yml pipeline e.g. https://github.com/sysadmws/salt-project-template .
```
git submodule add --name .gitlab-server-job -b master -- https://github.com/sysadmws/gitlab-server-job .gitlab-server-job
```
Salt Masters should be gitlab-runners for Gitlab Project with Salt Master git repo.
[ci_sudo scripts](https://github.com/sysadmws/sysadmws-formula/tree/master/scripts/ci_sudo) from sysadmws-formula needed.
## Creating Pipelines
```
pipeline_salt_cmd.sh wait/nowait SALT_PROJECT TIMEOUT TARGET CMD [SEVERITY_OVERRIDE=critical|...] [SALT_SSH_IN_SALT=true]
pipeline_rsnapshot_backup.sh wait/nowait SALT_PROJECT TIMEOUT TARGET SSH/SALT [SSH_HOST=...] [SSH_PORT=...] [SSH_JUMP=...] [SALT_SSH_IN_SALT=true]
```
To run salt command `state.apply app.deploy` with salt timeout `300` for minion `srv1.xyz.tld` inside project `sysadmws/xyz-salt`:
```
pipeline_salt_cmd.sh wait sysadmws/xyz-salt 300 srv1.xyz.tld "state.apply app.deploy"
```
Running rsnapshot_backup examples (via salt, via ssh, via ssh with nonstd port):
```
pipeline_rsnapshot_backup.sh wait sysadmws/xyz-salt 300 srv1.xyz.tld SALT
pipeline_rsnapshot_backup.sh wait sysadmws/xyz-salt 300 srv1.xyz.tld SSH
pipeline_rsnapshot_backup.sh wait sysadmws/xyz-salt 300 srv1.xyz.tld SSH SSH_HOST=1.2.3.4
pipeline_rsnapshot_backup.sh wait sysadmws/xyz-salt 300 srv1.xyz.tld SSH SSH_HOST=1.2.3.4 SSH_PORT=2222
```
Env vars used:
- GL_URL - e.g. https://gitlab.xyz.tld
- GL_USER_PRIVATE_TOKEN - full access token of GitLab user with permissions to create git tags and pipelines
Custom Git Tag created before runnning pipeline to customize pipeline info about what is runnning - so errors and emails will contain info which command on which minion failed.