This is an exercise from sevf education as part of cource in SkillFactory.ru - DEVOPS
terraform apply
ssh [email protected] docker run -d -p 80:80 tutum/wordpress /run.sh
ssh [email protected] docker run -d -p 80:80 tutum/wordpress /run.sh
ping -c 1 178.154.203.182
if [ $? -eq 1 ]; then
echo "stating PING DOWN" >> /home/jenkins/myping_sh.log
fi
ping -c 1 178.154.207.107
if [ $? -eq 1 ]; then
echo "production PING DOWN" >> /home/jenkins/myping_sh.log
fi
sh '''ssh [email protected] uptime >> /home/jenkins/statingUTime.log
ssh [email protected] uptime >> /home/jenkins/productionUTime.log'''
also via pipeline file (12.6)
pipeline {
agent any
stages {
stage('Ping') {
steps {
sh '''ping -c 1 178.154.203.182
if [ $? -eq 1 ]; then
echo "stating PING DOWN" >> /home/jenkins/myping_sh.log
fi
ping -c 1 178.154.207.107
if [ $? -eq 1 ]; then
echo "production PING DOWN" >> /home/jenkins/myping_sh.log
fi
'''
}
}
stage('Uptime') {
steps {
sh '''ssh [email protected] uptime >> /home/jenkins/statingUTime.log
ssh [email protected] uptime >> /home/jenkins/productionUTime.log'''
}
}
stage('Docker') {
steps {
echo 'Hello World'
}
}
}
}
pipeline {
agent any
parameters{ choice(choices: ['All', 'production', 'stating'], description: 'which of server (s)', name: 'ServerName') }
stages {
stage('reboot Production') {
agent {
label 'stating'
}
when {
expression {
return params.ServerName == 'production'
}
}
steps {
sh """
reboot now
"""
}
}
stage('reboot staging') {
when {
expression {
return params.ServerName == 'stating'
}
}
steps {
sh """
ssh [email protected] reboot now
"""
}
}
stage('reboot all') {
when {
expression {
return params.ServerName == 'stating'
}
}
steps {
sh """
ssh [email protected] reboot now
ssh [email protected] reboot now
"""
}
}
}
}