Skip to content

Commit

Permalink
feat: write canonical-facts file for yggd
Browse files Browse the repository at this point in the history
In order to correctly identify a yggd instance to console.redhat.com,
yggd needs to be told where to get canonical-facts. This timer writes
the output of canonical-facts to a path where yggd can be configured to
read it when it starts up.
  • Loading branch information
subpop authored and jirihnidek committed Sep 18, 2024
1 parent 436b9dd commit 17654f3
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions 80-rhc.preset
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enable rhc-canonical-facts.timer
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ DESTDIR ?=

# Dependent package directories
SYSTEMD_SYSTEM_UNIT_DIR := $(shell pkg-config --variable systemdsystemunitdir systemd)
SYSTEMD_SYSTEM_PRESET_DIR := $(shell pkg-config --variable systemdsystempresetdir systemd)

# Build flags
LDFLAGS :=
Expand Down Expand Up @@ -122,6 +123,9 @@ install: $(BIN) $(DATA)
install -D -m755 ./rhc $(DESTDIR)$(BINDIR)/$(SHORTNAME)
install -D -m644 ./rhc.1.gz $(DESTDIR)$(MANDIR)/man1/$(SHORTNAME).1.gz
install -D -m644 ./rhc.bash $(DESTDIR)$(DATADIR)/bash-completion/completions/$(SHORTNAME)
install -D -m644 ./rhc-canonical-facts.service $(DESTDIR)$(SYSTEMD_SYSTEM_UNIT_DIR)/rhc-canonical-facts.service
install -D -m644 ./rhc-canonical-facts.timer $(DESTDIR)$(SYSTEMD_SYSTEM_UNIT_DIR)/rhc-canonical-facts.timer
install -D -m644 ./80-rhc.preset $(DESTDIR)$(SYSTEMD_SYSTEM_PRESET_DIR)/80-rhc.preset

.PHONY: uninstall
uninstall:
Expand Down
12 changes: 12 additions & 0 deletions rhc-canonical-facts.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=rhc canonical-facts service
Documentation=https://github.com/RedHatInsights/rhc

[Service]
Type=oneshot
User=root
Group=yggdrasil-worker
ExecStart=rhc canonical-facts
StandardOutput=truncate:/var/lib/yggdrasil/canonical-facts.json
StandardError=journal
UMask=0027
10 changes: 10 additions & 0 deletions rhc-canonical-facts.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=yggdrasil canonical-facts service timer
Documentation=https://github.com/RedHatInsights/yggdrasil

[Timer]
OnCalendar=daily
Persistent=true

[Install]
WantedBy=timers.target
18 changes: 18 additions & 0 deletions rhc.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,29 @@ make PREFIX=%{_prefix} \
'PROVIDER=@PROVIDER@' \
install

%post
%systemd_post rhc-canonical-facts.timer
if [ $1 -eq 1 ]; then
systemctl daemon-reload
systemctl start rhc-canonical-facts.timer
fi

%preun
%systemd_preun rhc-canonical-facts.timer

%postun
%systemd_postun_with_restart rhc-canonical-facts.timer
if [ $1 -eq 0 ]; then
systemctl daemon-reload
fi

%files
%doc %{name}-%{version}/README.md
%{_bindir}/@SHORTNAME@
%{_datadir}/bash-completion/completions/*
%{_mandir}/man1/*
%{_unitdir}/*
%{_presetdir}/*


%changelog
Expand Down

0 comments on commit 17654f3

Please sign in to comment.