{"id":97226,"date":"2026-11-12T21:31:28","date_gmt":"2026-11-12T14:31:28","guid":{"rendered":"https:\/\/itsystems.vn\/?p=97226"},"modified":"2026-11-19T14:09:28","modified_gmt":"2026-11-19T07:09:28","slug":"ansible-automation-guide","status":"publish","type":"post","link":"https:\/\/itsystems.vn\/en\/ansible-automation-guide\/","title":{"rendered":"Ansible: A Beginner Guide to Automating System Administration"},"content":{"rendered":"<p><!-- its-entranslate-20261119 --><\/p>\n<div>\n<p><strong>Quick answer:<\/strong> Ansible is an open-source <strong>configuration automation \/ Infrastructure as Code<\/strong> tool (backed by Red Hat) that needs no agent: it only requires <strong>SSH<\/strong> access to the target machines and Python. Its main parts are the <strong>inventory<\/strong> (list of machines), <strong>playbooks<\/strong> (YAML files describing what to do), <strong>modules<\/strong> (apt, copy, service and more) and <strong>roles<\/strong> (reusable bundles of playbooks). To get started: (1) install it on the control machine with <code>pip install ansible<\/code> or <code>apt install ansible<\/code>; (2) set up SSH keys to the target machines; (3) create an inventory; (4) write a playbook; (5) run <code>ansible-playbook -i inventory site.yml<\/code>. Benefits: consistent, repeatable changes with fewer manual errors, ideal for installing software, configuring servers and deploying applications at scale.<\/p>\n<\/div>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_91 counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">The content of the article<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/itsystems.vn\/en\/ansible-automation-guide\/#Introduction_to_Ansible_and_system_administration_automation\" >Introduction to Ansible and system administration automation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/itsystems.vn\/en\/ansible-automation-guide\/#Benefits_of_using_Ansible\" >Benefits of using Ansible<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/itsystems.vn\/en\/ansible-automation-guide\/#Ansibles_main_components\" >Ansible&#8217;s main components<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/itsystems.vn\/en\/ansible-automation-guide\/#Installing_and_configuring_Ansible\" >Installing and configuring Ansible<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/itsystems.vn\/en\/ansible-automation-guide\/#Writing_your_first_playbook\" >Writing your first playbook<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/itsystems.vn\/en\/ansible-automation-guide\/#Examples_of_tasks_you_can_automate\" >Examples of tasks you can automate<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/itsystems.vn\/en\/ansible-automation-guide\/#Managing_playbooks_effectively\" >Managing playbooks effectively<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/itsystems.vn\/en\/ansible-automation-guide\/#Ansible_and_DevOps\" >Ansible and DevOps<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/itsystems.vn\/en\/ansible-automation-guide\/#Tips_and_tricks\" >Tips and tricks<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/itsystems.vn\/en\/ansible-automation-guide\/#Conclusion_and_next_steps\" >Conclusion and next steps<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/itsystems.vn\/en\/ansible-automation-guide\/#Need_someone_to_run_your_servers_NAS_and_systems\" >Need someone to run your servers, NAS and systems?<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Introduction_to_Ansible_and_system_administration_automation\"><\/span>Introduction to Ansible and system administration automation<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Ansible is a powerful configuration management tool that makes automating system administration simple and efficient. It was created by Michael DeHaan and first released in 2012, with the goal of saving IT professionals time and effort by automating repetitive administration tasks. Red Hat acquired Ansible in 2015.<\/p>\n<p>Automating administration with Ansible increases consistency, saves money and reduces human error. Its relationship with Infrastructure as Code (IaC) is especially important: Ansible lets you manage infrastructure as code, which improves the way applications are developed and deployed.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Benefits_of_using_Ansible\"><\/span>Benefits of using Ansible<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><strong>Saves time and cost:<\/strong> automated tasks take far less time than manual work.<\/li>\n<li><strong>Reduces human error:<\/strong> each step is clearly defined in a playbook, lowering the risk of mistakes.<\/li>\n<li><strong>Consistency and scalability:<\/strong> configuration stays uniform across many servers and environments.<\/li>\n<li><strong>Faster deployments and updates:<\/strong> application deployments and system updates run quickly and in sync.<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Ansibles_main_components\"><\/span>Ansible&#8217;s main components<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><strong>Control node:<\/strong> the machine that runs Ansible and executes all commands.<\/li>\n<li><strong>Managed nodes:<\/strong> the servers Ansible manages, where tasks are carried out.<\/li>\n<li><strong>Inventory:<\/strong> the list of managed hosts, used to target tasks.<\/li>\n<li><strong>Modules:<\/strong> units of work that each perform a specific task, making Ansible extensible.<\/li>\n<li><strong>Playbooks:<\/strong> ordered collections of tasks that organise your automation logic.<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Installing_and_configuring_Ansible\"><\/span>Installing and configuring Ansible<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><strong>System requirements:<\/strong> the control node needs Linux or macOS (or WSL on Windows) and Python; managed nodes need SSH and Python.<\/li>\n<li><strong>Install on the control node:<\/strong> <code>sudo apt install ansible<\/code> on Debian\/Ubuntu, <code>sudo dnf install ansible-core<\/code> on Fedora or RHEL-based systems, or <code>pip install ansible<\/code>.<\/li>\n<li><strong>Set up SSH keys to managed nodes:<\/strong> generate a key pair and add the public key to <code>~\/.ssh\/authorized_keys<\/code> on each managed node (for example with <code>ssh-copy-id<\/code>).<\/li>\n<li><strong>Test connectivity:<\/strong> run <code>ansible all -m ping<\/code> to check the control node can reach every managed node.<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Writing_your_first_playbook\"><\/span>Writing your first playbook<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><strong>Playbook structure:<\/strong> a playbook is a YAML file that starts with three dashes (<code>---<\/code>) and contains elements such as <strong>hosts<\/strong>, <strong>tasks<\/strong> and <strong>vars<\/strong>.<\/li>\n<li><strong>Use modules for simple tasks:<\/strong> for example, the <code>file<\/code> module creates files and directories.<\/li>\n<li><strong>Use variables to customise playbooks:<\/strong> define variables to adapt the same playbook to different hosts or environments.<\/li>\n<li><strong>Use handlers for change-triggered actions:<\/strong> handlers run only when something has changed, such as restarting a service after its configuration is updated.<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Examples_of_tasks_you_can_automate\"><\/span>Examples of tasks you can automate<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><strong>Install and configure web servers<\/strong> such as Apache or Nginx.<\/li>\n<li><strong>Deploy applications<\/strong> quickly and consistently.<\/li>\n<li><strong>Update systems:<\/strong> patch packages and the operating system without manual intervention.<\/li>\n<li><strong>Manage user accounts:<\/strong> add, modify or remove users.<\/li>\n<li><strong>Configure firewalls<\/strong> in a repeatable way.<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Managing_playbooks_effectively\"><\/span>Managing playbooks effectively<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><strong>Use Git for version control:<\/strong> track changes and roll back easily when needed.<\/li>\n<li><strong>Use roles to reuse code:<\/strong> roles organise playbooks and let you reuse them across projects.<\/li>\n<li><strong>Use Ansible Vault for secrets:<\/strong> encrypt passwords and other sensitive variables.<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Ansible_and_DevOps\"><\/span>Ansible and DevOps<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><strong>Ansible in CI\/CD pipelines:<\/strong> integrate Ansible into CI\/CD to automate testing environments and deployments.<\/li>\n<li><strong>Automating repetitive DevOps work:<\/strong> tasks such as environment setup and releases run quickly, saving the team time.<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Tips_and_tricks\"><\/span>Tips and tricks<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><strong>Use <code>ansible-lint<\/code><\/strong> to catch mistakes and style problems in playbooks.<\/li>\n<li><strong>Use <code>ansible-galaxy<\/code><\/strong> to find and reuse community roles and collections.<\/li>\n<li><strong>Follow best practices:<\/strong> keep tasks idempotent, name every task, and test changes with <code>--check<\/code> before applying them.<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Conclusion_and_next_steps\"><\/span>Conclusion and next steps<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Ansible stands out for automating system administration, saving time and improving efficiency in modern IT environments. To go further, read the official documentation and consider advanced Ansible courses.<\/p>\n<p>Need help automating your company&#8217;s server and network administration? Contact IT Systems at hotline <strong>028.3995.03.59<\/strong> or <a href=\"mailto:contact@itsystems.com.vn\">contact@itsystems.com.vn<\/a>.<\/p>\n<p><!-- its-topic-cta-20261112 --><\/p>\n<section class=\"its-post-cta its-topic-cta\">\n<h2><span class=\"ez-toc-section\" id=\"Need_someone_to_run_your_servers_NAS_and_systems\"><\/span>Need someone to run your servers, NAS and systems?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>IT Systems manages servers, NAS, cloud, backup and user accounts on a schedule, with a monthly operations report.<\/p>\n<p><a href=\"https:\/\/itsystems.vn\/en\/it-system-management\/\">IT system management services<\/a> \u00b7 <a href=\"tel:+842839950359\">Call +84 28 3995 0359<\/a><\/p>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>Quick answer: Ansible is an open-source configuration automation \/ Infrastructure as Code tool (backed by Red Hat) that needs no agent: it only requires SSH access to the target machines and Python. Its main parts are the inventory (list of machines), playbooks (YAML files describing what to do), modules (apt, copy, service and more) and [&hellip;]<\/p>\n","protected":false},"author":28,"featured_media":58204,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"rank_math_focus_keyword":"ansible automation","rank_math_title":"Ansible Guide: Automate Server Configuration (IaC) | IT Systems","rank_math_description":"Ansible is an agentless, open-source automation\/IaC tool. Learn its inventory, playbooks, modules and roles, and how to install and run your first playbook.","rank_math_robots":"","rank_math_canonical_url":"","rank_math_schema":"","footnotes":""},"categories":[2146],"tags":[],"class_list":["post-97226","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-it-knowledge"],"wpml_current_locale":"en_US","wpml_translations":{"vi_VN":{"locale":"vi_VN","id":58200,"slug":"ansible-huong-dan-tu-dong-hoa-quan-tri-he-thong-tu-a-den-z","post_title":"Ansible: H\u01b0\u1edbng D\u1eabn T\u1ef1 \u0110\u1ed9ng H\u00f3a Qu\u1ea3n Tr\u1ecb H\u1ec7 Th\u1ed1ng T\u1eeb A \u0110\u1ebfn Z","href":"https:\/\/itsystems.vn\/ansible-huong-dan-tu-dong-hoa-quan-tri-he-thong-tu-a-den-z\/"}},"_links":{"self":[{"href":"https:\/\/itsystems.vn\/en\/wp-json\/wp\/v2\/posts\/97226","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itsystems.vn\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itsystems.vn\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itsystems.vn\/en\/wp-json\/wp\/v2\/users\/28"}],"replies":[{"embeddable":true,"href":"https:\/\/itsystems.vn\/en\/wp-json\/wp\/v2\/comments?post=97226"}],"version-history":[{"count":2,"href":"https:\/\/itsystems.vn\/en\/wp-json\/wp\/v2\/posts\/97226\/revisions"}],"predecessor-version":[{"id":102049,"href":"https:\/\/itsystems.vn\/en\/wp-json\/wp\/v2\/posts\/97226\/revisions\/102049"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itsystems.vn\/en\/wp-json\/wp\/v2\/media\/58204"}],"wp:attachment":[{"href":"https:\/\/itsystems.vn\/en\/wp-json\/wp\/v2\/media?parent=97226"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itsystems.vn\/en\/wp-json\/wp\/v2\/categories?post=97226"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itsystems.vn\/en\/wp-json\/wp\/v2\/tags?post=97226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}