ansible - 为什么 kubespray ansible 无法匹配主机

标签 ansible kubespray

我是通过kubespray安装kubernetes的,我的kubespray版本是v2.11.0,我按照官方文档一步步安装。但是当我执行“ansible-playbook -i inventory/mycluster/hosts.yml --become --become-user=root cluster.yml”时,我得到以下与主机不匹配的信息。

root@yinkai01:~/kubespray# ansible-playbook -i inventory/mycluster/hosts.yml --become --become-user=root cluster.yml
/usr/local/lib/python3.5/dist-packages/ansible/parsing/vault/__init__.py:41: CryptographyDeprecationWarning: Python 3.5 support will be dropped in the next release ofcryptography. Please upgrade your Python.
  from cryptography.exceptions import InvalidSignature
 [WARNING]: Unable to parse /root/kubespray/inventory/mycluster/hosts.yml as an inventory source

 [WARNING]: No inventory was parsed, only implicit localhost is available

 [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'


PLAY [localhost] **********************************************************************************************************************************************************

TASK [Check ansible version >=2.7.8] **************************************************************************************************************************************
Saturday 10 October 2020  07:20:40 -0400 (0:00:00.089)       0:00:00.089 ****** 
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}
 [WARNING]: Could not match supplied host pattern, ignoring: bastion


PLAY [bastion[0]] *********************************************************************************************************************************************************
skipping: no hosts matched
 [WARNING]: Could not match supplied host pattern, ignoring: k8s-cluster

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


PLAY [k8s-cluster:etcd] ***************************************************************************************************************************************************
skipping: no hosts matched

PLAY [k8s-cluster:etcd] ***************************************************************************************************************************************************
skipping: no hosts matched

PLAY [etcd] ***************************************************************************************************************************************************************
skipping: no hosts matched

PLAY [k8s-cluster] ********************************************************************************************************************************************************
skipping: no hosts matched

PLAY [k8s-cluster] ********************************************************************************************************************************************************
skipping: no hosts matched
 [WARNING]: Could not match supplied host pattern, ignoring: kube-master


PLAY [kube-master] ********************************************************************************************************************************************************
skipping: no hosts matched

PLAY [k8s-cluster] ********************************************************************************************************************************************************
skipping: no hosts matched
 [WARNING]: Could not match supplied host pattern, ignoring: calico-rr


PLAY [calico-rr] **********************************************************************************************************************************************************
skipping: no hosts matched

PLAY [kube-master[0]] *****************************************************************************************************************************************************
skipping: no hosts matched

PLAY [kube-master] ********************************************************************************************************************************************************
skipping: no hosts matched

PLAY [kube-master] ********************************************************************************************************************************************************
skipping: no hosts matched

PLAY [k8s-cluster] ********************************************************************************************************************************************************
skipping: no hosts matched

PLAY RECAP ****************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0   

Saturday 10 October 2020  07:20:40 -0400 (0:00:00.089)       0:00:00.178 ****** 
=============================================================================== 
Check ansible version >=2.7.8 -------------------------------------------------------------------------------------------------------------------------------------- 0.09s

我是主机 yaml。我认为关于hosts.yaml 没有问题,如下所示:

root@yinkai01:~/kubespray# cat inventory/mycluster/hosts.yaml 
all:
  hosts:
    node1:
      access_ip: 10.138.18.194
      ip: 10.138.18.194
      ansible_host: 10.138.18.194
    node2:
      access_ip: 10.138.18.195
      ip: 10.138.18.195
      ansible_host: 10.138.18.195
    node3:
      access_ip: 10.138.18.196
      ip: 10.138.18.196
      ansible_host: 10.138.18.196
  children:
    kube-master:
      hosts:
        node2:
        node1:
    kube-node:
      hosts:
        node3:
        node2:
        node1:
    etcd:
      hosts:
        node3:
        node2:
        node1:
    k8s-cluster:
      children:
        kube-node:
        kube-master:
    calico-rr:
      hosts: {}
root@yinkai01:~/kubespray#

谁能告诉我,我哪里错了?

最佳答案

只需在命令行中更改文件名(显然是拼写错误):

inventory/mycluster/hosts.yml

作者

inventory/mycluster/hosts.yaml

此警告可以帮助您:

 [WARNING]: No inventory was parsed, only implicit localhost is available

关于ansible - 为什么 kubespray ansible 无法匹配主机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64292972/

相关文章:

取消存档然后修改提取的文件的 Ansible 幂等性问题

ansible - 如何避免在没有主机匹配时运行剧本?

ansible - 如何在 Ansible 中为给定路径的所有 parent 、祖先设置 acl?

kubernetes - K8s - 将 kubeadm 添加到现有集群

ansible - 如何将 obsoletes=0 传递给 yum 或 ansible 中的打包模块

amazon-web-services - 使用 packer 和 ansible 时获取 AWS 实例的 IP 地址

kubernetes:无法加载现有证书 apiserver-etcd-client:

windows - 使用 Kubespray 和 Windows Worker 支持设置 Kubernetes

azure - 当 Kubespray 中其他节点丢失时,Kubernetes 集群节点不会自动创建