From 8a419f648b48c773695710cd3db35211588d4c59 Mon Sep 17 00:00:00 2001 From: Gregory Kurtzer Date: Tue, 22 Dec 2020 21:51:05 -0800 Subject: [PATCH 1/5] Properly configure a network device to be default --- internal/app/wwctl/node/list/main.go | 1 + internal/app/wwctl/node/set/main.go | 18 ++++++++++++++++++ internal/app/wwctl/node/set/root.go | 3 +++ internal/app/wwctl/profile/list/main.go | 2 +- internal/app/wwctl/profile/set/main.go | 19 +++++++++++++++++++ internal/app/wwctl/profile/set/root.go | 2 ++ 6 files changed, 44 insertions(+), 1 deletion(-) diff --git a/internal/app/wwctl/node/list/main.go b/internal/app/wwctl/node/list/main.go index 47a4a5d1..74d68a8a 100644 --- a/internal/app/wwctl/node/list/main.go +++ b/internal/app/wwctl/node/list/main.go @@ -61,6 +61,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error { fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), name+":NETMASK", netdev.Netmask.Source(), netdev.Netmask.Print()) fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), name+":GATEWAY", netdev.Gateway.Source(), netdev.Gateway.Print()) fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), name+":TYPE", netdev.Type.Source(), netdev.Type.Print()) + fmt.Printf("%-20s %-18s %-12s %t\n", node.Id.Get(), name+":DEFAULT", netdev.Default.Source(), netdev.Default.PrintB()) } // v := reflect.ValueOf(node) diff --git a/internal/app/wwctl/node/set/main.go b/internal/app/wwctl/node/set/main.go index 22298a56..2878cbc2 100644 --- a/internal/app/wwctl/node/set/main.go +++ b/internal/app/wwctl/node/set/main.go @@ -233,6 +233,24 @@ func CobraRunE(cmd *cobra.Command, args []string) error { wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting HW address to: %s\n", n.Id.Get(), SetNetDev, SetHwaddr) n.NetDevs[SetNetDev].Hwaddr.Set(SetHwaddr) } + if SetNetDevDefault == true { + if SetNetDev == "" { + wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n") + os.Exit(1) + } + + if _, ok := n.NetDevs[SetNetDev]; !ok { + var nd node.NetDevEntry + n.NetDevs[SetNetDev] = &nd + } + + wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting device as default\n", n.Id.Get(), SetNetDev) + for _, dev := range n.NetDevs { + // First clear all other devices that might be configured as default + dev.Default.SetB(false) + } + n.NetDevs[SetNetDev].Default.SetB(true) + } err := nodeDB.NodeUpdate(n) if err != nil { diff --git a/internal/app/wwctl/node/set/root.go b/internal/app/wwctl/node/set/root.go index 24fe2934..3aadc4c7 100644 --- a/internal/app/wwctl/node/set/root.go +++ b/internal/app/wwctl/node/set/root.go @@ -19,6 +19,7 @@ var ( SetGateway string SetHwaddr string SetNetDevDel bool + SetNetDevDefault bool SetClusterName string SetIpxe string SetRuntimeOverlay string @@ -66,6 +67,8 @@ func init() { baseCmd.PersistentFlags().StringVarP(&SetGateway, "gateway", "G", "", "Set the node's network device gateway") baseCmd.PersistentFlags().StringVarP(&SetHwaddr, "hwaddr", "H", "", "Set the node's network device HW address") baseCmd.PersistentFlags().BoolVar(&SetNetDevDel, "netdel", false, "Delete the node's network device") + baseCmd.PersistentFlags().BoolVar(&SetNetDevDefault, "netdefault", false, "Set this network to be default") + baseCmd.PersistentFlags().BoolVarP(&SetNodeAll, "all", "a", false, "Set all nodes") baseCmd.PersistentFlags().BoolVarP(&SetYes, "yes", "y", false, "Set 'yes' to all questions asked") diff --git a/internal/app/wwctl/profile/list/main.go b/internal/app/wwctl/profile/list/main.go index 9702bc81..371e6171 100644 --- a/internal/app/wwctl/profile/list/main.go +++ b/internal/app/wwctl/profile/list/main.go @@ -49,7 +49,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error { fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), name+":GATEWAY", netdev.Gateway.Print()) fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), name+":HWADDR", netdev.Hwaddr.Print()) fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), name+":TYPE", netdev.Hwaddr.Print()) - + fmt.Printf("%-20s %-18s %t\n", profile.Id.Get(), name+":DEFAULT", netdev.Default.PrintB()) } } diff --git a/internal/app/wwctl/profile/set/main.go b/internal/app/wwctl/profile/set/main.go index 5025a3ff..74ec6adc 100644 --- a/internal/app/wwctl/profile/set/main.go +++ b/internal/app/wwctl/profile/set/main.go @@ -213,6 +213,25 @@ func CobraRunE(cmd *cobra.Command, args []string) error { p.NetDevs[SetNetDev].Hwaddr.Set(SetHwaddr) } + if SetNetDevDefault == true { + if SetNetDev == "" { + wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n") + os.Exit(1) + } + + if _, ok := p.NetDevs[SetNetDev]; !ok { + var nd node.NetDevEntry + p.NetDevs[SetNetDev] = &nd + } + + wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting device as default\n", p.Id.Get(), SetNetDev) + for _, dev := range p.NetDevs { + // First clear all other devices that might be configured as default + dev.Default.SetB(false) + } + p.NetDevs[SetNetDev].Default.SetB(true) + } + err := nodeDB.ProfileUpdate(p) if err != nil { wwlog.Printf(wwlog.ERROR, "%s\n", err) diff --git a/internal/app/wwctl/profile/set/root.go b/internal/app/wwctl/profile/set/root.go index b23a33fb..875fa3e8 100644 --- a/internal/app/wwctl/profile/set/root.go +++ b/internal/app/wwctl/profile/set/root.go @@ -29,6 +29,7 @@ var ( SetGateway string SetHwaddr string SetNetDevDel bool + SetNetDevDefault bool SetInit string SetRoot string ) @@ -56,6 +57,7 @@ func init() { baseCmd.PersistentFlags().StringVarP(&SetGateway, "gateway", "G", "", "Set the node's network device gateway") baseCmd.PersistentFlags().StringVarP(&SetHwaddr, "hwaddr", "H", "", "Set the node's network device HW address") baseCmd.PersistentFlags().BoolVar(&SetNetDevDel, "netdel", false, "Delete the node's network device") + baseCmd.PersistentFlags().BoolVar(&SetNetDevDefault, "netdefault", false, "Set this network to be default") baseCmd.PersistentFlags().BoolVarP(&SetAll, "all", "a", false, "Set all profiles") baseCmd.PersistentFlags().BoolVarP(&SetForce, "force", "f", false, "Force configuration (even on error)") From bd2968cf51b7dc4be2d71ddbbed68d9028e951c6 Mon Sep 17 00:00:00 2001 From: Gregory Kurtzer Date: Tue, 22 Dec 2020 21:51:19 -0800 Subject: [PATCH 2/5] Fix minor bug in hosts template for bool value --- etc/hosts.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/hosts.tmpl b/etc/hosts.tmpl index 1bdabf71..d02c5eea 100644 --- a/etc/hosts.tmpl +++ b/etc/hosts.tmpl @@ -3,7 +3,7 @@ {{range $node := $.AllNodes}} # Entry for {{$node.Id.Get}} {{- range $devname, $netdev := $node.NetDevs}} -{{- if $netdev.Default}} +{{- if $netdev.Default.GetB}} {{$netdev.Ipaddr.Get}} {{$node.Id.Get}} {{- else}} {{$netdev.Ipaddr.Get}} {{$node.Id.Get}}-{{$devname}} From b7d0a8d9b942089e62c7555176ed175a1736c50f Mon Sep 17 00:00:00 2001 From: Gregory Kurtzer Date: Tue, 22 Dec 2020 21:59:26 -0800 Subject: [PATCH 3/5] Minor fix in hosts.tmpl when an IP address isn't defined --- etc/hosts.tmpl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/etc/hosts.tmpl b/etc/hosts.tmpl index d02c5eea..feedb4ca 100644 --- a/etc/hosts.tmpl +++ b/etc/hosts.tmpl @@ -3,11 +3,13 @@ {{range $node := $.AllNodes}} # Entry for {{$node.Id.Get}} {{- range $devname, $netdev := $node.NetDevs}} +{{- if $netdev.Ipaddr.Defined}} {{- if $netdev.Default.GetB}} {{$netdev.Ipaddr.Get}} {{$node.Id.Get}} {{- else}} {{$netdev.Ipaddr.Get}} {{$node.Id.Get}}-{{$devname}} {{- end}} {{- end}} +{{- end}} {{end}} From b4e5656b5bb85c6418fc35f10a863653640ef040 Mon Sep 17 00:00:00 2001 From: Gregory Kurtzer Date: Tue, 22 Dec 2020 22:20:22 -0800 Subject: [PATCH 4/5] Create the correct directory name (plural for chroots) --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d635833d..f8d0d8e7 100644 --- a/Makefile +++ b/Makefile @@ -44,7 +44,7 @@ all: vendor wwctl wwclient files: all install -d -m 0755 /var/warewulf/ - install -d -m 0755 /var/warewulf/chroot + install -d -m 0755 /var/warewulf/chroots install -d -m 0755 /etc/warewulf/ install -d -m 0755 /etc/warewulf/ipxe install -d -m 0755 /var/lib/tftpboot/warewulf/ipxe/ From 3791633ea46786acce7671dd9078ef1d2e6734fc Mon Sep 17 00:00:00 2001 From: Gregory Kurtzer Date: Tue, 22 Dec 2020 22:26:29 -0800 Subject: [PATCH 5/5] Setting up basic documentation --- docs/Contributing.md | 23 +++++++++++++++++++++++ docs/README.md | 14 ++++++++++++++ docs/rhel7-quickstart.md | 2 +- docs/rhel8-quickstart.md | 2 +- 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 docs/Contributing.md diff --git a/docs/Contributing.md b/docs/Contributing.md new file mode 100644 index 00000000..29bd092e --- /dev/null +++ b/docs/Contributing.md @@ -0,0 +1,23 @@ +# Contributing + +Warewulf is an open source project and we invite your collaboration and help. + +## Contributor's Agreement +You are under no obligation whatsoever to provide any bug fixes, patches, or upgrades to the features, functionality +or performance of the source code ("Enhancements") to anyone; however, if you choose to make your Enhancements +available either publicly, or directly to the project, without imposing a separate written license agreement for such +Enhancements, then you hereby grant the following license: a non-exclusive, royalty-free perpetual license to +install, use, modify, prepare derivative works, incorporate into other computer software, distribute, and sublicense +such enhancements or derivative works thereof, in binary and source code form. + +## To Contribute +Here is the very high level guide to contributing: + +* For the project to a location of your choosing +* Clone your fork locally: `git clone http://github.com/$NAME/warewulf.git` +* Inside your fork, create a local branch: `cd warewulf; git checkout -b localchanges` +* Make the necessary changes and commit them: `git commit -a` +* Push your changes: `git push origin localchanges` +* Create a PR using GitHub: `https://github.com/$NAME/warewulf/pull/new/localchanges` + +*note: set your environment variable `NAME=github_username` before running the above commands.* diff --git a/docs/README.md b/docs/README.md index 7226386a..2ccdeaa2 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,7 +1,21 @@ # Documentation for Warewulf +The documentation for Warewulf is a work in progress and we are asking for contributions from the open source +community on this. Please see the [contributing](Contributing.md) document for how to help out this project. + ### Quickstarts * [RHEL-7 quickstart](rhel7-quickstart.md) * [RHEL-8 quickstart](rhel8-quickstart.md) +### Chapters +(all coming soon) + +* [Introduction](introduction.md) +* [Architecture](architecture.md) +* [System Services and Dependencies](system_services.md) +* [Profiles](profiles.md) +* [Node Configurations](nodes.md) +* [Containers and VNFS images](containers.md) +* [Overlays](overlays.md) +* [SELinux](selinux.md) diff --git a/docs/rhel7-quickstart.md b/docs/rhel7-quickstart.md index 24f8c114..aaf02d5e 100644 --- a/docs/rhel7-quickstart.md +++ b/docs/rhel7-quickstart.md @@ -128,7 +128,7 @@ Here are some of the common `overlay` commands: ``` sudo ./wwctl overlay list -l sudo ./wwctl overlay list -ls -sudo EDITOR=vim ./wwctl overlay edit default /etc/hello_world.ww +sudo ./wwctl overlay edit default /etc/hello_world.ww sudo ./wwctl overlay build -a ``` diff --git a/docs/rhel8-quickstart.md b/docs/rhel8-quickstart.md index 1acfb887..1b255256 100644 --- a/docs/rhel8-quickstart.md +++ b/docs/rhel8-quickstart.md @@ -129,7 +129,7 @@ Here are some of the common `overlay` commands: ``` sudo ./wwctl overlay list -l sudo ./wwctl overlay list -ls -sudo EDITOR=vim ./wwctl overlay edit default /etc/hello_world.ww +sudo ./wwctl overlay edit default /etc/hello_world.ww sudo ./wwctl overlay build -a ```