zoukankan      html  css  js  c++  java
  • 3.ansible-iventory的写法和基本变量

    ansible的配置文件一点要多考虑,有些设定比如ssh端口啊用户啊线程啊都尽量在里面调节好
    iventory的话/etc/ansible/hosts 里面可以使用正则匹配
    ansible从inventory开始就从inventory开始给你们讲起来
    1.hosts文件的基本构成是hosts hosts可以构成组也就是group,group可以构成大组
    --------------------------------------------------------------------------------
    [atlanta]
    host1
    host2
    [raleigh]
    host2
    host3
    [southeast:children]
    atlanta
    raleigh
    --------------------------------------------------------------------------------
    2.hosts可以有自己的变量group可以设定公用的变量
    --------------------------------------------------------------------------------
    [atlanta]
    host1 http_port=80 maxRequestsPerChild=808
    host2 http_port=303 maxRequestsPerChild=909
    [atlanta]
    host1
    host2
    [atlanta:vars]
    ntp_server=ntp.atlanta.example.com
    proxy=proxy.atlanta.example.com
    --------------------------------------------------------------------------------
    3.书写方式有两种列表和yml
    4.inventory支持匹配
    --------------------------------------------------------------------------------
    [webservers]
    www[01:50].example.com
    [databases]
    db-[a:f].example.com
    --------------------------------------------------------------------------------
    5.默认有一个all组包含所有的hosts
    6.还可以以文件的形势记录我们的变量
    --------------------------------------------------------------------------------
    /etc/ansible/group_vars/raleigh # can optionally end in '.yml', '.yaml', or '.json'
    /etc/ansible/group_vars/webservers
    /etc/ansible/host_vars/foosball
    --------------------------------------------------------------------------------
    ---
    ntp_server: acme.example.org
    database_server: storage.example.org
    --------------------------------------------------------------------------------
    7.常见的变量
    --------------------------------------------------------------------------------
    ansible_host
    ansible_port
    ansible_user
    ansible_ssh_pass 通常不使用明文,使用vault(老子不会啊)
    ansible_ssh_private_key_file
    ansible_ssh_executable
    This setting overrides the default behavior to use the system ssh. This can override the ssh_executable setting in ansible.cfg.

    ansible_become
    ansible_become_method
    ansible_become_user
    ansible_become_pass
    ansible_shell_type
    --------------------------------------------------------------------------------
    8.ansible可以和cobbler这也得批量装机工具管理动态inventory很复杂,在云上环境用的也不多。

  • 相关阅读:
    C#中使用事务
    C#中执行数据库存储过程
    构建ASP.net的AJAX开发环境
    C#开发数据库技巧汇总
    索引的作用及其使用
    C#中的多态性
    C#中调用C++的DLL
    不借助其它变量交换两变量值
    ASP.NET页面间传值的9种方式
    TERSUS无代码开发(笔记11)TERSUS框架学习框架基本信息修改
  • 原文地址:https://www.cnblogs.com/leleyao/p/8994663.html
Copyright © 2011-2022 走看看