Automating System Updates with Ansible Playbook
Raees Qazi | DevOps Engineer | Learner | Mentor | Creator | Briller Technologies
Hello everyone! ๐
Today, I’m going to share an exciting Ansible project with you. It’s a simple yet powerful example that shows how to automate system updates using an Ansible Playbook. I’m sure you’ll enjoy this hands-on learning experience.

๐ง Prerequisites
Before starting the practical part, make sure:
- You have a master/Ansible control node set up.
- At least one managed node (target server) is connected to your master/Ansible machine.
⚙️ Project Overview
In this project, we’ll create a playbook that updates and upgrades the system packages.
Important Note:
Always perform system updates outside of working hours to avoid downtime or interruptions.
๐งพ Steps to Create the Playbook
- Open a new playbook file in the terminal:
vim patch_server.yml
Write the following playbook content:
- name: Patch server
hosts: server2
become: yes
tasks:
- name: Update and upgrade packages
apt:
update_cache: yes
upgrade: dist
- name: Restart the server
reboot:
msg: "Server under patching activity maintenance"
when: ansible_distribution == 'Ubuntu'Save and exit the file:
:wq
Run the playbook:
ansible-playbook patch_server.yml
๐ Result
That’s it! ๐
Your system will now automatically update and reboot using the playbook. You’ve just automated a common sysadmin task with Ansible — pretty cool, right?
๐ฌ Final Thoughts
Automation saves time and reduces human error. Using Ansible for patching ensures consistency across multiple servers with minimal effort.
If you found this guide helpful, don’t forget to share and subscribe for more DevOps tutorials.
๐ Online References
- LinkedIn: https://www.linkedin.com/in/raees-yaqoob-qazi-ryqs/
- Medium Blog: https://medium.com/@raeesyaqubqazi
- Blogspot: https://brillertechnologies.blogspot.com/
- Facebook Page: https://web.facebook.com/profile.php?id=61553548371216
- YouTube Channel: https://www.youtube.com/@RaeesQ.
- TikTok: https://www.tiktok.com/@mrryqs?_t=ZS-8y7t0fQfJKu&_r=1
Comments
Post a Comment