码迷,mamicode.com
首页 > 其他好文 > 详细

[WARNING]: Could not match supplied host pattern, ignoring: servers

时间:2019-02-26 19:10:23      阅读:1692      评论:0      收藏:0      [点我收藏+]

标签:serve   name   could   root   添加主机   could not   hostname   lse   hat   

Centos7.5 ansible执行命令报错

问题:

[root@m01 ~]# ansible servers -a "hostname" 
 [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit
localhost does not match 'all'

 [WARNING]: Could not match supplied host pattern, ignoring: servers

原因:

没有添加主机清单

解决方法:

方式一:
[root@m01 ~]# vim /etc/ansible/hosts
[webservers]
172.16.1.7
[mysqlservers]
172.16.1.8
[servers:children]
webservers
mysqlservers
[root@m01 ~]# ansible servers -a "hostname" 
172.16.1.8 | CHANGED | rc=0 >>
web02
172.16.1.7 | CHANGED | rc=0 >>
web01
方式二:
[root@m01 ~]# vim hosts
[webservers]
172.16.1.7
[mysqlservers]
172.16.1.8
[servers:children]
webservers
mysqlservers
[root@m01 ~]# ansible servers -a "hostname" -i ./hosts
172.16.1.8 | CHANGED | rc=0 >>
web02
172.16.1.7 | CHANGED | rc=0 >>
web01

[WARNING]: Could not match supplied host pattern, ignoring: servers

标签:serve   name   could   root   添加主机   could not   hostname   lse   hat   

原文地址:https://www.cnblogs.com/lvhanzhi/p/10439228.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!