Commit Graph

165 Commits

Author SHA1 Message Date
Jonathon Anderson
749e79b7ec Clone to a site overlay when adding files in wwapi
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2025-07-28 18:18:48 -06:00
Jonathon Anderson
9884aad504 Consolidated createOverlayFile and updateOverlayFile to addOverlayFile
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2025-07-28 18:18:48 -06:00
jason yang
62d1aa654d Support for creating and updating overlay file in wwapi
Signed-off-by: jason yang <jasonyangshadow@gmail.com>
2025-07-28 18:18:48 -06:00
Jonathon Anderson
7b2c0901ed Only return overlay files that refer to a path within the overlay
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2025-07-28 18:18:48 -06:00
jason yang
e089fe0101 add overlay file deletion support
Signed-off-by: jason yang <jasonyangshadow@gmail.com>
2025-07-28 18:18:48 -06:00
Jonathon Anderson
db3a3fee05 Additional overlays to support provision-to-disk without ignition
- sfdisk - partitions the disk
- mkfs - formats partitions
- mkswap - formats partitions for swap
- systemd.mount - explicit creation of systemd mount units
- systemd.swap - explicit creation of systemd swap units

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2025-06-30 23:24:20 -06:00
Jonathon Anderson
b98eae4b01 Refactor ignition support during dracut
- Control root device using the node/profile root field
- Add support for `/warewulf/wwinit.d` to run scripts during first stage
- Move first-stage ignition support to `/warewulf/wwinit.d/`
- Add `wwctl <node|profile> set --parttype`
- Add overlay template functions `SystemdEscape` and `SystemdEscapePath`
- Support configuring ignition with resources

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2025-06-30 23:19:31 -06:00
Jonathon Anderson
4367b56120 Restore some default behaviors
- If `init` is not specified, wwinit looks for /sbin/init, /etc/init,
  and /bin/init, matching dracut behavior.
- assume ipxe template=default if not set
- Display a warning during overlay build if an overlay list is empty

Issues:

- Closes: #1808
- Closes: #1813

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2025-03-25 09:07:03 +01:00
Jonathon Anderson
279e966ce2 Reduced default verbosity of wwctl overlay build
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2025-02-20 01:40:36 -07:00
Jonathon Anderson
21333482e6 Omit duplicate passwd and group entries in syncuser overlay
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2025-02-11 18:28:47 -07:00
Jonathon Anderson
6a250f3f96 Set execute permissions for intermediate directories
- Fixes: #1655

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2025-02-05 20:04:22 -07:00
Jonathon Anderson
4f83885c5b Show each overlay only once #1675
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2025-02-01 13:40:12 +01:00
Jonathon Anderson
d6d1e37c83 Merge pull request #1641 from anderbubble/rename-container-node-image
Rename "container" to "image"
2025-01-23 21:45:41 -07:00
Jonathon Anderson
45a690ca4e Rename "container" to "image"
- Updated `wwctl upgrade` to handle updates
- Maintained `.Container` and `.ContainerName` in tstruct
- Added `ContainerName()` methods to node and profile objects
- Added `--container`, `-C` aliases to wwctl commands (`<node|profile> <add|set>`)
- Added `wwctl container` alias
- Added support for `container_exit.sh` if `image_exit.sh` is not found

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2025-01-19 05:54:19 -07:00
Jonathon Anderson
4be3e6db9f Linting fixes called-out by vscode
A few linting issues that were called out by vscode.

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2025-01-19 05:26:43 -07:00
Jonathon Anderson
c244adc7f6 Performance improvements for overlay build
Rendering overlay templates requires fetching and populating / merging all
other nodes, because overlay templates have access to all cluster node info.
This was previously being done for each template render, but is not being done
once for each render operation and re-used for each template render.

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2024-12-25 08:48:14 -07:00
Jonathon Anderson
a59403ab3b Parallel overlay builds
- Closes #1018

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2024-12-25 08:48:14 -07:00
Jonathon Anderson
53e5805fbe Remove os.Umask from overlay.BuildOverlayIndir
Adds tests to ensure that the overlay image contains the correct permissions.

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2024-12-25 08:48:14 -07:00
Jonathon Anderson
e3680438a6 Remove Chdir from overlay.BuildOverlayIndir
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2024-12-25 08:48:14 -07:00
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
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
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
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
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
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
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
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
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
e8e9c4f3bd Merge branch 'development' into lint-update 2023-02-02 14:38:33 -07:00
David McFarlane
950099f9dc Set umask to 0000 while overlays are being built. Fixes #584 2023-01-18 14:34:40 +11:00
Jonathon Anderson
15879eb991 Use node.NewInfo constructor in configure hostfile
Also used in overlay, as I was looking there already.

Signed-off-by: Jonathon Anderson <janderson@ciq.co>
2022-11-11 11:42:40 -06:00
Logan Harbour
99ec5acb59 Fix typos 2022-11-08 09:53:22 -07:00
mslacken
ab0ee87629 updated linter and fixed deprecated stuff 2022-10-14 17:40:16 +02:00
Jonathon Anderson
0b3e862bea Remove trailing newline from wwlog
I noticed that some wwlog calls included a trailing newline, but others
did not. I tested both in isolation and discovered that the behavior was
consistent regardless of whether a trailing newline was included. I
further confirmed in code that wwlog appends a trailing newline
automatically if it is not present; so a trailing newline is unnecessary
in individual calls.

This commit removes trailing newlines from all calls to make them
consistent. It also replaces two calls to wwlog.Printf. (see #534)

Signed-off-by: Jonathon Anderson <janderson@ciq.co>
2022-09-15 12:38:03 -06:00