【问题标题】:Error when running playbook with tags on kubespray在 kubespray 上运行带有标签的 playbook 时出错
【发布时间】:2020-07-12 10:42:29
【问题描述】:

我正在尝试运行剧本

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'"
}

我不明白我做错了什么......

【问题讨论】:

  • 您关注的是哪个指南?
  • 请发布您定义的所有 group_vars 以及您的库存结构。

标签: kubernetes ansible kubespray


【解决方案1】:

看看 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(与名称分开) .

【讨论】:

  • 我像你提到的那样配置我的库存,因为那,我对这个错误感到困惑......在下面的答案中,是我的库存
【解决方案2】:

这是库存文件的具体示例。请注意,ansible_host 设置为服务器的 IP 地址。每台服务器都需要一条线路。

[all]
ip-10-250-195-106.ec2.internal ansible_host=10.250.195.106

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-06-04
    • 2018-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-15
    • 1970-01-01
    相关资源
    最近更新 更多