码迷,mamicode.com
首页 > 其他好文 > 详细

ansible module: group_by

时间:2016-07-13 12:01:12      阅读:114      评论:0      收藏:0      [点我收藏+]

标签:ansible module之group_by

ansible中的group_by模块借助Facts可以用来创建匹配特定标准的主机的动态组。

- hosts: all

 tasks:

 - name: Create a group of all hosts by operating system

  group_by: key={{ansible_distribution}}-{{ansible_distribution_version}}

#组名中间不要留空格

- hosts: CentOS-6.2    #CentOS-6.2即引用上面group_by创建的value

 tasks:

 - name: ping all CentOS 6.2 hosts

  ping:


- hosts: CentOS-6.3

 tasks:

 - name: ping all CentOS 6.3 hosts

  ping:

附:

Facts are information derived from speaking with your remote systems.

#ansible hostname -m setup

本文出自 “11524698” 博客,请务必保留此出处http://11534698.blog.51cto.com/11524698/1825989

ansible module: group_by

标签:ansible module之group_by

原文地址:http://11534698.blog.51cto.com/11524698/1825989

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!