• 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很复杂,在云上环境用的也不多。

  • 相关阅读:
    linux下运行、停止jar包
    .net开发CAD2008无法调试的解决方法
    【转】C#获取当前程序运行路径的方法集合
    如何在arcmap中调试addin或者插件
    【转】WriteMessage的信息在AutoCAD中命令行中实时显示
    ArcGIS10的附件功能
    CAD调试时抛出“正试图在 os 加载程序锁内执行托管代码。不要尝试在 DllMain 或映像初始化函数内运行托管代码”异常的解决方法
    [转]Tesseract 3.02中文字库训练
    Truncated incorrect DOUBLE value
    tomcat无故停止
  • 原文地址:https://www.cnblogs.com/leleyao/p/8994663.html
Copyright © 2020-2023  润新知