- Ansible Playbook Essentials
- Gourav Shah
- 287字
- 2021-07-16 20:47:47
Plays
A playbook consists of one or more plays, which map groups of hosts to well-defined tasks. The preceding example contains three plays, each to configure one layer in the multitiered web application. Plays also define the order in which tasks are configured. This allows us to orchestrate multitier deployments. For example, configure the load balancers only after starting the web servers, or perform two-phase deployment where the first phase only adds this configurations and the second phase starts the services in the desired order.
YAML – the playbook language
As you may have already noticed, the playbook that we wrote previously resembles more of a text configuration than a code snippet. This is because the creators of Ansible chose to use a simple, human-readable, and familiar YAML format to blueprint the infrastructure. This adds to Ansible's appeal, as users of this tool need not learn any special programming language to get started with. Ansible code is self-explanatory and self-documenting in nature. A quick crash course on YAML should suffice to understand the basic syntax. Here is what you need to know about YAML to get started with your first playbook:
- The first line of a playbook should begin with "--- " (three hyphens) which indicates the beginning of the YAML document.
- Lists in YAML are represented with a hyphen followed by a white space. A playbook contains a list of plays; they are represented with "- ". Each play is an associative array, a dictionary, or a map in terms of key-value pairs.
- Indentations are important. All members of a list should be at the same indentation level.
- Each play can contain key-value pairs separated by ":" to denote hosts, variables, roles, tasks, and so on.
- C及C++程序設(shè)計(第4版)
- Fundamentals of Linux
- 密碼學(xué)原理與Java實現(xiàn)
- 樂學(xué)Web編程:網(wǎng)站制作不神秘
- 樂高機(jī)器人設(shè)計技巧:EV3結(jié)構(gòu)設(shè)計與編程指導(dǎo)
- Animate CC二維動畫設(shè)計與制作(微課版)
- Python零基礎(chǔ)快樂學(xué)習(xí)之旅(K12實戰(zhàn)訓(xùn)練)
- 大模型RAG實戰(zhàn):RAG原理、應(yīng)用與系統(tǒng)構(gòu)建
- Flowable流程引擎實戰(zhàn)
- Spring Boot+MVC實戰(zhàn)指南
- Getting Started with Nano Server
- Android高級開發(fā)實戰(zhàn):UI、NDK與安全
- Learning D3.js 5 Mapping(Second Edition)
- Elasticsearch搜索引擎構(gòu)建入門與實戰(zhàn)
- 算法精解:C語言描述