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

Posted lvhanzhi

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[WARNING]: Could not match supplied host pattern, ignoring: servers相关的知识,希望对你有一定的参考价值。

Centos7.5 ansible执行命令报错

问题:

[[email protected] ~]# 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

原因:

没有添加主机清单

解决方法:

方式一:
[[email protected] ~]# vim /etc/ansible/hosts
[webservers]
172.16.1.7
[mysqlservers]
172.16.1.8
[servers:children]
webservers
mysqlservers
[[email protected] ~]# ansible servers -a "hostname" 
172.16.1.8 | CHANGED | rc=0 >>
web02
172.16.1.7 | CHANGED | rc=0 >>
web01
方式二:
[[email protected] ~]# vim hosts
[webservers]
172.16.1.7
[mysqlservers]
172.16.1.8
[servers:children]
webservers
mysqlservers
[[email protected] ~]# 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的主要内容,如果未能解决你的问题,请参考以下文章

U盘安装CentOS 7提示 “Warning: /dev/root does not exist, could not boot” 解决办法

WARNING:root:could not open file ‘/etc/apt/sources.list.d

(转) WARNING: Could not open/create prefs root node SoftwareJavaSoftPrefs at root 0x80000002. Windo(示

WARNING: The host 'WeiLei' could not be looked up with resolveip.

(etherape:27270): libglade-WARNING **: 23:47:40.270: Could not load support for `gnome': libgnom

WARNING: The host '$hostname' could not be looked up with resolveip. (转)