{"id":381,"date":"2015-12-03T09:36:00","date_gmt":"2015-12-03T09:36:00","guid":{"rendered":"https:\/\/opstree.com\/blog\/\/2015\/12\/03\/setup-jenkins-using-ansible\/"},"modified":"2019-09-18T13:45:14","modified_gmt":"2019-09-18T08:15:14","slug":"setup-jenkins-using-ansible","status":"publish","type":"post","link":"https:\/\/opstree.com\/blog\/2015\/12\/03\/setup-jenkins-using-ansible\/","title":{"rendered":"Setup Jenkins using Ansible"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align:left;\">\n<div dir=\"ltr\" style=\"text-align:left;\">\n<div dir=\"ltr\" style=\"line-height:1.38;margin-bottom:0;margin-top:0;\">In this document I\u2019ll walk you through how you can setup Jenkins using Ansible.<p><\/p>\n<p>Prerequisites<\/p>\n<\/div>\n<ul style=\"margin-bottom:0;margin-top:0;\">\n<li style=\"background-color:transparent;color:black;font-family:Arial;font-size:14.666666666667px;font-style:normal;font-variant:normal;font-weight:400;list-style-type:disc;text-decoration:none;vertical-align:baseline;\">\n<div style=\"line-height:1.5;margin-bottom:0;margin-top:0;text-align:justify;\">&nbsp;OS &#8211; Ubuntu {at least two machine required in production}<\/div>\n<\/li>\n<li style=\"background-color:transparent;color:black;font-family:Arial;font-size:14.666666666667px;font-style:normal;font-variant:normal;font-weight:400;list-style-type:disc;text-decoration:none;vertical-align:baseline;\">\n<div style=\"line-height:1.5;margin-bottom:0;margin-top:0;text-align:justify;\">&nbsp;First machine for Ansible &nbsp;installation<\/div>\n<\/li>\n<li style=\"background-color:transparent;color:black;font-family:Arial;font-size:14.666666666667px;font-style:normal;font-variant:normal;font-weight:400;list-style-type:disc;text-decoration:none;vertical-align:baseline;\">\n<div style=\"line-height:1.5;margin-bottom:0;margin-top:0;text-align:justify;\">&nbsp;Second machine where we will install jenkins server<\/div>\n<\/li>\n<li style=\"background-color:transparent;color:black;font-family:Arial;font-size:14.666666666667px;font-style:normal;font-variant:normal;font-weight:400;list-style-type:disc;text-decoration:none;vertical-align:baseline;\">\n<div style=\"line-height:1.5;margin-bottom:0;margin-top:0;text-align:justify;\">You should have basic understanding of ansible workflow.<\/div>\n<\/li>\n<\/ul>\n<div dir=\"ltr\" style=\"line-height:1.5;margin-bottom:16pt;margin-top:0;text-align:justify;\">Note : &nbsp;You should have password less login enabled in second machine. use this link&nbsp;<br><span id=\"docs-internal-guid-acb8815f-620c-108f-1de6-ecb15a224716\"><a href=\"http:\/\/www.linuxproblem.org\/art_9.html\" target=\"_blank\" rel=\"noopener\">http:\/\/www.linuxproblem.org\/art_9.html<\/a><\/span><p><\/p>\n<p>Ansible Installation<br>Before starting with installing Jenkins using Ansible, you need to have Ansible installed in your system.<\/p>\n<\/div>\n<\/div>\n<pre style=\"line-height:1.38;margin-bottom:0;margin-top:10pt;\">$ curl https:\/\/raw.githubusercontent.com\/OpsTree\/AnsiblePOC\/alok\/scripts\/Setup\/setup_ansible.sh | sudo bash<\/pre>\n<p>Setup jenkins using Ansible<br>Install jenkins ansible roles<br>Once we have ansible installed in our system, we can start installing the jenkins using ansible. To install we will use an already available ansible role to setup jenkins<\/p>\n<div dir=\"ltr\" style=\"line-height:1.38;margin-bottom:0;margin-top:10pt;\">\n<h5 style=\"background-image:url('http:\/\/2.bp.blogspot.com\/_z5ltvMQPaa8\/SjJXr_U2YBI\/AAAAAAAAAAM\/46OqEP32CJ8\/s320\/codebg.gif');background:#f0f0f0;border:1px dashed #CCCCCC;color:black;font-family:arial;font-size:12px;height:auto;line-height:20px;overflow:auto;padding:0;text-align:left;width:99%;\"><b style=\"background-color:#f0f0f0;font-family:Consolas;font-size:12px;font-style:italic;line-height:20px;text-indent:36pt;white-space:pre-wrap;\">$ ansible-galaxy install geerlingguy.jenkins<\/b><\/h5>\n<\/div>\n<div dir=\"ltr\" style=\"line-height:1.38;margin-bottom:0;margin-top:10pt;\">to know more about the jenkins role hit this link <b> <\/b><a style=\"text-decoration:none;\" href=\"https:\/\/galaxy.ansible.com\/detail#\/role\/440\" target=\"_blank\" rel=\"noopener\"><b>https:\/\/galaxy.ansible.com\/detail#\/role\/440<\/b><\/a><\/div>\n<p>Ansible roles default directory path is \/etc\/ansible\/roles<br>Make ansible playbook file<\/p>\n<div dir=\"ltr\" style=\"line-height:1.38;margin-bottom:0;margin-top:0;\">Now the next step is to use the installed jenkins roles to install the jenkins. For this purpose we will create a playbook &nbsp;and hosts file with below content<p><\/p>\n<pre style=\"background-image:url('http:\/\/2.bp.blogspot.com\/_z5ltvMQPaa8\/SjJXr_U2YBI\/AAAAAAAAAAM\/46OqEP32CJ8\/s320\/codebg.gif');background:#f0f0f0;border:1px dashed #CCCCCC;color:black;font-family:arial;font-size:12px;height:auto;line-height:20px;overflow:auto;padding:0;text-align:left;width:99%;\"><span id=\"docs-internal-guid-acb8815f-5c23-ff2e-4ee5-bec827bfa43b\"><b>$ cd ~\/MyPlaybook\/jenkins<\/b><\/span><\/pre>\n<\/div>\n<div dir=\"ltr\" style=\"line-height:1.38;margin-bottom:0;margin-top:0;\">create a file hosts and add below content<\/div>\n<div dir=\"ltr\" style=\"line-height:1.38;margin-bottom:0;margin-top:0;\">[jenkins_hosts]<\/div>\n<div dir=\"ltr\" style=\"line-height:1.38;margin-bottom:0;margin-top:0;\">192.168.33.15<p><\/p>\n<\/div>\n<div dir=\"ltr\" style=\"line-height:1.38;margin-bottom:0;margin-top:0;text-indent:36pt;\"><img decoding=\"async\" style=\"-webkit-transform:rotate(0.00rad);border:none;transform:rotate(0.00rad);\" src=\"https:\/\/lh5.googleusercontent.com\/pLMVLXcAZ9AjbQB807g4UTXk6vzQ22yeKru9NpJ3cCfIBLf3n82zCBuAac2PfmkJ5WMJWPSmEhA5QaTNQO3NHprKadBG-kQ9XzopZdElACIRyUeB5PdsqFRbit-f0DbulxuAt2_M\" alt=\"Screenshot from 2015-11-30 12:55:41.png\" width=\"464px;\" height=\"85px;\"><\/div>\n<div dir=\"ltr\" style=\"line-height:1.38;margin-bottom:0;margin-top:0;\">Next create &nbsp;a file site.yml and add below content<\/div>\n<div dir=\"ltr\" style=\"line-height:1.38;margin-bottom:0;margin-top:0;\">&#8212;<\/div>\n<div dir=\"ltr\" style=\"line-height:1.38;margin-bottom:0;margin-top:0;\">&#8211; hosts: jenkins_hosts<\/div>\n<div dir=\"ltr\" style=\"line-height:1.38;margin-bottom:0;margin-top:0;\">&nbsp;roles:<\/div>\n<div dir=\"ltr\" style=\"line-height:1.38;margin-bottom:0;margin-top:0;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8211; { role: geerlingguy.jenkins }<p><\/p>\n<\/div>\n<div dir=\"ltr\" style=\"line-height:1.38;margin-bottom:0;margin-top:0;\"><img decoding=\"async\" style=\"-webkit-transform:rotate(0.00rad);border:none;transform:rotate(0.00rad);\" src=\"https:\/\/lh3.googleusercontent.com\/-fuK0A7QcCVORsZZw-TLzAQM4aCLTOupifJflH8zULXBpSgmc598pKsiMazp18tCszSWJEUH9WzEc-kJY1vey3fIadlgRUMdbwQGI8RvrxQ7UrRCDo67yBYJr0ReUSh7Mg1pSStJ\" alt=\"Screenshot from 2015-11-30 12:59:08.png\" width=\"478px;\" height=\"135px;\"><\/div>\n<div dir=\"ltr\" style=\"line-height:1.38;margin-bottom:0;margin-top:0;\">so configuration file is done, the next step is to run ansible playbook command<p><\/p>\n<div dir=\"ltr\" style=\"line-height:1.38;margin-bottom:0;margin-top:0;\">\n<pre style=\"background-image:url('http:\/\/2.bp.blogspot.com\/_z5ltvMQPaa8\/SjJXr_U2YBI\/AAAAAAAAAAM\/46OqEP32CJ8\/s320\/codebg.gif');background:#f0f0f0;border:1px dashed #CCCCCC;color:black;font-family:arial;font-size:12px;height:auto;line-height:20px;overflow:auto;padding:0;text-align:left;width:99%;\"><span id=\"docs-internal-guid-acb8815f-5c23-ff2e-4ee5-bec827bfa43b\">$ ansible-playbook -i hosts site.yml<\/span><\/pre>\n<\/div>\n<\/div>\n<p>Now that Jenkins is running, go to http:\/\/192.168.33.15:8080. You&#8217;ll be welcome by the default Jenkins screen.<\/p>\n<\/div>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this document I\u2019ll walk you through how you can setup Jenkins using Ansible. Prerequisites &nbsp;OS &#8211; Ubuntu {at least two machine required in production} &nbsp;First machine for Ansible &nbsp;installation &nbsp;Second machine where we will install jenkins server You should have basic understanding of ansible workflow. Note : &nbsp;You should have password less login enabled &hellip; <a href=\"https:\/\/opstree.com\/blog\/2015\/12\/03\/setup-jenkins-using-ansible\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Setup Jenkins using Ansible&#8221;<\/span><\/a><\/p>\n","protected":false},"author":171775670,"featured_media":29900,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[28070474,351789],"tags":[768739304,44070,613002,768739299],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2025\/11\/DevSecOps-1.jpg","jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pfDBOm-69","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/381"}],"collection":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/users\/171775670"}],"replies":[{"embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/comments?post=381"}],"version-history":[{"count":5,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/381\/revisions"}],"predecessor-version":[{"id":1335,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/381\/revisions\/1335"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/media\/29900"}],"wp:attachment":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/media?parent=381"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/categories?post=381"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/tags?post=381"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}