{"id":9825,"date":"2022-02-15T16:54:34","date_gmt":"2022-02-15T11:24:34","guid":{"rendered":"https:\/\/opstree.com\/blog\/\/?p=9825"},"modified":"2025-11-21T12:47:06","modified_gmt":"2025-11-21T07:17:06","slug":"bigbulls-game-series-patching-mongodb-using-ansible","status":"publish","type":"post","link":"https:\/\/opstree.com\/blog\/2022\/02\/15\/bigbulls-game-series-patching-mongodb-using-ansible\/","title":{"rendered":"BigBulls Game Series- Patching MongoDB using Ansible"},"content":{"rendered":"\r\n<p>MongoDB is the most popular NoSQL and an open-source document-oriented database. The term <strong>NoSQL <\/strong>means <strong>&#8216;non-relational&#8217;<\/strong>.This simply means mongo does not base on a table-like relational database structure. It is moreover a schemaless database. In Mongo information is stored in JSON-style documents.<\/p>\r\n\r\n<p>&nbsp;<\/p>\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"869\" height=\"488\" class=\"wp-image-9857\" src=\"https:\/\/opstree.com\/blog\/\/wp-content\/uploads\/2022\/02\/patch3.png?w=869\" alt=\"\" \/><\/figure>\r\n\r\n\r\n\r\n<p>&nbsp;<\/p>\r\n\r\n<p><!--more--><\/p>\r\n\r\n\r\n\r\n<p><strong>What is Patching?<\/strong><\/p>\r\n\r\n\r\n\r\n<p>1. A patch is a set of updates containing a delta of changes between two different versions.<\/p>\r\n\r\n\r\n\r\n<p>2. Patching is basically done to fix security-related vulnerabilities.<\/p>\r\n\r\n\r\n\r\n<p>3. Patch is aimed to add a new functionality and remediates current bugs to keep our system updated and secure from attacks.<\/p>\r\n\r\n\r\n\r\n<p>4. Some patch updates also help us in fixing issues with drivers and software running on the system.<\/p>\r\n\r\n\r\n\r\n<p>5. The longer a server is unpatched, the bigger is the risk of cyber-attacks. A <strong>golden thumb rule<\/strong> is to apply patches within <strong>30 days <\/strong>of vendors making them available.<\/p>\r\n\r\n\r\n\r\n<p><strong>Factors to be considered while Patching-<\/strong><br \/>When we are patching any application server or a database server the First thing that comes to our mind is there should be no downtime in both cases.<br \/>When a hole is found, patching seems obvious. At the same time, we need to look at the total hours and money spent patching versus the cost of downtime.<br \/>Here are some important key factors to consider &#8211;<\/p>\r\n\r\n\r\n\r\n<p>1. <strong>Cost of lost data<\/strong>&#8211; When we are patching any server this is a possibility of data loss. So we should have a replication of the data\/DR system so that we should not suffer any data loss which could affect our business reputation.<\/p>\r\n\r\n\r\n\r\n<p><strong>2. Downtime costs<\/strong>&#8211; Downtime simply means when the application is not available to serve requests which can be due to any region either technical glitch, network outage. Downtime can potentially paralyze your organization, and in some cases, even cause irreparable damage.<\/p>\r\n\r\n\r\n\r\n<p>As we have discussed basic factors to be considered while patching. Now let&#8217;s get started with the important things which we have to keep in mind which patching and rebooting a <a href=\"https:\/\/opstree.com\/blog\/2022\/08\/23\/a-detailed-guide-to-key-metrics-of-mongodb-monitoring\/\">MongoDB<\/a> cluster-<\/p>\r\n\r\n\r\n\r\n<p>1. While patching a server either it is (application or database) in this case we are taking database(MongoDB) we have to exclude all the application and database-related packages.<\/p>\r\n\r\n\r\n\r\n<p>2. Before taking reboot we have to take backup of all the indexes collection with respective of service database.<\/p>\r\n\r\n\r\n\r\n<p>3. While rebooting a MongoDB cluster we have to keep in mind that first, we have to reboot secondary nodes and then go for primary nodes.<\/p>\r\n\r\n\r\n\r\n<p>4. After reboot when primary nodes come up you need to verify the indexes collection should be the same as it was before the reboot.<\/p>\r\n\r\n\r\n\r\n<p><strong>Introduction to Ansible Role-<\/strong> As we all know that in today&#8217;s world is all about automation. Especially when we talk about the <a href=\"https:\/\/opstree.com\/blog\/2025\/05\/15\/devops-how-it-works-and-why-it-matters\/\" target=\"_blank\" rel=\"noopener\">DevOps lifecycle<\/a> we always try to automate tasks. Patching is an important aspect when we talk about security. Automating it will help us to patch more servers in a single click.<br \/><strong>Here is the Ansible role for patching a mongo cluster<\/strong>&#8211;<\/p>\r\n\r\n\r\n\r\n<p><a href=\"https:\/\/github.com\/OT-OSM\/mongo_kernel_patching\" target=\"_blank\" rel=\"noreferrer noopener\">git repo link<\/a><\/p>\r\n\r\n\r\n\r\n<p>1. Firstly clone the repo-<\/p>\r\n\r\n\r\n\r\n<p>2. Then using the following command you can start patching your mongo cluster-<\/p>\r\n\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"alignleft size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-9860\" src=\"https:\/\/opstree.com\/blog\/\/wp-content\/uploads\/2022\/02\/2.png?w=1024\" alt=\"\" width=\"614\" height=\"116\" \/><\/figure>\r\n<\/div>\r\n\r\n<p>&nbsp;<\/p>\r\n\r\n<p>&nbsp;<\/p>\r\n\r\n<p>&nbsp;<\/p>\r\n\r\n<p><strong>Below<\/strong> <strong>recording will help you in understanding the working of Ansible role-<\/strong><\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-video wp-block-embed is-type-video is-provider-videopress\">\r\n<div class=\"wp-block-embed__wrapper\">https:\/\/videopress.com\/v\/OqUp8Nal?resizeToParent=true&amp;cover=true&amp;preloadContent=metadata&amp;useAverageColor=true<\/div>\r\n<div>\u00a0<\/div>\r\n<\/figure>\r\n\r\n<p><strong>Conclusion-<\/strong><br \/>Patching simply means keeping your servers updated so that there is no security breach. Effective patch management process requires a combination of automation and best practices. With the right patches in place, it improves the functionality and performance of your infrastructure. At the same time, it can also improve uptime, error rates, system-level performance metrics.<br \/><em>&#8220;<strong>If you enjoyed this article, share it with your friends<\/strong> <strong>and colleagues!&#8221;<\/strong><\/em><\/p>\r\n\r\n\r\n\r\n<p><strong style=\"font-weight: bold;\">Blog Pundit:<\/strong> <a href=\"https:\/\/opstree.com\/blog\/\/author\/bhupendersinghb5dca0b393\/\"><strong>Bhupender rawat<\/strong><\/a> <strong>and <\/strong><a href=\"https:\/\/opstree.com\/blog\/\/author\/abhishekbhardwaj510\/\"><strong>Abhishek Dubey<\/strong><\/a><\/p>\r\n\r\n\r\n\r\n<p class=\"has-text-align-center\"><strong>Related Searches &#8211; <a href=\"https:\/\/opstree.com\/\" target=\"_blank\" rel=\"noopener\">DevOps Solutions<\/a> | <a href=\"https:\/\/opstree.com\/aws-partner\/\" target=\"_blank\" rel=\"noopener\">AWS Partner<\/a><\/strong><\/p>\r\n\r\n\r\n","protected":false},"excerpt":{"rendered":"<p>MongoDB is the most popular NoSQL and an open-source document-oriented database. The term NoSQL means &#8216;non-relational&#8217;.This simply means mongo does not base on a table-like relational database structure. It is moreover a schemaless database. In Mongo information is stored in JSON-style documents. &nbsp; &nbsp;<\/p>\n","protected":false},"author":211948566,"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],"tags":[460,304054034,551126,38392303,768739286,4996032],"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-2yt","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/9825"}],"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\/211948566"}],"replies":[{"embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/comments?post=9825"}],"version-history":[{"count":27,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/9825\/revisions"}],"predecessor-version":[{"id":29976,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/9825\/revisions\/29976"}],"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=9825"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/categories?post=9825"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/tags?post=9825"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}