Example for building an artifact using Jenkins and deploying it using Ansible

0 votes
Can you give an example for building an artifact using Jenkins and deploying it using Ansible? Can you describe the steps of achieving the same?
Jul 31 in Jenkins by Harsh
37 views

1 answer to this question.

+1 vote

Hey @Harsh, follow this to get an understanding on building an artifact using Jenkins and Deploying it using Ansible.  

Install "publish Over SSH" plugin

Manage Jenkins > Manage Plugins > Available > Publish over SSH

Enable connection between Ansible and Jenkins

Manage Jenkins > Configure System > Publish Over SSH > SSH Servers

SSH Servers:

Hostname:<ServerIP>
username: username
password: *******

Test the connection "Test Connection"

create a copywarfile.yml on Ansible under /opt/playbooks

# example.yml
---
- hosts: all 
  become: true
  tasks: 
    - name: example
        copy:
          src: /op/playbooks/wabapp/target/webapp.war
          dest: /opt/apache-tomcat-8.5.32/webapps

Add tomcat server details to /etc/ansible/hosts (if you are using other hosts file update server info there)

echo "<server_IP>" >> /etc/ansible/hosts

Create Jenkins job, Fill the following details,

Source Code Management:

Repository: https://github.com/path/hello-world.git
Branches to build : */master

Build:

Root POM:pom.xml
Goals and options : clean install package

Add post-build steps

Send files or execute commands over SSH
SSH Server : ansible_server
Source fiels: webapp/target/*.war
Remote directory: //opt//playbooks

Add post-build steps

Send files or execute commands over ssh
SSH Server : ansible_server
Exec command ansible-playbook /opt/playbooks/example.yml
Execute job and you should be able to seen build has been deployed on Tomcat server.

answered Jul 31 by Vijay

Related Questions In Jenkins

0 votes
1 answer

Why is it displaying Jenkins build failure for Android app

I think you should try this. Try Uninstalling ...READ MORE

answered Apr 12, 2018 in Jenkins by shubham
• 6,890 points
223 views
0 votes
2 answers

Is possible for Jenkins to auto start and stop slave nodes?

Try Jenkins Plugin called as Slave SetupPlugin. This ...READ MORE

answered Aug 6, 2018 in Jenkins by Nilesh
• 6,900 points
746 views
0 votes
1 answer

Ansible or Jenkins pipelines for bigger jobs

Well, you are indeed well aware of ...READ MORE

answered Jun 16, 2018 in Jenkins by shubham
• 6,890 points
213 views
0 votes
1 answer

Unable to access Jenkins. I newly installed Jenkins but for some reason I cannot access it.

Try changing the port, Change JENKINS_AJP_PORT="xyz" to JENKINS_AJP_PORT="abc" If changing the ...READ MORE

answered Jul 4, 2018 in Jenkins by Sophie may
• 9,530 points
235 views
+13 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
124 views
0 votes
1 answer
+1 vote
3 answers
+1 vote
1 answer