Kubernetes 在kubespray上运行带有标记的playbook时出错
我在试着写剧本Kubernetes 在kubespray上运行带有标记的playbook时出错,kubernetes,ansible,kubespray,Kubernetes,Ansible,Kubespray,我在试着写剧本 ansible-playbook \ -i inventory/preprod/inventory.ini \ --private-key ~/.ssh/id_rsa_stagging \ -u cloud-user \ --become \ --become-user=root \ cluster.yml \ --tags resolvconf 它返回以下错误: fatal: [tivit-aiops-k8s-preprd-app-1]: FAIL
ansible-playbook \
-i inventory/preprod/inventory.ini \
--private-key ~/.ssh/id_rsa_stagging \
-u cloud-user \
--become \
--become-user=root \
cluster.yml \
--tags resolvconf
它返回以下错误:
fatal: [tivit-aiops-k8s-preprd-app-1]: FAILED! => {
"msg": "The field 'environment' has an invalid
value, which includes an undefined variable. The error
was: 'ansible.vars.hostvars.HostVarsVars object' has
no attribute 'ansible_hostname'"
}
我不明白我做错了什么……请看Kubespray提供的:
# ## Configure 'ip' variable to bind kubernetes services on a
# ## different ip than the default iface
# ## We should set etcd_member_name for etcd cluster. The node that is not a etcd member do not need to set the value, or can set the empty string value.
[all]
# node1 ansible_host=95.54.0.12 # ip=10.3.0.1 etcd_member_name=etcd1
# node2 ansible_host=95.54.0.13 # ip=10.3.0.2 etcd_member_name=etcd2
# node3 ansible_host=95.54.0.14 # ip=10.3.0.3 etcd_member_name=etcd3
# node4 ansible_host=95.54.0.15 # ip=10.3.0.4 etcd_member_name=etcd4
# node5 ansible_host=95.54.0.16 # ip=10.3.0.5 etcd_member_name=etcd5
# node6 ansible_host=95.54.0.17 # ip=10.3.0.6 etcd_member_name=etcd6
有一个名称可用于通过清单文件引用此主机(用于将组分配给主机),还有一个
ansible\u host
值指定ansible将连接到的IP(与名称分开)。下面是清单文件的一个具体示例。请注意,ansible\u主机
设置为服务器的IP地址。每台服务器需要一行
[all]
ip-10-250-195-106.ec2.internal ansible_host=10.250.195.106
我像你提到的那样配置我的库存,因为我对这个错误感到困惑。。。在下面的回答中,是我的清单吗?您遵循的是哪一个指南?请发布您定义的所有组变量,以及您的清单结构。