我正在尝试使用 Ansible 在我的 Kubernetes 集群上部署应用程序。我尝试使用此模块kubernetes集群模块但是当我尝试执行从文档中复制的示例剧本时,我得到了:
[WARNING]: Host file not found: /etc/ansible/hosts [WARNING]: provided hosts list is empty, only localhost is available ERROR! 'kubernetes' is not a valid attribute for a Play The error appears to have been in '/home/holo/enterpryze/sources/devops/orchiestration/environment-cloud/ansible-playbook/kube.yaml': line 1, column 3, but may be elsewhere in the file depending on the exact syntax problem. The offending line appears to be: - name: Create a kubernetes namespace ^ here
如何添加此模块以使我的示例配置正常工作?
答案1
显然存在语法错误。
不是 Play 的有效属性
您应该将模块调用放在tasks
部分下(注意缩进):
- hosts: server
tasks:
- name: mytask
kubernetes: