Commit Graph

195 Commits

Author SHA1 Message Date
Jonathon Anderson
0b00233ab7 Move tstruct.Overlay from wwctl to overlay.InitStruct
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2024-12-20 11:12:47 +01:00
Jonathon Anderson
c03dc9436b Add an Overlay type with helper methods
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2024-12-20 11:12:47 +01:00
Jonathon Anderson
7d4b7ab432 Remove OverlayDoesNotExistError
- No receiver of the error is checking its type
- No receiver of the error is checking its `Name` attribute
- Any receiver of the error knows the name already

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2024-12-20 11:12:47 +01:00
Jonathon Anderson
ac49ecef70 Rename and refactor overlay constructor functions
- Reduces redundancy
- Adds clarity

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2024-12-20 11:12:47 +01:00
Jonathon Anderson
717241aa18 Add methods to config.New().Paths for site and distribution overlays
- SiteOverlaySourcedir() uses WWOverlaydir (/var/lib/warewulf/overlays)
- DistributionOverlaySourcedir() uses Datadir (/usr/share/warewulf/overlays)
- config.New().Warewulf.DataStore moved to config.New().Paths.Datadir
- FindOverlays() ignores missing distribution overlay directory

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2024-12-20 11:12:47 +01:00
Christian Goll
d5fc7e9320 introduce site overlays
site overlays are place in sysconfdir/overlays and take
precedence over distribution overlays with the same name.

Every `wwctl overlay` command changing overlays will create
an site overlay. distribution overlays can't be deleted or
modified with wwctl.

Signed-off-by: Christian Goll <cgoll@suse.com>
2024-12-20 11:12:41 +01:00
Jonathon Anderson
fc82244749 Refactor softlink functions to remove repetition and add flexibility
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2024-12-17 18:48:00 -07:00
Christian Goll
9ff5c60505 create soft link with template
Add the the function softlink to the template rendering, so that
{{ softlink: "/bin/bash" }} for the file `/bin/run.ww` will create
a soft link to `/bin/bash`
It's also possible to "import" soft links from the host, e.g. the
template
{{ ImportLink "/etc/localtime" }}
set the timezone from the host

Signed-off-by: Christian Goll <cgoll@suse.com>
2024-12-17 18:48:00 -07:00
Jonathon Anderson
098c288ce2 Provide detected kernel version to overlay templates
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2024-12-09 10:02:28 +01:00
Jonathon Anderson
a7325b6ffa Remove WW_INTERNAL
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2024-11-11 00:08:54 -07:00
Jonathon Anderson
0665d5dc88 Refactor node
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2024-11-11 00:08:47 -07:00
Christian Goll
0dd0317740 replaced errors.Wrap with fmt.Errorf
Signed-off-by: Christian Goll <cgoll@suse.com>
2024-11-07 22:57:29 -07:00
Jonathon Anderson
fbd5ca9895 Recommended refactors
- make sure spec sets new cache dir
- move clean out of api
- capture warewulfconf.Paths.Cachedir+"/warewulf" in once place
- split Clean() into multiple functions
- remove WriteFileAbs

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2024-10-28 15:20:41 -06:00
Christian Goll
0c6e7cc58a fixes for split overlays
Signed-off-by: Christian Goll <cgoll@suse.com>
2024-10-17 15:39:54 -04:00
Christian Goll
ac6cd69ca6 fix test to run without NodeInfo
Also removed --fullall from node list and profile list

Signed-off-by: Christian Goll <cgoll@suse.com>
2024-10-17 15:30:47 -04:00
Christian Goll
28a7b9fe84 removed NodeInfo and using NodeConf instead
This is a significant change in the undelying data model!

nodeDb, err := node.New()

will result in a structure which contains the on disk
values. Only

nodeDb.FindAllNodes() or nodeDb.GetNode(id) will give
the nodes with its merged in profiles.

Signed-off-by: Christian Goll <cgoll@suse.com>
2024-10-17 13:35:42 -04:00
xu yang
d59ace3792 Change the permission of overlay dir to and generated overlays to
Signed-off-by: xu yang <xyang@ciq.com>
2024-09-27 11:48:44 -06:00
Jonathon Anderson
053dd9953a Split overlays into discrete functionality and test
- Closes #987

To make the overlays testable in isolation, and after discussion with
the TSC, removed host/time/source from overlay files.

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2024-09-26 10:48:38 -06:00
xu yang
170d03e751 fix the issue that system/runtime overlays are not auto-rebuilt
Signed-off-by: xu yang <xyang@ciq.com>
2024-06-19 09:31:32 +00:00
Jonathon Anderson
7046c6dc8c Use the first configured ssh key type for authn
Previously, the authentication key was always generated using rsa. Now
it uses the first configured ssh key type.

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2024-05-01 14:27:39 -06:00
Christian Goll
5c23a4cdde added {{ .Overlay }} to templates
{{ .Overlay }} contains the overlay name in which the template is
located, or an empty string if RenderTempalte is called outside the
warewulf overlay tree.

- Closes #1052

Signed-off-by: Christian Goll <cgoll@suse.com>
2024-04-17 21:40:32 -06:00
John Hanks
a7b5f6ac94 Drop 'tr' as a custom function. 2024-03-11 09:36:56 +01:00
John Hanks
cbf9178f10 Provide sprig functions in overlay templates 2024-03-11 09:36:52 +01:00
Christian Goll
ff10bc95bb const string for Version, Release, Confversion
The Version (e,g, 4.4 ), Release (git hash) and Confversion (e.g. 44)
must be compiled into the code so that they can't be changed during run
time and ensure this with the compiler

Signed-off-by: Christian Goll <cgoll@suse.com>
2024-02-17 10:22:44 -07:00
Christian Goll
1fca0057d3 updated WW_INTERNAL to 45 for 4.5.x release
Internal version update is necessary as new structures were added,
most obviously the disk, partitions and file system structures.
Old configurations will work as expected.

Signed-off-by: Christian Goll <cgoll@suse.com>
2024-02-16 20:12:51 -07:00
Jonathon Anderson
a1832ad8c1 Complete transfer of Warewulf from HPCng
Warewulf is now being maintained in its own GitHub organization at
github.com/warewulf

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2024-01-26 21:35:04 -07:00
jason yang
8f7b8b641b change message level from warn to debug
Signed-off-by: jason yang <jasonyangshadow@gmail.com>
2024-01-24 21:36:19 -07:00
Christian Goll
67e526d726 added test and reafctorred kernel.Build
Signed-off-by: Christian Goll <cgoll@suse.com>
2024-01-17 23:23:15 -07:00
Christian Goll
725176cfed cleanup code after review
Signed-off-by: Christian Goll <cgoll@suse.com>
2024-01-17 18:02:04 -07:00
Christian Goll
60dc8f6251 enable grub boot for all nodes
Signed-off-by: Christian Goll <cgoll@suse.com>
2024-01-17 18:02:04 -07:00
Christian Goll
183f8e479c Propagate paths to overlays and use for wwclient
Signed-off-by: Christian Goll <cgoll@suse.com>
2023-12-08 21:09:47 -07:00
Jonathon Anderson
2b49bcad27 Expand test descriptions and simplify some tests
As part of reviewing this PR, I expanded the test definitions to make it
easier to discern the intent of each test at a glance. In so doing I
understood most tests behaving as normal, but I did make a few small
changes:

- Some tests no longer produce any errors, so remove this variable from
  the test definitions.
- Replace comma-separated overlay definitions with explicit slices.
  Splitting comma-separated strings led to erroneous behavior where a
  null overlay list was processed as a single null overlay rather than
  an empty slice.

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2023-10-25 22:35:49 -06:00
Christian Goll
767be4fd8c refactored util_test.go to test on real files
Signed-off-by: Christian Goll <cgoll@suse.com>
2023-10-25 22:35:49 -06:00
Christian Goll
242276bba9 fixed tests and added explcit error handling
Signed-off-by: Christian Goll <cgoll@suse.com>
2023-10-25 22:35:49 -06:00
Christian Goll
e90616cafb calling the overlay build functions direclty
The warewulfd process called `wwctl build -O [system|runtime] node`
if autobuild was set. This created [system|runtime].img which isn't
supported with the build model. Calling now BuildOverlay directly

Signed-off-by: Christian Goll <cgoll@suse.com>
2023-10-25 22:35:45 -06:00
Jonathon Anderson
42842aeee1 Format entire source code using make fmt
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2023-10-23 17:56:20 -06:00
Christian Goll
ff7608251a advanced command line completion for wwctl overlay
Signed-off-by: Christian Goll <cgoll@suse.com>
2023-09-13 12:03:43 +02:00
Jonathon Anderson
9cf47da963 Fix warewulfd for new contextual overlay names
The recent PR #883 replaced the standard overlay naming convention with
static names for each of the runtime and wwinit/system contexts; but the
method by which it left the "legacy" naming convention in place led to a
bug where warewulfd was still attempting to serve overlays with the
previous naming convention, though this name wasn't being built.

This PR refactors contextual overlay image naming to be, I think, a more
typical golang pattern, and updates affected code to match.

This PR also included tests for all functions modified by this change.

Fixes #896

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2023-09-02 11:18:38 -06:00
Jonathon Anderson
9058682b18 Add tests for disk data and ignition json
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2023-08-22 14:28:02 -06:00
Christian Goll
a7df560a30 Add json output for ignition
Signed-off-by: Christian Goll <cgoll@suse.com>
2023-08-21 16:19:13 -06:00
griznog
13c426de1c Add an argument to the runtime/system overlay related functions to carry the context to getOverlayFile() for building the img name. 2023-07-27 07:27:20 -05:00
Jonathon Anderson
4622153a82 Support subdirectories in ipxe paths
Signed-off-by: Jonathon Anderson <janderson@ciq.co>
2023-04-19 14:02:43 -06:00
Jonathon Anderson
8321193645 Refactor and document config/datastructure
Also adjusted case for initialisms (e.g., DHCP, TFTP, NFS).

Signed-off-by: Jonathon Anderson <janderson@ciq.co>
2023-04-19 14:02:43 -06:00
Jonathon Anderson
70292276e2 Rename BaseConf.New to BaseConf.Get
Since BaseConf.New could return a cached BaseConf, rather than always
constructing a new struct, I've renamed it to Get to more accurately
reflect its use. A new New() method is called by Get and always
initializes a new struct.

Signed-off-by: Jonathon Anderson <janderson@ciq.co>
2023-04-19 14:02:43 -06:00
Jonathon Anderson
c461e65a98 Rename pkg/warewulfconf to pkg/config
Signed-off-by: Jonathon Anderson <janderson@ciq.co>
2023-04-19 14:02:43 -06:00
Christian Goll
ce43dfa0b7 removed getters as configs must exportable
Signed-off-by: Christian Goll <cgoll@suse.de>
2023-03-06 10:20:00 +01:00
Christian Goll
ca088d123d paths need to be visibale for marshalling
Signed-off-by: Christian Goll <cgoll@suse.de>
2023-03-03 16:12:53 +01:00
Christian Goll
377702a179 make the configuration to be based in warewulf.conf
defaults will be se by the Makefile

Signed-off-by: Christian Goll <cgoll@suse.de>
2023-03-03 16:02:41 +01:00
Christian Goll
78978ad233 added warewulfconf as command line parameter
the environment variable WAREWULFCONF is also recognized

Signed-off-by: Christian Goll <cgoll@suse.de>
2023-03-03 11:18:49 +01:00
Christian Goll
11fa27f3e9 Merge pull request #651 from mslacken/MakeIpxeConfig
make ipxe binary source configurable
2023-02-24 15:12:26 +01:00