Working With Playbooks
Working With Playbooks
使用playbook
Playbooks are Ansible’s configuration, deployment, and orchestration language. They can describe a policy you want your remote systems to enforce, or a set of steps in a general IT process.
Playbooks是Ansible的配置,部署和编排语言。他们可以描述您希望远程系统实施的策略,或者描述一般IT流程中的一系列步骤。
If Ansible modules are the tools in your workshop, playbooks are your instruction manuals, and your inventory of hosts are your raw material.
如果Ansible模块是您工作场景中的工具,那么Playbook就是您的使用说明书,而您的主机库存就是您的原材料。
At a basic level, playbooks can be used to manage configurations of and deployments to remote machines. At a more advanced level, they can sequence multi-tier rollouts involving rolling updates, and can delegate actions to other hosts, interacting with monitoring servers and load balancers along the way.
在基础级别,可以使用playbooks来管理远程计算机的配置和部署。在更高级别,他们可以对涉及滚动更新的多层部署进行排序,并可以将操作委派给其他主机,并在此过程中与监控服务器和负载平衡器进行交互。
While there’s a lot of information here, there’s no need to learn everything at once. You can start small and pick up more features over time as you need them.
虽然这里有很多信息,但没有必要一次学习所有内容。您可以从小处着手,随时根据需要选择更多功能。
Playbooks are designed to be human-readable and are developed in a basic text language. There are multiple ways to organize playbooks and the files they include, and we’ll offer up some suggestions on that and making the most out of Ansible.
Playbooks设计为人类可读的,并以基本文本语言开发。有多种方法来组织Playbooks及其中包含的文件,我们将提供一些建议使你可以充分利用Ansible。
You should look at Example Playbooks while reading along with the playbook documentation. These illustrate best practices as well as how to put many of the various concepts together.
您应该在阅读Playbook文档的同时查看示例Playbooks。这些说明了最佳实践以及如何将许多不同的概念放在一起。
- Intro to Playbooks Playbooks简介
- About Playbooks 关于Playbooks
- Playbook Language Example 语言范例
- Basics 基本
- Action Shorthand 动作速记
- Handlers: Running Operations On Change 处理程序:在变更时运行操作
- Executing A Playbook 执行一个剧本
- Ansible-Pull 拉?
- Tips and Tricks 技巧和窍门
- Including and Importing 包括和导入
- Roles 角色
- Dynamic vs. Static 动态和静态
- Differences Between Static and Dynamic 静态和动态之间的差异
- Tradeoffs and Pitfalls Between Includes and Imports 包含和导入之间的权衡和陷阱
- 创建可重用的手册
- What Makes A Valid Variable Name 有效的变量名称
- Variables Defined in Inventory 库存中定义的变量
- Variables Defined in a Playbook 在剧本中定义的变量
- Variables defined from included files and roles 包含的文件和角色中定义的变量
- Using Variables: About Jinja2 使用变量,关于jinja2
- Jinja2 Filters 过滤器
- Hey Wait, A YAML Gotcha 得到一个YAML
- Information discovered from systems: Facts 从系统发现的信息:Facts事实
- Turning Off Facts 关闭Facts
- Local Facts (Facts.d) 本地Facts
- Ansible version 版本
- Fact Caching Facts缓存
- Registered Variables 注册变量
- Accessing Complex Variable Data 访问复杂的可变数据
- Magic Variables, and How To Access Information About Other Hosts 魔法变量,如何访问有关其他主机的信息
- Variable File Separation 可变文件分离
- Passing Variables On The Command Line 在命令行上传参
- Variable Precedence: Where Should I Put A Variable? 变量优先级:我应该在哪里放置变量?
- Variable Scopes 可变范围
- Variable Examples 变量范例
- Advanced Syntax 高级语法
- Templating (Jinja2) 模板
- Filters 过滤器
- Tests 测试
- Lookups 查找
- Python Version and Templating Python版本和模板
- Conditionals 条件语句
- The When Statement 实践陈述
- Loops and Conditionals 循环和条件
- Loading in Custom Facts 加载自定义事实
- Applying ‘when’ to roles, imports, and includes 将when用于角色导入和包含
- Conditional Imports 有条件的导入
- Selecting Files And Templates Based On Variables 基于变量选择文件和模板
- Register Variables 注册变量
- Commonly Used Facts 常用事实
- Loops 循环
- Standard Loops 标准
- Complex loops 复杂
- Using lookup vs query with loop 使用查找与查询循环
- Do-Until Loops do-until循环
- Using register with a loop 使用带循环的寄存器
- Looping over the inventory 循环库存
- Loop Control 循环控制
- Migrating from with_X to loop 从with_x迁移到循环
- 变量
- Error Handling 错误处理
- 块
- Understanding Privilege Escalation 了解权限提升
- Asynchronous Actions and Polling 异步操作和轮询
- Check Mode (“Dry Run”) 检查模式
- Playbook Debugger 剧本调试
- Delegation, Rolling Updates, and Local Actions 委派,滚动更新和本地操作
- Setting the Environment (and Working With Proxies) 设置环境和代理
- Working With Language-Specific Version Managers 使用特定语言的版本管理器
- Error Handling In Playbooks 处理剧本错误
- Advanced Syntax 高级语法
- Working With Plugins 插件
- Prompts 提示
- Tags 标签
- Using Vault in playbooks 使用vault
- Start and Step 开始和步骤
- Playbook Keywords 关键词
- Lookups 查找
- Module defaults 模块默认值
- 高级剧本功能
- Strategy Plugins 策略插件
- 策略
- 最佳实践
- Content Organization 内容组织
- Staging vs Production 分期和生产
- Rolling Updates 滚动更新
- Always Mention The State 总是提到国家
- Group By Roles 按角色分组
- Operating System and Distribution Variance 操作系统和分布差异
- Bundling Ansible Modules With Playbooks 将ansible模块和剧本捆绑在一起
- Whitespace and Comments 空白区和评论
- Always Name Tasks 始终命名任务
- Keep It Simple 把事情简单化
- Version Control 版本控制
- Variables and Vaults 变量和保险柜
https://docs.ansible.com/ansible/latest/user_guide/playbooks.html