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'


相关内容

热门资讯

特朗普:俄乌将实行为期3天的停... △特朗普(资料图)当地时间5月8日,美国总统特朗普在其社交媒体“真实社交”发文表示,在俄罗斯与乌克兰...
《星球大战》男主角发“特朗普躺... 据英国广播公司(BBC)5月8日报道,《星球大战》演员马克·哈米尔在社交平台发布一张AI生成的图片,...
产业园区招商政府委托媒介选型指... 导语:产业园区招商需兼顾资源整合效率与项目落地精准度,尤其在互联网招商模式下,平台流量、技术团队与资...
“无废城市”建设 | 为新材料... 4月26日,在常山生态工业园区的利安隆科润(浙江)新材料有限公司实验室里,企业品控部负责人、科技副总...
既能防晒又能听歌,还自带AI小... 春夏出门运动,你是不是也常常纠结:到底是戴帽子防晒,还是戴耳机听歌?两个都戴上,耳朵被压得生疼,帽檐...
伊朗警告过往船只远离美军舰艇:... 据美国有线电视新闻网(CNN)5月8日报道,一段录音显示,美伊在霍尔木兹海峡发生冲突后,伊朗革命卫队...
事关汉坦病毒,大西洋小岛牵动多... 5月6日,荷兰“洪迪厄斯”号邮轮停留在佛得角首都普拉亚的近海海域。新华社发(埃尔顿·蒙泰罗摄)发生汉...
上海尼为取得供栈收栈机专利,实... 国家知识产权局信息显示,上海尼为智能科技有限公司取得一项名为“一种供栈收栈机”的专利,授权公告号CN...
Win11终于不卡了!让CPU... 快科技5月8日消息,微软正针对Windows11系统用户体验进行深度优化,内部代号为Project ...
2026户外出行与通勤旗舰手机... 对于经常需要通勤、热爱户外活动的朋友来说,选择一款合适的手机至关重要。它需要满足单手操作的便捷性、坚...