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

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
主站蜘蛛池模板: 西乌珠穆沁旗| 射洪县| 桐乡市| 黄龙县| 大埔县| 仪征市| 蒙阴县| 肥乡县| 天等县| 育儿| 安仁县| 九龙城区| 乐安县| 苍山县| 嘉峪关市| 深圳市| 高要市| 普定县| 公主岭市| 苍梧县| 阿克苏市| 平乐县| 平远县| 自治县| 托克逊县| 商南县| 百色市| 宜阳县| 峡江县| 逊克县| 库伦旗| 长阳| 镇巴县| 菏泽市| 平遥县| 江华| 肃宁县| 贵德县| 天峨县| 铁力市| 比如县|