www.coachdevop...
Pre-requisites:
Ansible is installed and Boto is also installed on Jenkins instance
Ansible plug-in is installed in Jenkins.
Make sure you create an IAM role with AmazonS3FullAccess policy and attach the role to Jenkins EC2 instance.
Playbook for creating new S3 bucket needs to be created but you can refer my GitHub Repo
Ansible playbook for AWS S3 bucket creation
Steps:
1. Create Ansible playbook for S3 bucket creation
(Sample playbook is available in my GitHub Repo, you can use that as a reference)
2. Create Jenkins Pipeline
pipeline {
agent any
stages {
stage ("checkout") {
steps {
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[url: 'github.com/aka...]]])
}
}
stage('execute') {
steps {
//to suppress warnings when you execute playbook
sh "pip install --upgrade requests==2.20.1"
// execute ansible playbook
ansiblePlaybook 'create-s3.yml'
}
}
}
}
3. Build the Pipeline
4. Check Pipeline Console output
29 авг 2024