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

  • 相关阅读:
    ASP.NET MVC + EF 利用存储过程读取大数据,1亿数据测试很OK
    ASP.NET MVC+EasyUI+Entity FrameWork 整合开发
    ASP.NET MVC局部验证及相关问题
    asp.net mvc常用的数据注解和验证以及entity framework数据映射
    Entity Framework 一次加载许多个 Fluent API 映射
    Entity Framework Code First 常用方法集成
    ASP.NET MVC 应用程序的安全性,看一眼你就会了
    Entity Framework SqlFunctions 教你如何在EF调用sqlserver方法的函数存根
    ASP.NET MVC 及 Areas 简单控制路由
    ASP.NET MVC 表单的几种提交方式
  • 原文地址:https://www.cnblogs.com/leleyao/p/8994663.html
Copyright © 2011-2022 走看看