Created
November 10, 2022 10:46
-
-
Save chrisedrego/b60c7575bdcdf19abebfd613e334b012 to your computer and use it in GitHub Desktop.
Prometheus CI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$1" == "" ] && [ "$2" == "" ] && [ "$3" == "" ]; then echo "USER_NAME, HOST_NAME, KEY_LOCATION values are not set, Sourcing environment variables from file" && source .env ; else "echo 'Required Values are found.'" ; fi | |
# Adding the username to the Prometheus Group to access and makes changes to the configuration file. | |
# sudo adduser $1 prometheus | |
ssh -o StrictHostKeyChecking=no -i $KEY_LOCATION $USER_NAME@$HOST_NAME "sudo systemctl stop prometheus || echo 'failed to stop prometheus service'" | |
ssh -o StrictHostKeyChecking=no -i $KEY_LOCATION $USER_NAME@$HOST_NAME "sudo mv /etc/prometheus/prometheus.yml /etc/prometheus/prometheus.yml.old" | |
scp -o StrictHostKeyChecking=no -i $KEY_LOCATION -r ./prometheus.yml $USER_NAME@$HOST_NAME:/etc/prometheus | |
ssh -o StrictHostKeyChecking=no -i $KEY_LOCATION $USER_NAME@$HOST_NAME "sudo chown -R prometheus:prometheus /etc/prometheus/" | |
ssh -o StrictHostKeyChecking=no -i $KEY_LOCATION $USER_NAME@$HOST_NAME "promtool check config /etc/prometheus/prometheus.yml" | |
ssh -o StrictHostKeyChecking=no -i $KEY_LOCATION $USER_NAME@$HOST_NAME "sudo systemctl start prometheus || echo 'Failed to start Prometheus Service'" | |
ssh -o StrictHostKeyChecking=no -i $KEY_LOCATION $USER_NAME@$HOST_NAME "sudo systemctl status prometheus || echo 'Failed to start Prometheus Service'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment