Practical Ansible 2: Automate infrastructure, manage configuration, and deploy applications with Ansible 2.9

Daniel Oh (Author), James Freeman (Author), Fabio Alessandro Locati



Key Features

  • Use Ansible 2.9 to automate and control your infrastructure
  • Delve into advanced functionality such as plugins and custom modules in Ansible
  • Automate and orchestrate major cloud platforms such as OpenStack, AWS, and Azure using Ansible

Book Description

Ansible enables you to automate software provisioning, configuration management, and application roll-outs, and can be used as a deployment and orchestration tool. While Ansible provides simple yet powerful features to automate multi-layer environments using agentless communication, it can also solve other critical IT challenges, such as ensuring continuous integration and continuous deployment (CI/CD) with zero downtime.

In this book, you'll work with Ansible 2.9 and learn to solve complex issues quickly with the help of task-oriented scenarios. You'll start by installing and configuring Ansible on Linux and macOS to automate monotonous and repetitive IT tasks and get to grips with concepts such as playbooks, inventories, and network modules. As you progress, you'll gain insight into the YAML syntax and learn how to port between Ansible versions. In addition to this, you'll also understand how Ansible enables you to orchestrate multi-layer environments such as networks, containers, and the cloud.

By the end of this Ansible book, you'll be well - versed in writing playbooks and other related Ansible code to overcome just about all of your IT challenges, from infrastructure-as-code provisioning to application deployments, and even handling the mundane day-to-day maintenance tasks that take up so much valuable time.

What you will learn

  • Become familiar with the fundamentals of the Ansible framework
  • Set up role-based variables and dependencies
  • Avoid common mistakes and pitfalls when writing automation code in Ansible
  • Extend Ansible by developing your own modules and plugins
  • Contribute to the Ansible project by submitting your own code
  • Follow best practices for working with cloud environment inventories
  • Troubleshoot issues triggered during Ansible playbook runs

Who this book is for

If you are a DevOps engineer, administrator, or any IT professional looking to automate IT tasks using Ansible, this book is for you. Prior knowledge of Ansible is not necessary.



  • 使用 Ansible 2.9 自動化和控制基礎架構

  • 深入研究 Ansible 的高級功能,如插件和自定義模塊

  • 使用 Ansible 自動化和協調主要的雲平台,如 OpenStack、AWS 和 Azure


Ansible 讓您能夠自動化軟件供應、配置管理和應用程序部署,並可用作部署和協調工具。雖然 Ansible 提供了簡單而強大的功能,以使用無代理通信自動化多層環境,但它還可以解決其他關鍵的 IT 挑戰,例如確保零停機的持續集成和持續部署(CI/CD)。

在本書中,您將使用 Ansible 2.9,並通過以任務為導向的場景快速解決複雜問題。您將從在 Linux 和 macOS 上安裝和配置 Ansible 開始,以自動化單調和重複的 IT 任務,並熟悉 playbook、清單和網絡模塊等概念。隨著進展,您將深入了解 YAML 語法,並學習如何在不同版本的 Ansible 之間移植。此外,您還將了解 Ansible 如何使您能夠協調多層環境,如網絡、容器和雲。

通過閱讀本書,您將精通編寫 playbook 和其他相關的 Ansible 代碼,以應對幾乎所有的 IT 挑戰,從基礎架構即代碼供應到應用程序部署,甚至處理占用寶貴時間的乏味日常維護任務。


  • 熟悉 Ansible 框架的基礎知識

  • 設置基於角色的變量和依賴關係

  • 在編寫 Ansible 自動化代碼時避免常見的錯誤和陷阱

  • 通過開發自己的模塊和插件擴展 Ansible

  • 通過提交自己的代碼為 Ansible 項目做出貢獻

  • 遵循與雲環境清單一起工作的最佳實踐

  • 在 Ansible playbook 執行期間解決問題


如果您是 DevOps 工程師、管理員或任何希望使用 Ansible 自動化 IT 任務的 IT 專業人士,本書適合您。不需要事先了解 Ansible。


Daniel Oh is a principal technical marketing manager at Red Hat. He provides runtimes, frameworks, fast data access, and high-performance messaging in flexible, easy-to-use, cost-effective, open, and collaborative ways. He's also a CNCF ambassador and DevOps Institute ambassador who evangelizes how to design and develop cloud-native serverless microservices and deploy them to multi/hybrid cloud-native platforms based on CNCF projects. Daniel loves to share his developer experiences with DevOps folks in terms of how to evolve traditional microservices to cloud-native, event-driven, and serverless applications via technical workshops, brown bag sessions, hackathons, and hands-on labs across regions at many international conferences.

James Freeman is an accomplished IT consultant with over 20 years' experience in the technology industry. He has more than 5 years of first-hand experience of solving real-world enterprise problems in production environments using Ansible, frequently introducing Ansible as a new technology to businesses and CTOs for the first time. In addition, he has authored and facilitated bespoke Ansible workshops and training sessions, and has presented at both international conferences and meetups on Ansible.

Fabio Alessandro Locati - commonly known as Fale - is an EMEA senior solution architect at Red Hat, a public speaker, an author, and an open source contributor. His primary areas of expertise are Linux, automation, security, and cloud technologies. Fale has more than 15 years of working experience in IT, with many of them spent consulting for many companies, including dozens of Fortune 500 companies. Fale has written Learning Ansible 2.7, Learning Ansible 2, and OpenStack Cloud Security, and has been part of the review process of multiple books.


Daniel Oh 是 Red Hat 的首席技術行銷經理。他以靈活、易於使用、具有成本效益、開放和協作的方式提供運行時、框架、快速數據訪問和高性能消息傳遞。他還是 CNCF 大使和 DevOps Institute 大使,宣揚如何設計和開發基於 CNCF 項目的雲原生無服務器微服務並將其部署到多/混合雲原生平台。Daniel 喜歡通過技術研討會、內部分享會、黑客松和實踐實驗室在各個地區與 DevOps 人員分享他的開發者經驗,介紹如何將傳統微服務演變為雲原生、事件驅動和無服務器應用。

James Freeman 是一位經驗豐富的 IT 顧問,在技術行業擁有超過 20 年的經驗。他在實際環境中解決企業問題並使用 Ansible 的第一手經驗超過 5 年,經常將 Ansible 作為新技術介紹給企業和首席技術官。此外,他還編寫和組織定制的 Ansible 研討會和培訓課程,並在國際會議和聚會上就 Ansible 發表演講。

Fabio Alessandro Locati,通常被稱為 Fale,是 Red Hat 的 EMEA 高級解決方案架構師,也是一位公開演講者、作者和開源貢獻者。他的主要專長領域是 Linux、自動化、安全和雲技術。Fale 在 IT 領域擁有超過 15 年的工作經驗,其中許多時間都在為許多公司提供咨詢服務,包括數十家財富 500 強企業。Fale 曾經撰寫過《學習 Ansible 2.7》、《學習 Ansible 2》和《OpenStack 雲安全》,並參與了多本書的審查過程。


  1. Getting Started with Ansible
  2. Understanding the Fundamentals of Ansible
  3. Defining Your Inventory
  4. Playbooks and Roles
  5. Consuming and Creating Modules
  6. Consuming and Creating Plugins
  7. Coding Best Practices
  8. Advanced Ansible Topics
  9. Network Automation with Ansible
  10. Container and Cloud Management
  11. Troubleshooting and Testing Strategies
  12. Getting Started with Ansible Tower


- 開始使用 Ansible
- 理解 Ansible 的基礎知識
- 定義您的清單
- Playbooks 和 Roles
- 使用和創建模組
- 使用和創建插件
- 編碼最佳實踐
- 進階 Ansible 主題
- 使用 Ansible 進行網絡自動化
- 容器和雲端管理
- 故障排除和測試策略
- 開始使用 Ansible Tower