DevOps(Day-31) : End-to-End automation for Setup Web-Server using jenkins/Ansible (part-2)
Now we are going to run the playbook
Here comes playbook running successfully
Now Playbook to build the java code and deploy the build code:
First we have to create a playbook called as playbookDeployment.yml
Playbook running successfully
Now both the playbooks are ready.
Now we have to create a github repo where we are going to place the playbooks.
Her we are going to make a inventory file also .
And weSo here we are going to github and creating a new repository.
will ask Jenkins to clone the repo and execute the playbooks.
Repository created
In the repository we will create a new file
First playbook we will mention here as playbookInstall.yml
Now we are going to add another file for playbookDeployment.yml
Now going to create a inventory file In inventory fil we create groups with their ip address.
Now we have to go to Jenkins to write down the code in order to run the playbooks
Now w are going to create pipeline
pipeline code =====
pipeline{
agent any
stages{
stage('clone the repo')
{
steps{
git branch: 'main', url: 'https://github.com/SL-CMAT-CEP1-Jenkins-Ansible.git'
}
}
stage('run playbook1')
{
steps{
ansiblePlaybook credentialsId: 'ansible', disableHostKeyChecking: true, installation: 'myansible', inventory: 'dev.inv', playbook: 'PlaybookInstall.yml'
}
]
stage('Run playbook Deployment')
{
steps{
ansiblePlaybook credentialsId: 'ansible', disableHostKeyChecking: true, installation: 'myansible', inventory: 'dev.inv', playbook: 'PlaybookDeployment.yml'
}
}
}
}
Comments
Post a Comment