我在试着运行战术手册
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'"
}
我不明白我做错了什么.
发布于 2019-11-26 00:59:22
看一看Kubespray提供的sample inventory:
# ## 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_host
值指定Ansible将连接到的IP (与名称分开)。
发布于 2020-07-12 10:42:30
下面是清单文件的一个具体示例。请注意,ansible_host
设置为服务器的IP地址。每台服务器需要一行代码。
[all]
ip-10-250-195-106.ec2.internal ansible_host=10.250.195.106
https://stackoverflow.com/questions/59036467
复制相似问题