zoukankan      html  css  js  c++  java
  • ansible-主机清单的配置

    1. ansible主机清单的配置

        以下是ansible安装完成后的源文件

     1 [root@test-1 ~]# cat /etc/ansible/hosts
     2     # This is the default ansible 'hosts' file.
     3     #
     4     # It should live in /etc/ansible/hosts
     5     #
     6     #   - Comments begin with the '#' character
     7     #   - Blank lines are ignored
     8     #   - Groups of hosts are delimited by [header] elements
     9     #   - You can enter hostnames or ip addresses
    10     #   - A hostname/ip can be a member of multiple groups
    11     
    12     # Ex 1: Ungrouped hosts, specify before any group headers.
    13     [webservers]
    14     192.168.200.131  ansible_ssh_user=root ansible_ssh_pass='123456'
    15     192.168.200.132
    16     192.168.200.133
    17     192.168.200.134
    18     192.168.200.135
    19     192.168.200.136
    20     
    21     ## green.example.com
    22     ## blue.example.com
    23     ## 192.168.100.1
    24     ## 192.168.100.10
    25     
    26     # Ex 2: A collection of hosts belonging to the 'webservers' group
    27     
    28     ## [webservers]
    29     ## alpha.example.org
    30     ## beta.example.org
    31     ## 192.168.1.100
    32     ## 192.168.1.110
    33     
    34     # If you have multiple hosts following a pattern you can specify
    35     # them like this:
    36     
    37     ## www[001:006].example.com
    38     
    39     # Ex 3: A collection of database servers in the 'dbservers' group
    40     
    41     ## [dbservers]
    42     ## 
    43     ## db01.intranet.mydomain.net
    44     ## db02.intranet.mydomain.net
    45     ## 10.25.1.56
    46     ## 10.25.1.57
    47     
    48     # Here's another example of host ranges, this time there are no
    49     # leading 0s:
    50     
    51     ## db-[99:101]-node.example.com

    2. ansible定义方式:

     1) 直接指明主机地址或主机名

    1         test_2.xxxx.cn
    2         192.168.200.132

        2) 定义一个主机组 [  组名  ]  把地址或主机名加进去

    1         [webservers]
    2         192.168.200.131  ansible_ssh_user=root ansible_ssh_pass=123456
    3         192.168.200.132
    4         192.168.200.133
    5         192.168.200.134
    6         192.168.200.135
    7         192.168.200.136

        3) 如果你没有使用公钥,想要使用密码,你也可以这样写(适用于第一次登陆控制)

    1         格式:    【主机名】       【指定用户】              【主机地址】         【主机密码】
    2         [webservers]
    3                 192.168.200.131    ansible_ssh_user=root    test-1=192.168.200.131      ansible_ssh_pass=123456
  • 相关阅读:
    jQuery琐碎
    jQuery文档加载事件
    微信,禁止分享页面
    级联下拉列表
    struts2 result随笔
    C++知识点(四)类与对象,结构体、联合体、枚举类
    C++知识点(三)函数
    剑指offer-二叉树
    LeetCode:Remove Element
    LeetCode:Remove Duplicates from Sorted Array
  • 原文地址:https://www.cnblogs.com/scajy/p/11389496.html
Copyright © 2011-2022 走看看