默认位置

/etc/ansible/hosts

标准

mail.example.com

[webservers]
foo.example.com
bar.example.com [dbservers]
one.example.com
two.example.com
three.example.com
# 2个主机组webservers&dbservers,一个孤儿主机mail.example.com

非默认ssh端口

badwolf.example.com:5309

主机别名&ssh通道

jumper ansible_ssh_port=5555 ansible_ssh_host=192.168.1.50
# jumper是主机别名,连接192.168.1.50:5555端口

配置大量主机

[webservers]
www[01:50].example.com [databases]
db-[a:f].example.com

指派连接用户和类型

[targets]
localhost ansible_connection=local
other1.example.com ansible_connection=ssh ansible_ssh_user=mpdehaan
other2.example.com ansible_connection=ssh ansible_ssh_user=mdehaan

主机变量

[atlanta]
host1 http_port=80 maxRequestsPerChild=808
host2 http_port=303 maxRequestsPerChild=909
# 变量http_port,maxRequestsPerChild用于playbook

主机组变量

[atlanta]
host1
host2 [atlanta:vars]
ntp_server=ntp.atlanta.example.com
proxy=proxy.atlanta.example.com
# 关键字:var,变量ntp_server,proxy

主机组嵌套

[atlanta]
host1
host2 [raleigh]
host2
host3 [southeast:children]
atlanta
raleigh [southeast:vars]
some_server=foo.southeast.example.com
halon_system_timeout=30
self_destruct_countdown=60
escape_pods=2 [usa:children]
southeast
northeast
southwest
northwest
# 关键字:children

在文件存储主机及主机组变量

/etc/ansible/group_vars/raleigh
/etc/ansible/group_vars/webservers
/etc/ansible/host_vars/foosball
# 主机foosball,主机组raleigh & webservers

dynamic inventory

/etc/ansible/hosts是基于文本管理的数据,可以将inventory存储在数据库,使用http api进行交互。编写脚本将inventory数据json化。

http://docs.ansible.com/developing_inventory.html

ansible使用2-inventory & dynamic inventory的更多相关文章

  1. Ansible: hosts文件拆分为inventory和定义inventory全局变量

    前言 随着管理机器的增多,我们在使用Ansible的时候时常会遇到hosts文件过于冗长的问题,极其不便于管理,而将hosts文件拆分为inventory就可解决该问题:另外,hosts中的每个主机条 ...

  2. Amazon.com Seller Distributed Inventory Placement Inventory Placement Service

    Greetings, Thank you for writing to us. I understand that you would like to send inventory to our wa ...

  3. Documentation | AnsibleWorks

    Documentation | AnsibleWorks   Welcome to the Ansible documentation! Ansible is an IT automation too ...

  4. 【Ansible 文档】【译文】动态inventory

    Dynamic Inventory 动态inventory 配置管理系统的用户经常想要保存inventory到不同的软件系统中.Ansible提供了一个基本的基于文本的系统,正如inventory中描 ...

  5. Ansible 小手册系列 五(inventory 主机清单)

    Ansible 可同时操作属于一个组的多台主机,组和主机之间的关系通过 inventory 文件配置. 默认的文件路径为 /etc/ansible/hosts 主机清单示例 mail.example. ...

  6. ansible 的组件inventory

    P44 Ansible 的默认的inventory的是一个静态的ini格式的文件/etc/ansible/hosts. 我们还可以通过ansible_hosts环境变脸指定或者运行ansible和an ...

  7. Ansible 之动态Inventory文件(二)

    上篇主要讲解了Ansible 的安装和配置,并且根据不同的业务场景将服务器的信息存放在Ansible的Inventory中,其实存放这样的数据每次更新都需要我们自动的添加和删除,这样对于我们维护起来很 ...

  8. inventory file 与hosts patterns (ansible 机器清单 与 主机匹配模式)

    Ansible配置: ansible有两个核心配置文件: ansible.cfg 配置文件和Inventory配置文件 Ansible.cfg配置文件 Inventory机器列表配置 这里介绍Inve ...

  9. Ansible的Inventory管理

    Ansible将可管理的服务器集合成为Inventory,Inventory的管理便是服务器的管理. hosts文件的位置: /etc/ansible/hosts 在命令行通过-i参数指定 通过/et ...

随机推荐

  1. Maven入门(二)pom.xml和核心概念

    一.pom.xml文件说明 1.pom意思就是project object model. 2.pom.xml包含了项目构建的信息,包括项目的信息.项目的依赖等. 3.pom.xml文件是可以继承的,大 ...

  2. 远程私有库的创建 pod 组件化

    参考:   http://www.cnblogs.com/hs-funky/p/6780203.html http://www.jianshu.com/p/4b63dfbd8be7 http://ww ...

  3. git push fatal: HttpRequestException encountered

    原因: github禁用了TLS1.0/1.1协议 截至2018年2月22日,GitHub禁用了对弱加密的支持,这意味着许多用户会突然发现自己无法使用Git for Windows进行身份验证(影响版 ...

  4. 解决SharePoint密码更新后,创建Web Application 失败

    问题在sharepoint central administration中通过Configuration Wizards来创建一个web application,出现如下错误: The passwor ...

  5. HDU - 1042-N!(Java)

    Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N! Input One N in one line, process to ...

  6. day20 模块 collections time sys os

    1.模块 1. 模块的定义:我们把装有特定功能的代码进行归类的结果.我们目前写的所有py文件都是模块 2. 引入模块的方式: 1.import 模块名 2.from xxx import 模块名 2. ...

  7. python自动化day2-列表、字典、集合

    一.数据类型 1.什么是数据? x=10,10是我们要存储的数据 2.为何数据要分不同的类型 数据是用来表示状态的,不同的状态就应该用不同的类型的数据去表示 3 数据类型 数字(整形,长整形,浮点型, ...

  8. 如何查看mysql执行的所有SQL

    在程序调试中,有时需要看到最终在DB执行的SQL文,而默认mysql此功能是关闭的,开启的方法如下: set global general_log='ON'; 然后用如下命令查看log文件所在路径即可 ...

  9. java——多线程的实现方式、三种办法解决线程赛跑、多线程数据同步(synchronized)、死锁

    多线程的实现方式:demo1.demo2 demo1:继承Thread类,重写run()方法 package thread_test; public class ThreadDemo1 extends ...

  10. mobiscroll 日期问题

    做的一个项目中用到了mobiscroll日期控件,设置距离当前日期往前推一个月的时间出现如下图问题 弹出窗默认的年份不对,后来查找原因是初始化属性配置有问题,应该将设置为dateFormat:'yy- ...