add server script
This commit is contained in:
@@ -21,6 +21,10 @@ pipeline {
|
||||
}
|
||||
}
|
||||
stage("execute ansible playbook from the ansible-server") {
|
||||
environment {
|
||||
AWS_ACCESS_KEY_ID = credentials('jenkins_aws_access_key_id')
|
||||
AWS_SECRET_ACCESS_KEY = credentials('jenkins_aws_secret_access_key')
|
||||
}
|
||||
steps {
|
||||
script {
|
||||
echo "executing ansible-playbook"
|
||||
@@ -35,10 +39,10 @@ pipeline {
|
||||
remote.user = user
|
||||
|
||||
sshCommand remote: remote, command: "ls -l"
|
||||
sshCommand remote: remote, command: "apt update"
|
||||
sshCommand remote: remote, command: "apt install ansible -y"
|
||||
sshCommand remote: remote, command: "apt install python3-pip -y"
|
||||
sshCommand remote: remote, command: "pip3 install boto3 botocore"
|
||||
|
||||
// set AWS credentials
|
||||
sshScript remote: remote, script: "ansible/prepare-server.sh ${AWS_ACCESS_KEY_ID} ${AWS_SECRET_ACCESS_KEY}"
|
||||
|
||||
sshCommand remote: remote, command: "ansible-playbook docker-and-compose.yaml"
|
||||
}
|
||||
}
|
||||
|
||||
11
ansible/prepare-server.sh
Normal file
11
ansible/prepare-server.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
apt update
|
||||
apt install ansible -y
|
||||
apt install python3-pip -y
|
||||
pip3 install boto3 botocore
|
||||
|
||||
export AWS_ACCESS_KEY_ID=$1
|
||||
export AWS_SECRET_ACCESS_KEY=$2
|
||||
|
||||
|
||||
Reference in New Issue
Block a user