库存如下:
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "unleash.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some K8S name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "unleash.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 26 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
我想 在模板中使用ansible_host哦'h2' ,但是我遇到了 ansible.errors.AnsibleUndefinedVariable 错误。如何解决?
我已经尝试过这些:
[host-1]
h1 ansible_ssh_private_key_file="*/*/*" ansible_host=a.b.c.d
h2 ansible_ssh_private_key_file="*/*/*" ansible_host=a.b.c.t
[host-2]
h3 ansible_ssh_private_key_file="*/*/*" ansible_host=a.b.c.r
答案 0 :(得分:1)
请提示:
- name: host
debug: msg="{{hostvars['h2']['ansible_host']}}"
答案 1 :(得分:1)
正确的语法
"{{ hostvars['h2']['ansible_host'] }}"
或
"{{ hostvars.h2.ansible_host }}"
提示:看看"{{ hostvars }}"
和"{{ groups }}"
。