host templates
This commit is contained in:
@ -2,8 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/sha1"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
@ -180,9 +178,20 @@ func (ctx *renderContext) renderConfigTo(buf io.Writer, configTemplate *clusters
|
||||
return string(ba), err
|
||||
}
|
||||
|
||||
extraFuncs["host_ip"] = func() string {
|
||||
if ctx.Host.Template {
|
||||
return "{{ host_ip }}"
|
||||
}
|
||||
return ctx.Host.IP
|
||||
}
|
||||
extraFuncs["host_name"] = func() string {
|
||||
if ctx.Host.Template {
|
||||
return "{{ host_name }}"
|
||||
}
|
||||
return ctx.Host.Name
|
||||
}
|
||||
extraFuncs["machine_id"] = func() string {
|
||||
ba := sha1.Sum([]byte(ctx.Cluster.Name + "/" + ctx.Host.Name)) // TODO: check semantics of machine-id
|
||||
return hex.EncodeToString(ba[:])
|
||||
return "{{ machine_id }}"
|
||||
}
|
||||
|
||||
extraFuncs["version"] = func() string { return Version }
|
||||
|
Reference in New Issue
Block a user