diff --git a/etc/warewulf.conf b/etc/warewulf.conf index 938c0bc9..b6e29601 100644 --- a/etc/warewulf.conf +++ b/etc/warewulf.conf @@ -18,6 +18,11 @@ tftp: systemd name: tftp nfs: systemd name: nfs-server - exports: - - /home - - /var/warewulf \ No newline at end of file + export paths: + - path: /home + export options: rw,sync + mount options: default + mount: true + - path: /opt + export options: ro,sync,no_root_squash + mount: false \ No newline at end of file diff --git a/internal/app/wwctl/configure/nfs/main.go b/internal/app/wwctl/configure/nfs/main.go index b9d5ec08..890b0370 100644 --- a/internal/app/wwctl/configure/nfs/main.go +++ b/internal/app/wwctl/configure/nfs/main.go @@ -64,9 +64,15 @@ func Configure(show bool) error { } for _, export := range controller.Nfs.ExportsExtended { - fmt.Fprintf(exports, "%s %s/%s(%s)\n", export.Path, controller.Network, controller.Netmask, export.Options) + fmt.Fprintf(exports, "%s %s/%s(%s)\n", export.Path, controller.Network, controller.Netmask, export.ExportOptions) if export.Mount { - fmt.Fprintf(fstab, "%s:%s %s nfs defaults 0 0\n", controller.Ipaddr, export.Path, export.Path) + var mountOpts string + if export.MountOptions == "" { + mountOpts = "defaults" + } else { + mountOpts = export.MountOptions + } + fmt.Fprintf(fstab, "%s:%s %s nfs %s 0 0\n", controller.Ipaddr, export.Path, export.Path, mountOpts) } } diff --git a/internal/pkg/warewulfconf/datastructure.go b/internal/pkg/warewulfconf/datastructure.go index db262269..f1405baa 100644 --- a/internal/pkg/warewulfconf/datastructure.go +++ b/internal/pkg/warewulfconf/datastructure.go @@ -1,9 +1,9 @@ package warewulfconf import ( + "github.com/creasty/defaults" "github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/wwlog" - "github.com/creasty/defaults" ) var ConfigFile = "/etc/warewulf/warewulf.conf" @@ -44,29 +44,30 @@ type TftpConf struct { } type NfsConf struct { - Enabled bool `default:"true" yaml:"enabled"` - Exports []string `yaml:"exports"` - ExportsExtended []*NfsExportConf `yaml:"exports extended"` - SystemdName string `yaml:"systemd name"` -} - -func (s *NfsConf) UnmarshalYAML(unmarshal func(interface{}) error) error { - if err := defaults.Set(s); err != nil { - return err - } - - type plain NfsConf - if err := unmarshal((*plain)(s)); err != nil { - return err - } - - return nil + Enabled bool `default:"true" yaml:"enabled"` + Exports []string `yaml:"exports"` + ExportsExtended []*NfsExportConf `yaml:"export paths"` + SystemdName string `yaml:"systemd name"` } type NfsExportConf struct { - Path string `yaml:"path"` - Options string `yaml:"options"` - Mount bool `yaml:"mount"` + Path string `yaml:"path"` + ExportOptions string `yaml:"export options"` + MountOptions string `yaml:"mount options"` + Mount bool `yaml:"mount"` +} + +func (s *NfsConf) UnmarshalYAML(unmarshal func(interface{}) error) error { + if err := defaults.Set(s); err != nil { + return err + } + + type plain NfsConf + if err := unmarshal((*plain)(s)); err != nil { + return err + } + + return nil } func init() {