Files
kube-forge/internal/resources/templates/kubespray/inventory/hosts.tmpl

62 lines
1.3 KiB
Cheetah

{{- range .Hosts }}
{{ .Hostname }} ansible_host={{ .Ip }} ip={{ .Ip }} {{ if .User }}ansible_user={{ .User }}{{- end }} {{ if .Password }}ansible_ssh_password={{ .Password }}{{- end }}
{{- end }}
[kube_control_plane]
{{- range .Hosts }}
{{- $search := "control_plane" -}}
{{- $found := false -}}
{{- range .Roles }}
{{- if eq . $search }}
{{- $found = true }}
{{- end }}
{{- end }}
{{- if $found }}
{{ .Hostname }}
{{- end }}
{{- end }}
[etcd]
{{- range .Hosts }}
{{- $search := "etcd" -}}
{{- $found := false -}}
{{- range .Roles }}
{{- if eq . $search }}
{{- $found = true }}
{{- end }}
{{- end }}
{{- if $found }}
{{ .Hostname }}
{{- end }}
{{- end }}
[kube_node]
{{- range .Hosts }}
{{- $search := "node" -}}
{{- $found := false -}}
{{- range .Roles }}
{{- if eq . $search }}
{{- $found = true }}
{{- end }}
{{- end }}
{{- if $found }}
{{ .Hostname }}
{{- end }}
{{- end }}
[k8s_cluster:children]
kube_control_plane
kube_node
[all:vars]
ansible_connection=ssh
{{- if not (eq .Credentials.User "") }}
ansible_user={{ .Credentials.User }}
{{- end }}
{{- if not (eq .Credentials.Password "") }}
ansible_ssh_password={{ .Credentials.Password }}
{{- end }}
{{- if not (eq .Credentials.PrivateKeyFile "") }}
ansible_ssh_private_key_file={{ .Credentials.PrivateKeyFile }}
{{- end }}