官术网_书友最值得收藏!

Playbooks and Roles

So far in this book, we have worked mostly with ad hoc Ansible commands for simplicity and to help you to understand the fundamentals. However, the lifeblood of Ansible is most certainly the playbook, which is a logical organization of tasks (think ad hoc commands) in a structure that creates a useful outcome. This might be to deploy a web server on a newly built virtual machine, or it might be to apply a security policy. It might even handle the whole build process for a virtual machine! The possibilities are endless. Ansible playbooks, as we have already covered, are designed to be simple to write and easy to read—they are intended to be self-documenting and, as such, will form a valuable part of your IT processes.

In this chapter, we will explore playbooks in greater depth, from the basics of their creation to more advanced concepts such as running tasks in loops and blocks, performing conditional logic, and—perhaps one of the most important concepts for playbook organization and code re-use—Ansible roles. We will cover roles in more detail later, but please know that this is something you will want to use as much as possible when creating manageable playbook code.

Specifically, in this chapter, we will cover the following topics:

  • Understanding the playbook framework
  • Understanding rolesthe playbook organizer
  • Using conditions in your code
  • Repeating tasks with loops
  • Grouping tasks using blocks
  • Configuring play execution via strategies
  • Using ansible-pull
主站蜘蛛池模板: 邛崃市| 团风县| 谷城县| 临沂市| 英德市| 庆安县| 青州市| 老河口市| 崇州市| 汉寿县| 即墨市| 辽阳市| 武威市| 布拖县| 驻马店市| 民县| 五台县| 宣恩县| 台东市| 绥宁县| 始兴县| 建湖县| 和静县| 岳阳市| 杭锦后旗| 喜德县| 彭阳县| 北票市| 睢宁县| 梅州市| 昭觉县| 丁青县| 阿鲁科尔沁旗| 辽中县| 获嘉县| 西乌珠穆沁旗| 上杭县| 新田县| 安阳市| 内黄县| 大田县|