Improve virtual environment
Virtual environments now re-use names, to prevent accumulation of older environments when updating versions.
This commit is contained in:
parent
de9e2083e4
commit
48abe1c3db
|
@ -4,9 +4,9 @@
|
|||
.tmp/
|
||||
|
||||
# Ignore custom hosts.
|
||||
host/
|
||||
!host/base
|
||||
!host/virtual
|
||||
host/*
|
||||
!host/base/
|
||||
!host/virtual/
|
||||
|
||||
# Ignore files in private directory.
|
||||
private/
|
||||
|
|
18
Makefile
18
Makefile
|
@ -1,6 +1,7 @@
|
|||
# CoreOS options.
|
||||
NAME := coreos-home-server
|
||||
STREAM := stable
|
||||
VERSION := 36.20220820.3.0
|
||||
VERSION := 36.20220918.3.0
|
||||
ARCH := x86_64
|
||||
IMAGE_URI := https://builds.coreos.fedoraproject.org/prod/streams/
|
||||
HOST := $(if $(filter deploy-virtual,$(MAKECMDGOALS)),virtual,$(HOST))
|
||||
|
@ -8,7 +9,7 @@ HOST := $(if $(filter deploy-virtual,$(MAKECMDGOALS)),virtual,$(HOST))
|
|||
# Default Makefile options.
|
||||
VERBOSE :=
|
||||
ROOTDIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
TMPDIR := $(shell ls -d /var/tmp/fcos-build.???? 2>/dev/null || mktemp -d /var/tmp/fcos-build.XXXX && chmod 0755 /var/tmp/fcos-build.????)/
|
||||
TMPDIR := $(shell ls -d /var/tmp/$(NAME).???? 2>/dev/null || mktemp -d /var/tmp/$(NAME).XXXX && chmod 0755 /var/tmp/$(NAME).????)/
|
||||
|
||||
# Target-specific variables.
|
||||
ADDRESS = $(shell ip -o route get 1 | awk '{for (i=1; i<=NF; i++) {if ($$i == "src") {print $$(i+1); exit}}}')
|
||||
|
@ -31,15 +32,15 @@ deploy: $(TMPDIR)deploy/host/$(HOST)/spec.ign
|
|||
## Prepares and deploys CoreOS release for local, virtual environment.
|
||||
deploy-virtual: $(TMPDIR)images/fedora-coreos-$(VERSION)-qemu.$(ARCH).qcow2.xz $(TMPDIR)deploy/host/$(HOST)/spec.ign
|
||||
@printf "Preparing virtual environment...\n"
|
||||
$Q $(VIRTINSTALL) --import --name="fcos-$(STREAM)-$(VERSION)-$(ARCH)" --os-variant=fedora34 \
|
||||
$Q $(VIRTINSTALL) --import --name=$(NAME) --os-variant=fedora36 \
|
||||
--graphics=none --vcpus=2 --memory=2048 --cpu=host --virt-type=kvm \
|
||||
--disk="size=10,backing_store=$(TMPDIR)images/fedora-coreos-$(VERSION)-qemu.$(ARCH).qcow2" \
|
||||
--disk="size=20,backing_store=$(TMPDIR)images/fedora-coreos-$(VERSION)-qemu.$(ARCH).qcow2" \
|
||||
--qemu-commandline="-fw_cfg name=opt/com.coreos/config,file=$(TMPDIR)deploy/host/$(HOST)/spec.ign"
|
||||
|
||||
## Stop and remove virtual environment for CoreOS.
|
||||
destroy-virtual:
|
||||
$Q $(VIRSH) destroy fcos-$(STREAM)-$(VERSION)-$(ARCH) || true
|
||||
$Q $(VIRSH) undefine --remove-all-storage fcos-$(STREAM)-$(VERSION)-$(ARCH) || true
|
||||
$Q $(VIRSH) destroy $(NAME) || true
|
||||
$Q $(VIRSH) undefine --remove-all-storage $(NAME) || true
|
||||
|
||||
## Remove deployment configuration files required for build.
|
||||
clean:
|
||||
|
@ -107,11 +108,6 @@ $(TMPDIR)make.depend: $(shell find $(ROOTDIR) -name '*.bu' -type f 2>/dev/null)
|
|||
@printf "$(foreach i,$^,\n$(patsubst $(ROOTDIR)%.bu,$(TMPDIR)deploy/%.ign, \
|
||||
$(i)): $(addprefix $(TMPDIR)deploy/, $(shell awk -F '[ ]+local:[ ]*' '/^[ ]+(-[ ]+)?local:/ {print $$2}' $(i))))" >> $@
|
||||
|
||||
# Show help if empty or invalid target has been given.
|
||||
.DEFAULT:
|
||||
$Q $(MAKE) -s -f $(firstword $(MAKEFILE_LIST)) help
|
||||
@printf "Invalid target '$@', stopping.\n"; exit 1
|
||||
|
||||
.PHONY: deploy deploy-virtual destroy-virtual clean purge help $(CONTAINERFILES)
|
||||
|
||||
# Conditional command echo control.
|
||||
|
|
|
@ -71,19 +71,24 @@ function sync-systemd-services() {
|
|||
if test -n "$buffer"; then return 0; else return 1; fi
|
||||
}
|
||||
|
||||
# Synchronize all existing CoreOS home-server configuration.
|
||||
for hostdir in "$HOST_CONFIG_PATH"/*; do
|
||||
if test ! -d "$hostdir"; then
|
||||
continue
|
||||
# Entrypoint for script. Process all services present in host configuration against remote state.
|
||||
function main() {
|
||||
# Synchronize all existing CoreOS home-server configuration.
|
||||
for hostdir in "$HOST_CONFIG_PATH"/*; do
|
||||
if test ! -d "$hostdir"; then
|
||||
continue
|
||||
fi
|
||||
|
||||
printf "Synchronizing host configuration for '%s'... " "$hostdir"
|
||||
sync-coreos-config "$hostdir"
|
||||
done
|
||||
|
||||
# Synchronize systemd services from local CoreOS home-server configuration.
|
||||
printf "Synchronizing systemd service files... "
|
||||
if sync-systemd-services; then
|
||||
printf "Reloading systemd daemon after service updates...\n"
|
||||
systemctl daemon-reload
|
||||
fi
|
||||
}
|
||||
|
||||
printf "Synchronizing host configuration for '%s'... " "$hostdir"
|
||||
sync-coreos-config "$hostdir"
|
||||
done
|
||||
|
||||
# Synchronize systemd services from local CoreOS home-server configuration.
|
||||
printf "Synchronizing systemd service files... "
|
||||
if sync-systemd-services; then
|
||||
printf "Reloading systemd daemon after service updates...\n"
|
||||
systemctl daemon-reload
|
||||
fi
|
||||
main "$@"
|
||||
|
|
|
@ -7,7 +7,6 @@ ConditionPathExists=%E/coreos-home-server/%i/Containerfile
|
|||
[Service]
|
||||
Type=oneshot
|
||||
SyslogIdentifier=%N
|
||||
Environment=PODMAN_BUILD_OPTIONS=
|
||||
ExecStart=/bin/podman build $PODMAN_BUILD_OPTIONS --file %E/coreos-home-server/%i/Containerfile --tag localhost/%i:latest %E/coreos-home-server/%i
|
||||
|
||||
[Install]
|
||||
|
|
|
@ -3,7 +3,7 @@ version: 1.3.0
|
|||
ignition:
|
||||
config:
|
||||
merge:
|
||||
- local: host/base/container.ign
|
||||
- local: host/base/spec.ign
|
||||
- local: host/base/logging.ign
|
||||
- local: service/redis/spec.ign
|
||||
- local: service/mariadb/spec.ign
|
||||
|
@ -133,7 +133,7 @@ systemd:
|
|||
[Service]
|
||||
ExecStartPre=/bin/podman volume create letsencrypt
|
||||
ExecStart=
|
||||
ExecStart=/bin/sh -c "V=$(podman volume mount letsencrypt) && cp -Rv /etc/ssl/private/certificates $V"
|
||||
ExecStart=/bin/sh -c "V=$(podman volume mount letsencrypt) && cp -Rv /etc/ssl/private/certificates $V && chown -R 10000:10000 $V"
|
||||
ExecStartPost=/bin/podman volume unmount letsencrypt
|
||||
|
||||
storage:
|
||||
|
|
Loading…
Reference in New Issue