ansible-主机清单的配置
admin
2023-03-07 01:41:56
0

1. ansible主机清单的配置

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

[root@test-1 ~]# cat /etc/ansible/hosts
    # This is the default ansible 'hosts' file.
    #
    # It should live in /etc/ansible/hosts
    #
    #   - Comments begin with the '#' character
    #   - Blank lines are ignored
    #   - Groups of hosts are delimited by [header] elements
    #   - You can enter hostnames or ip addresses
    #   - A hostname/ip can be a member of multiple groups
    
    # Ex 1: Ungrouped hosts, specify before any group headers.
    [webservers]
    192.168.200.131  ansible_host_user=root ansible_host_pass='123456'
    192.168.200.132
    192.168.200.133
    192.168.200.134
    192.168.200.135
    192.168.200.136
    
    ## green.example.com
    ## blue.example.com
    ## 192.168.100.1
    ## 192.168.100.10
    
    # Ex 2: A collection of hosts belonging to the 'webservers' group
    
    ## [webservers]
    ## alpha.example.org
    ## beta.example.org
    ## 192.168.1.100
    ## 192.168.1.110
    
    # If you have multiple hosts following a pattern you can specify
    # them like this:
    
    ## www[001:006].example.com
    
    # Ex 3: A collection of database servers in the 'dbservers' group
    
    ## [dbservers]
    ## 
    ## db01.intranet.mydomain.net
    ## db02.intranet.mydomain.net
    ## 10.25.1.56
    ## 10.25.1.57
    
    # Here's another example of host ranges, this time there are no
    # leading 0s:
    
    ## db-[99:101]-node.example.com

2. ansible定义方式:

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

test_2.xxxx.cn2         
192.168.200.132

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

[webservers]
        192.168.200.131  ansible_host_user=root ansible_host_pass='123456'
        192.168.200.132
        192.168.200.133
        192.168.200.134
        192.168.200.135
        192.168.200.136

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

格式:【主机名】       【指定用户】    【主机地址】   【主机密码】
[webservers]
192.168.200.131    ansible_host_user=root    test-1=192.168.200.131      ansible_host_pass='123456'


相关内容

热门资讯

今日重磅消息“官方正版炸金花.... 家人们!今天小编来为大家解答官方正版炸金花透视挂怎么安装这个问题咨询软件客服徽4282891的挂在哪...
玩家攻略科普“同城跑胡子.真的... 玩家攻略科普“同城跑胡子.真的有挂吗?”原来真的有挂您好,同城跑胡子这个游戏其实有挂的,确实是有挂的...
【第一资讯】“德娴麻将.怎么装... 有 亲,根据资深记者爆料德娴麻将是可以开挂的,确实有挂(咨询软件无需打开...
终于懂了“决战卡五星.是不是有... 终于懂了“决战卡五星.是不是有挂?”原来真的有挂您好,决战卡五星这个游戏其实有挂的,确实是有挂的,需...
终于了解“情怀麻将.有没有挂?... 有 亲,根据资深记者爆料情怀麻将是可以开挂的,确实有挂(咨询软件无需打开...
最新引进“授权大厅炸/金/花.... 最新引进“授权大厅炸/金/花.可以开挂吗?”详细开挂教程您好,授权大厅炸/金/花这个游戏其实有挂的,...
终于了解“甘孜娱乐中心.究竟有... 网上科普关于“甘孜娱乐中心有没有挂”话题很是火热,小编也是针对甘孜娱乐中心作*弊开挂的方法以及开挂对...
玩家攻略科普“云南山水麻将.怎... 网上科普关于“云南山水麻将有没有挂”话题很是火热,小编也是针对云南山水麻将作*弊开挂的方法以及开挂对...
重磅消息“人人乐麻将.真的有挂... 网上科普关于“人人乐麻将有没有挂”话题很是火热,小编也是针对人人乐麻将作*弊开挂的方法以及开挂对应的...
今日重大发现“乐乐四川麻将.有... 家人们!今天小编来为大家解答乐乐四川麻将透视挂怎么安装这个问题咨询软件客服徽9784099的挂在哪里...