creating exports from resource

Signed-off-by: Christian Goll <cgoll@suse.com>
This commit is contained in:
Christian Goll
2024-11-26 12:03:21 +01:00
committed by Jonathon Anderson
parent 77bdfba816
commit 847d11611b
5 changed files with 23 additions and 15 deletions

View File

@@ -34,6 +34,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- New "localtime" overlay to define the system time zone. #1303
- Add support for nested profiles. #1572, #1598
- Adds `wwctl container <exec|shell> --build=false` to prevent automatically (re)building the container. #1490, #1489
- Added resource as global variable for templates
### Changed

View File

@@ -46,7 +46,8 @@ func templateFileBlock(inc string, abortStr string) (string, error) {
wwlog.Debug("Including file block into template: %s", inc)
readFile, err := os.Open(inc)
if err != nil {
return "", err
wwlog.Info("couldn't read block %s: %s", inc, err)
return abortStr, nil
}
defer readFile.Close()
var cont string

View File

@@ -58,7 +58,7 @@ func Test_hostOverlay(t *testing.T) {
conf: "",
args: []string{"--render", "host", "host", "etc/exports.ww"},
log: host_exports,
header: "",
header: "# Do not edit after this line",
},
{
name: "host:/etc/hosts",
@@ -278,11 +278,10 @@ dhcp-host=e6:92:39:49:7b:04,set:warewulf,node2,192.168.3.23,infinite
const host_exports string = `backupFile: true
writeFile: true
Filename: etc/exports
# This file is autogenerated by warewulf
# Do not edit after this line
# This block is autogenerated by warewulf
# Resource: NFSHOME
/home 192.168.0.0/255.255.255.0(rw,sync)
/opt 192.168.0.0/255.255.255.0(ro,sync,no_root_squash)
`
const host_hosts string = `backupFile: true

View File

@@ -15,3 +15,10 @@ nodes:
device: wwnet0
hwaddr: e6:92:39:49:7b:04
ipaddr: 192.168.3.23
resource:
NFSHOME:
mountpoint: /home
moptions: defaults
eoptions: rw,sync
epath: /home
server: controller

View File

@@ -1,11 +1,11 @@
{{- if .Nfs.Enabled }}
# This file is autogenerated by warewulf
{{ IncludeBlock "/etc/exports" "# Do not edit after this line" }}
# This block is autogenerated by warewulf
{{- $Resource := .Resource }}
{{- $network := .Network }}
{{- $netmask := .Netmask }}
{{- range .Nfs.ExportsExtended }}
{{ .Path }} {{ $network }}/{{ $netmask }}({{ .ExportOptions }})
{{- end }}
{{- else }}
{{ abort }}
{{- end }}
{{- range $ResName,$Res := .Resource }}
{{- if eq (substr 0 3 $ResName) "NFS" }}{{ if eq $Res.server "controller" }}
# Resource: {{ $ResName }}
{{ $Res.epath}} {{ $network }}/{{ $netmask }}({{ $Res.eoptions }})
{{- end }}{{ end }}
{{- end }}