Flatten directory structures
This commit contains a fairly large diff for a fairly small change: moving the `config/common` directory to `host/base` to better reflect its intended use, and promoting `config/service` to the root directory. These changes unlock some improvements in `coreos-home-server-update` processes, which will (assuming `/etc/coreos-home-server/base` exists) keep host-wide systemd services in sync in addition to service-specific ones. Changes have been make to the `Makefile` and a few other places where `config/common` was referenced, but most of this work is renames that are not intended to break compatibility with new or running servers.
This commit is contained in:
parent
9dc5c6aaee
commit
f877a72e83
32
Makefile
32
Makefile
|
@ -20,27 +20,27 @@ VIRTINSTALL ?= $(call find-cmd,virt-install) --connect=qemu:///system
|
|||
NC ?= $(call find-cmd,nc) -vv -r -l
|
||||
|
||||
## Builds and deploys Fedora CoreOS for HOST on ADDRESS.
|
||||
deploy: $(TMPDIR)host/$(HOST)/spec.ign
|
||||
deploy: $(TMPDIR)deploy/host/$(HOST)/spec.ign
|
||||
@printf "Serving Ignition config '$<' over HTTP...\n"
|
||||
@printf 'HTTP/1.0 200 OK\r\nContent-Length: %d\r\n\r\n%s\n' "$$(wc -c < $<)" "$$(cat $<)" | $(NC) -s $(ADDRESS) || exit 0
|
||||
|
||||
## Prepares and deploys CoreOS release for local, virtual environment.
|
||||
deploy-virtual: $(TMPDIR)images/fedora-coreos-$(VERSION)-qemu.$(ARCH).qcow2.xz $(TMPDIR)host/$(HOST)/spec.ign
|
||||
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 \
|
||||
--graphics=none --vcpus=2 --memory=2048 \
|
||||
--disk="size=10,backing_store=$(TMPDIR)images/fedora-coreos-$(VERSION)-qemu.$(ARCH).qcow2" \
|
||||
--qemu-commandline="-fw_cfg name=opt/com.coreos/config,file=$(TMPDIR)host/$(HOST)/spec.ign"
|
||||
--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
|
||||
|
||||
## Remove configuration files required for build.
|
||||
## Remove deployment configuration files required for build.
|
||||
clean:
|
||||
@printf "Removing configuration files...\n"
|
||||
$Q rm -Rf $(TMPDIR)config $(TMPDIR)host
|
||||
@printf "Removing deployment configuration files...\n"
|
||||
$Q rm -Rf $(TMPDIR)deploy
|
||||
|
||||
## Remove all temporary files required for build.
|
||||
purge:
|
||||
|
@ -57,30 +57,30 @@ help:
|
|||
@printf "\n"
|
||||
|
||||
# Copy host configuration in plain-text. Mainly used for development hosts.
|
||||
$(TMPDIR)config/$(HOST).env: $(ROOTDIR)host/$(HOST)/$(HOST).env
|
||||
$(TMPDIR)deploy/$(HOST).env: $(ROOTDIR)host/$(HOST)/$(HOST).env
|
||||
$Q install -d $(@D)
|
||||
$Q cp -f $< $@
|
||||
|
||||
# Copy encrypted host configuration. Used in production hosts.
|
||||
$(TMPDIR)config/$(HOST).env.gpg: $(ROOTDIR)host/$(HOST)/$(HOST).env.gpg
|
||||
$(TMPDIR)deploy/$(HOST).env.gpg: $(ROOTDIR)host/$(HOST)/$(HOST).env.gpg
|
||||
@printf "Waiting to decrypt configuration for '$(HOST)'...\n"
|
||||
$Q install -d $(@D)
|
||||
$Q $(GPG) -o $@ --decrypt $<
|
||||
|
||||
# Copy directory tree if any of the files within are newer than the target directory.
|
||||
$(TMPDIR)config/%/: $(shell find $(ROOTDIR)config/$* -type f -newer $(TMPDIR)config/$* 2>/dev/null)
|
||||
$(TMPDIR)deploy/%/: $(shell find $(ROOTDIR)$* -type f -newer $(TMPDIR)deploy/$* 2>/dev/null)
|
||||
$Q install -d $(dir $(@D))
|
||||
$Q cp -Ru $(if $(VERBOSE),-v) $(ROOTDIR)config/$* $(dir $(@D))
|
||||
$Q cp -Ru $(if $(VERBOSE),-v) $(ROOTDIR)$* $(dir $(@D))
|
||||
$Q touch $(@D)
|
||||
|
||||
# Copy specific file if source file is newer.
|
||||
$(TMPDIR)config/%: $(ROOTDIR)config/%
|
||||
$(TMPDIR)deploy/%: $(ROOTDIR)%
|
||||
$Q install $(if $(VERBOSE),-v) -D $< $@
|
||||
|
||||
# Compile Ignition file from Butane configuration file.
|
||||
$(TMPDIR)%.ign: $(ROOTDIR)%.bu
|
||||
$(TMPDIR)deploy/%.ign: $(ROOTDIR)%.bu
|
||||
$Q install -d $(@D)
|
||||
$Q $(BUTANE) --pretty --strict --files-dir $(TMPDIR)config -o $@ $<
|
||||
$Q $(BUTANE) --pretty --strict --files-dir $(TMPDIR)deploy -o $@ $<
|
||||
|
||||
# Download and, optionally, extract Fedora CoreOS installation image.
|
||||
$(TMPDIR)images/fedora-coreos-$(VERSION)-%:
|
||||
|
@ -95,13 +95,13 @@ $(TMPDIR)images/fedora-coreos-$(VERSION)-%:
|
|||
# Generate Makefile dependencies from `local:` definitions in BUTANE files.
|
||||
$(TMPDIR)make.depend: $(shell find $(ROOTDIR) -name '*.bu' -type f 2>/dev/null)
|
||||
@printf "# Automatic prerequisites for Fedora CoreOS configuration." > $@
|
||||
@printf "$(foreach i,$^,\n$(patsubst $(ROOTDIR)%.bu,$(TMPDIR)%.ign, \
|
||||
$(i)): $(addprefix $(TMPDIR)config/, $(shell awk -F '[ ]+local:[ ]*' '/^[ ]+(-[ ]+)?local:/ {print $$2}' $(i))))" >> $@
|
||||
@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:
|
||||
@printf "Invalid target '$@'...\n"
|
||||
$Q $(MAKE) -s -f $(firstword $(MAKEFILE_LIST)) help
|
||||
@printf "Invalid target '$@', stopping.\n"; exit 1
|
||||
|
||||
.PHONY: deploy deploy-virtual destroy-virtual clean purge help
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ In addition to host-specific configuration, servers will typically include a num
|
|||
managed by `systemd` and `podman`. These are intended to be deployed via Ignition on server setup,
|
||||
but also be managed throughout the server's life-cycle.
|
||||
|
||||
Check the [service documentation](config/service/README.md) for more information.
|
||||
Check the [service documentation](service/README.md) for more information.
|
||||
|
||||
## License
|
||||
|
||||
|
|
|
@ -4,8 +4,10 @@ storage:
|
|||
trees:
|
||||
- path: /etc/coreos-home-server
|
||||
local: service/
|
||||
- path: /etc/coreos-home-server/base
|
||||
local: host/base/
|
||||
- path: /etc/systemd/system
|
||||
local: common/systemd/
|
||||
local: host/base/systemd/
|
||||
directories:
|
||||
- path: /etc/coreos-home-server
|
||||
mode: 0700
|
||||
|
@ -13,7 +15,7 @@ storage:
|
|||
- path: /etc/containers/containers.conf
|
||||
mode: 0644
|
||||
contents:
|
||||
local: common/container/containers.conf
|
||||
local: host/base/service/containers.conf
|
||||
systemd:
|
||||
units:
|
||||
- name: coreos-home-server-update.timer
|
|
@ -19,7 +19,7 @@ function sync-coreos-config() {
|
|||
local path="$1"
|
||||
|
||||
# Search for configuration in any of the local configuration sub-directories.
|
||||
for dir in "$TEMP_CONFIG_PATH"/config/*/"$(basename "$path")"; do
|
||||
for dir in "$TEMP_CONFIG_PATH"/*/"$(basename "$path")"; do
|
||||
if test ! -d "$dir"; then
|
||||
printf "configuration not found, skipping.\n"
|
||||
return
|
|
@ -9,7 +9,7 @@ SyslogIdentifier=%N
|
|||
PrivateTmp=true
|
||||
Environment=GIT_REMOTE_URL=https://github.com/deuill/coreos-home-server.git
|
||||
ExecStartPre=/usr/bin/git clone --verbose -- $GIT_REMOTE_URL %T/coreos-home-server
|
||||
ExecStart=/bin/bash %T/coreos-home-server/hooks/post-merge
|
||||
ExecStart=/bin/bash %T/coreos-home-server/host/base/service/%N
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -3,8 +3,8 @@ version: 1.3.0
|
|||
ignition:
|
||||
config:
|
||||
merge:
|
||||
- local: common/common.ign
|
||||
- local: common/logging.ign
|
||||
- local: host/base/container.ign
|
||||
- local: host/base/logging.ign
|
||||
- local: service/redis/spec.ign
|
||||
- local: service/mariadb/spec.ign
|
||||
- local: service/nginx/spec.ign
|
||||
|
|
|
@ -3,8 +3,8 @@ version: 1.3.0
|
|||
ignition:
|
||||
config:
|
||||
merge:
|
||||
- local: common/common.ign
|
||||
- local: common/logging.ign
|
||||
- local: host/base/container.ign
|
||||
- local: host/base/logging.ign
|
||||
- local: service/redis/spec.ign
|
||||
- local: service/mariadb/spec.ign
|
||||
- local: service/nginx/spec.ign
|
||||
|
|
|
@ -3,8 +3,8 @@ version: 1.3.0
|
|||
ignition:
|
||||
config:
|
||||
merge:
|
||||
- local: common/common.ign
|
||||
- local: common/logging.ign
|
||||
- local: host/base/container.ign
|
||||
- local: host/base/logging.ign
|
||||
- local: service/redis/spec.ign
|
||||
- local: service/mariadb/spec.ign
|
||||
- local: service/nginx/spec.ign
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue