【Ansible 文档】提示、推荐、注意事项
1. 查看 详细 信息
如果你想要查看成功模块和不成功的详细输出,使用
--verbose标识
2. 检查 playbook 的语法
使用 ansible-playbook 的 --syntax-check 标识。通过parser来运行playbook,确保Include files、roles等没有语法错误。
3. 在运行playbook之前,查看playbook影响的哪些主机
ansible-playbook playbook.yml --list-hosts
4. 运行playbook的方式
ansible-playbook playbook.yml -f 10
5. 特权上升的方式更改为 become
6. 指定主机顺序执行playbook
inventory:
The default. The order is ‘as provided’ by the inventory
reverse_inventory:
As the name implies, this reverses the order ‘as provided’ by the inventory
sorted:
Hosts are alphabetically sorted by name
reverse_sorted:
Hosts are sorted by name in reverse alphabetical order
shuffle:
Hosts are randomly ordered each run
7. 任务可以使用历史遗留格式: action: module options 来声明,但是推荐使用 module: options 格式
8. 大多数模块使用 “key=value” 来指定参数,例如服务模块。但是 “command and shell ” 模块使用的是参数列表,不使用“key=value”格式。
tasks:
- name: enable selinux
command: /sbin/setenforce 1 command和shell模块关心返回值,因此如果你有的命令退出码不为0,你可能希望这么做:tasks:
- name: run this command and ignore the result
shell: /usr/bin/somecommand || /bin/truetasks:
- name: run this command and ignore the result
shell: /usr/bin/somecommand
ignore_errors: True
9. 如果一行太长了,在下一行使用一个空格缩进表示命令的继续
tasks:
- name: Copy ansible inventory file to client
copy: src=/etc/ansible/hosts dest=/etc/ansible/hosts
owner=root group=root mode=
10. playbook 可能有四个包含任务的部分
pre_tasks, tasks, post_tasks, roles
11. handlers 需要注意的
handler执行的时机:
- handlers notified within
pre_tasks,tasks, andpost_taskssections are automatically flushed in the end of section where they were notified;- handlers notified within
rolessection are automatically flushed in the end oftaskssection, but before anytaskshandlers. 表明 roles 会跟tasks section合并此外,通过meta,可以提前执行handler:
tasks:
- shell: some tasks go here
- meta: flush_handlers
- shell: some other tasks可以指定监听的主题
handlers:
- name: restart memcached
service: name=memcached state=restarted
listen: "restart web services"
- name: restart apache
service: name=apache state=restarted
listen: "restart web services" tasks:
- name: restart everything
command: echo "this task will restart the web services"
notify: "restart web services"
【Ansible 文档】提示、推荐、注意事项的更多相关文章
- Atitit 项目文档规范化与必备文档与推荐文档列表
Atitit 项目文档规范化与必备文档与推荐文档列表 ===========比较重要的必备文档========== 项目组名单通讯录( 包括项目组,客户沟通人等 需求文档 原型ui文档 开发计划表 项 ...
- WebBrowser打开Word文档的一些注意事项
WebBrowser打开Word文档的一些注意事项 分类: C#word2010-03-31 21:26 5640人阅读 评论(3) 收藏 举报 webbrowser文档browser工具object ...
- 【Ansible 文档】【译文】配置文件
这里说明一下配置文件的内容,原文地址:http://docs.ansible.com/ansible/latest/intro_configuration.html 这个与[Ansible 文档]配置 ...
- 【Ansible 文档】【译文】入门教程
http://docs.ansible.com/ansible/latest/intro_getting_started.html Foreword 前言 到这里,你应该已经安装了Ansible,是时 ...
- 【Ansible 文档】【译文】Ad-Hoc 命令介绍
Introduction To Ad-Hoc Commands Ad-Hoc命令介绍 下面的例子展示了如何使用 /usr/bin/ansible 来运行ad hoc任务. 什么是ad hoc命令? 一 ...
- SharePoint 上传文档提示别人迁出
前言 我们在使用SharePoint文档库的时候,经常会遇到文档被别人迁出,自己无法修改的情况.这时候,我们最好的办法就是找到那个迁出的人,怼他!如果,他已经离职了,我们无法找到,那么,就请继续往瞎看 ...
- 【Ansible 文档】【译文】Playbooks 变量
Variables 变量 自动化的存在使得重复的做事情变得很容易,但是我们的系统不可能完全一样. 在某些系统中,你可能想要设置一些与其他系统不一样的行为和配置. 同样地,远程系统的行为和状态也可以影响 ...
- 【Ansible 文档】【译文】网络支持
Networking Support 网络支持 Working with Networking Devices 使用网络设备 自从Ansible 2.1开始,你现在可以使用成熟模型 - 编写 play ...
- 【Ansible 文档】【译文】Windows 支持
see also:List of Windows Modules Windows Support Windows 支持 Windows: How Does It Work Windows:如何工作 正 ...
- 【Ansible 文档】【译文】常见问题
http://docs.ansible.com/ansible/latest/faq.html 如何为一个task或者整个Playbook设置PATH或者任意其他环境变量? 通过environment ...
随机推荐
- Oracle添加定时任务
1.创建存储过程 注:执行语句后,如果需要请添加commit 2.添加定时job,执行存储过程 declare job_delete number; begin dbms_job.submit( jo ...
- element split 将多个单号分隔
const condeid = this.formData.WayBillCode; var item = ""; const codes = condeid.split(&quo ...
- oracle用户权限
权限: create session create table unlimited tablespace connect resource dba 例: #sqlplus /nolog SQL> ...
- IdentityServer4关于多客户端和API的最佳实践【含多类型客户端和API资源,以及客户端分组实践】【下】
经过前两篇文章你已经知道了关于服务器搭建和客户端接入相关的基本资料,本文主要讲述整个授权系统所服务的对象,以ProtectApi资源为演示 目标: 1)实现多资源服务器针对请求的token校验,接入I ...
- .net dll反编译出现的问题,以及部分修复的方法
常用.net反编译工具 1.Reflector 9.0.2 2.JustDecompile2015.3.928.0j 3.ILSpy 4.CS资源文件批量转换工具 base.AutoScaleMode ...
- MVC架构介绍-事件机制
实例产品基于asp.net mvc 5.0框架,源码下载地址:http://www.jinhusns.com/Products/Download 在.net框架中,事件是将事件发送者(触发事件的对象) ...
- 在EF中执行SQL语句(转载)
在EF中执行SQL语句 你可能要问,我用EF不就为了避免写SQL吗?如果要写SQL我不如直接用ADO.NET得了.话虽然这么说没错,可有些时候使用EF操作数据还是有一些不方便,例如让你根据条件删除 ...
- 轻量级ORM——PetaPoco
近乎产品的数据访问是基于轻量级ORM——PetaPoco,哪怕是最新的5.2版本也是基于PetaPoco. 产品源码下载地址:http://www.jinhusns.com/Products/Down ...
- 【Quartz】1、Quartz使用说明
简介 Quartz 是个开源的作业调度框架,为在 Java 应用程序中进行作业调度提供了简单却强大的机制.Quartz 允许开发人员根据时间间隔(或天)来调度作业.它实现了作业和触发器的多对多关系,还 ...
- vue常用笔记
vue源码解析(勾三股四):http://jiongks.name/blog/vue-code-review/ 0.npm: https://www.npmjs.com/ 1. package.jso ...