add server script

This commit is contained in:
Nana Janashia
2021-04-03 18:57:36 +02:00
parent 3e561bbf2e
commit f883a86564
2 changed files with 19 additions and 4 deletions

View File

@@ -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
View 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