如果你有一个大的剧本,你可以在不运行整个剧本的情况下运行一个特定的部分。

 由于这个原因,两个游戏和任务都支持一个“标记:”属性。您只能根据命令行中的标记(标记或- skip- tags)对任务进行筛选。添加“标记”:在一个游戏的任何部分(包括角色)中添加这些标记到包含的任务中。
 

例子:Example:

tasks:

    - yum: name={{ item }} state=installed
with_items:
- httpd
- memcached
tags:
- packages - template: src=templates/src.j2 dest=/etc/foo.conf
tags:
- configuration

如果您想要运行“配置”和“包”部分的很长的脚本,您可以这样做:

ansible-playbook example.yml --tags "configuration,packages"

另一方面,如果你想在没有特定任务的情况下运行剧本,你可以这样做:

ansible-playbook example.yml --skip-tags "notification"

Tag Reuse

您可以在同一个文件或包含文件中对多个任务应用相同的标记名。这将用该标记运行所有任务。Example:

---
# file: roles/common/tasks/main.yml - name: be sure ntp is installed
yum: name=ntp state=installed
tags: ntp - name: be sure ntp is configured
template: src=ntp.conf.j2 dest=/etc/ntp.conf
notify:
- restart ntpd
tags: ntp - name: be sure ntpd is running and enabled
service: name=ntpd state=started enabled=yes
tags: ntp

Tag Inheritance

You can apply tags to more than tasks, but they ONLY affect the tasks themselves. Applying tags anywhere else is just a convenience so you don’t have to write it on every task:

- hosts: all
tags:
- bar
tasks:
... - hosts: all
tags: ['foo']
tasks:
...

You may also apply tags to roles:

roles:
- { role: webserver, port: 5000, tags: [ 'web', 'foo' ] }

And import/include statements:

- import_tasks: foo.yml
tags: [web,foo]

or:

- include_tasks: foo.yml
tags: [web,foo]

All of these apply the specified tags to EACH task inside the play, included file, or role, so that these tasks can be selectively run when the playbook is invoked with the corresponding tags.

Tags are inherited down the dependency chain. In order for tags to be applied to a role and all its dependencies, the tag should be applied to the role, not to all the tasks within a role.

You can see which tags are applied to tasks by running ansible-playbook with the --list-tasks option. You can display all tags using the --list-tags option.

Special Tags

有一个特殊的always标记,它将始终运行一个任务,除非特别跳过(- -skip- tags总是)

Example:

tasks:

    - debug: msg="Always runs"
tags:
- always - debug: msg="runs when you use tag1"
tags:
- tag1

ansibel---tag模块的更多相关文章

  1. django tag

    官方文档:https://docs.djangoproject.com/en/1.10/howto/custom-template-tags/#simple-tags stackoverflow de ...

  2. 如何实现phpcms v9_4X版本tag的伪静态?

    这两个月来写的文章越来越少了,不是懒,因为太忙了--为客户赶做网站.因为客户指定要使用phpcms v9,还要求使用phpcms v9_42版本实现tag伪静态,在接手的时候phpcms v9_42是 ...

  3. 第四十一节,xml处理模块

    XML是实现不同语言或程序之间进行数据交换的协议,XML文件格式如下 读xml文件 <data> <country name="Liechtenstein"> ...

  4. Supesite 参数说明

    supesite有人看到的是强大的功能,我看到的是坑爷的一些用法,第一次看到block,我晕了.对于参数一头雾水,下面收集了一些,备用吧. supesite标签调用参数详解 参数: blocktype ...

  5. django的templatetags

    创建tag方式,首先在需要使用tag的app下创建一个templatetags的python包, 然后在包里创建一个tag模块,例如hellotag.py from django import tem ...

  6. [js]js设计模式-单例模式

    单例模式 不同模块之间需要同时开发, // 单例模式: 把描述同一个事物的属性和方法放在同一个内存空间下. // 优点: 分组,防止冲突 // p1 p2也叫做命名空间(模块开发) var p1 = ...

  7. Python开发一个简单的BBS论坛

    项目:开发一个简单的BBS论坛 需求: 整体参考“抽屉新热榜” + “虎嗅网” 实现不同论坛版块 帖子列表展示 帖子评论数.点赞数展示 在线用户展示 允许登录用户发贴.评论.点赞 允许上传文件 帖子可 ...

  8. Ansible运维自动化工具

    1>Ansible 1>ansible简介 ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet.cfengine.chef.func.fabri ...

  9. 关于Android的HAL的一些理解

    之前一直在学习基于Linux内核的一些字符型驱动的编程,对Linux内核驱动也算有了一些基本的了解吧,后来也做过一些基于Linux内核的驱动开发,像基于Android的CC1101高频模块的驱动开发, ...

  10. Template--模板

    模板引擎的支持 配置 模板引擎配置为TEMPLATES设置.这是一个配置列表,每个引擎一个,默认值为空.这是settings.py生成的,通过startproject命令定义了一个更有用的值: TEM ...

随机推荐

  1. 四十三 Python分布式爬虫打造搜索引擎Scrapy精讲—elasticsearch(搜索引擎)的mapping映射管理

    1.映射(mapping)介绍 映射:创建索引的时候,可以预先定义字段的类型以及相关属性elasticsearch会根据json源数据的基础类型猜测你想要的字段映射,将输入的数据转换成可搜索的索引项, ...

  2. linux的find命令详解

    find命令是用来在给定的目录下查找符合给定条件的文件 find [OPTIONS] [查找起始路径] [查找条件] [处理动作]   一.OPTIONS参数 -P.-L.-H:控制软连接的对待方式, ...

  3. pg_test_fsync使用记录

    pg_test_fsync pg_test_fsync旨在让您合理地了解特定系统上最快的wal_sync_method,以及在发生识别的I / O问题时提供诊断信息. 但是,pg_test_fsync ...

  4. css选择器的特殊性值

    今天从前端那拿来写好的页面,就开始动工,首先,照旧处理导航栏高亮的问题, 说到处理高亮的问题,不同的人会有不同的方法,比如: //类名为nav的元素下的第n个a元素 .nav a:nth-of-typ ...

  5. android事件传递机制以及onInterceptTouchEvent()和onTouchEvent()总结

    老实说,这两个小东东实在是太麻烦了,很不好懂,我自己那api文档都头晕,在网上找到很多资料,才知道是怎么回事,这里总结一下,记住这个原则就会很清楚了: 1.onInterceptTouchEvent( ...

  6. rem第一天

    Rem为单位 CSS3的出现,他同时引进了一些新的单位,包括我们今天所说的rem.在W3C官网上是这样描述rem的——“font size of the root element” .下面我们就一起来 ...

  7. 关于Sublime Text不能在打开方式中显示并且不能被设置成默认打开方式的问题

    解决方法: 1. Windows 输入 regedit 后 回车 打开注册表 2.找到 "HKEY_CLASSES_ROOT\Applications\sublime_text.exe\sh ...

  8. asp.net core microservices 架构之Task 事务一致性 事件源 详解

    一 aspnetcore之task的任务状态-CancellationToken 我有一篇文章讲解了asp.net的线程方面的知识.我们知道.net的针对于多线程的一个亮点就是Task,net clr ...

  9. WCF *.svc 自定义地址路由映射

    一般在创建WCF服务时会用Serivce.svc文件访问,地址如:http://localhost/applicationname/Serivce.svc/Name 现在用路由映射成:http://l ...

  10. niosii dma实验中的一点感想

    1,使用nios给出的驱动函数的顺序一般为1,清中断2,写控制寄存器,3,写参数寄存器4,中断注册,5,开始工作.因为开始工作控制位在控制寄存器中,所以会想到到最后一块写,省事,但是在dma试验中发现 ...