嗨,我尝试在 terraform 中自动化不同类型的节点组,以使用我们在自定义 tfvar 中传递的实例标签和配置的配置动态填充库存文件。
我能够正确呈现库存文件,但是当我对其运行 ansible 命令时,它失败了
任务 [bastion-ssh-config : create ssh bastion conf] 致命:[bastion]:失败!=> {"changed": false, "msg": "AnsibleUndefinedVariable: 'ansible.vars.hostvars.HostVarsVars object' 没有属性 'ansible_host'"}
下面是我自定义生成的库存文件
[all]
ip-10-211-204-179.ap-south-1.compute.internal ansible_host=10.211.204.179
ip-10-211-222-187.ap-south-1.compute.internal ansible_host=10.211.222.187
ip-10-211-194-202.ap-south-1.compute.internal ansible_host=10.211.194.202
ip-10-211-207-181.ap-south-1.compute.internal ansible_host=10.211.207.181
ip-10-211-218-9.ap-south-1.compute.internal ansible_host=10.211.218.9
ip-10-211-199-118.ap-south-1.compute.internal ansible_host=10.211.199.118
ip-10-211-214-102.ap-south-1.compute.internal ansible_host=10.211.214.102
ip-10-211-194-189.ap-south-1.compute.internal ansible_host=10.211.194.189
ip-10-211-221-38.ap-south-1.compute.internal ansible_host=10.211.221.38
ip-10-211-205-11.ap-south-1.compute.internal ansible_host=10.211.205.11
bastion ansible_host=65.2.38.18
bastion ansible_host=15.206.90.177
[bastion]
bastion ansible_host=65.2.38.18
bastion ansible_host=15.206.90.177
[kube-master]
ip-10-211-204-179.ap-south-1.compute.internal
ip-10-211-222-187.ap-south-1.compute.internal
ip-10-211-194-202.ap-south-1.compute.internal
[kube-node]
ip-10-211-207-181.ap-south-1.compute.internal
ip-10-211-218-9.ap-south-1.compute.internal
ip-10-211-199-118.ap-south-1.compute.internal
ip-10-211-214-102.ap-south-1.compute.internal
[etcd]
ip-10-211-194-189.ap-south-1.compute.internal
ip-10-211-221-38.ap-south-1.compute.internal
ip-10-211-205-11.ap-south-1.compute.internal
[k8s-cluster:children]
kube-node
kube-master
[k8s-cluster:vars]
apiserver_loadbalancer_domain_name="kubernetes-elb-25tagversion-1844424666.ap-south-1.elb.amazonaws.com"
注意:ansible 方面没有变化,因为我认为唯一的链接是 terraform 和 ansible 之间的库存文件。
已尝试使用标签:2.15