F #185: Recontextualizaton on vCenter

Periodically runs one-context-reconfigure to poll for changes
in vCenter context metadata to apply. Implemented via:

- systemd timer conditionally started only on vCenter
- cron job which checks for vmware and triggers service on non-systemd

Closes #185
pull/244/head
Vlastimil Holer 3 years ago
parent 7701d3a426
commit 70cf13f434
No known key found for this signature in database
GPG Key ID: EB549BADEFD07C53

@ -2,6 +2,7 @@
NETWORK=${NETWORK:-yes}
SERVICES=${SERVICES:-one-context-local one-context-online one-context}
TIMERS=${TIMERS:-one-context-reconfigure.timer}
rm -f /etc/udev/rules.d/70-persistent-cd.rules
rm -f /etc/udev/rules.d/70-persistent-net.rules
@ -18,8 +19,8 @@ if which systemctl >/dev/null 2>&1 && \
then
systemctl daemon-reload >/dev/null 2>&1 || :
for S in ${SERVICES}; do
systemctl enable "${S}.service" >/dev/null 2>&1
for S in ${SERVICES} ${TIMERS}; do
systemctl enable "${S}" >/dev/null 2>&1
done
fi
@ -47,6 +48,15 @@ elif which rc-update >/dev/null 2>&1; then
rc-update add "${S}" boot >/dev/null 2>&1
done
# Add crontab action for 1min schedules
if ! crontab -l -u root | grep -qF '/etc/periodic/1min'; then
(
crontab -l -u root
echo -e '\n# Added by one-context'
echo -e '* * * * * run-parts /etc/periodic/1min'
) | crontab -u root -
fi
# When existing file is changed, the new one might be created with
# .apk-new suffix. Such files need to be processed by update-conf.
if update-conf -al 2>/dev/null | grep -q context; then

@ -6,6 +6,7 @@ udevadm control --reload >/dev/null 2>&1 || :
### Enable services ########################################
SERVICES=${SERVICES:-one-context-local one-context-online one-context}
TIMERS=${TIMERS:-one-context-reconfigure.timer}
if which systemctl >/dev/null 2>&1 && \
[ -d /etc/systemd ] && \
@ -13,8 +14,8 @@ if which systemctl >/dev/null 2>&1 && \
then
systemctl daemon-reload >/dev/null 2>&1 || :
for S in ${SERVICES}; do
systemctl enable "${S}.service" >/dev/null 2>&1
for S in ${SERVICES} ${TIMERS}; do
systemctl enable "${S}" >/dev/null 2>&1
done
fi
@ -42,6 +43,15 @@ elif which rc-update >/dev/null 2>&1; then
rc-update add "${S}" boot >/dev/null 2>&1
done
# Add crontab action for 1min schedules
if ! crontab -l -u root | grep -qF '/etc/periodic/1min'; then
(
crontab -l -u root
echo -e '\n# Added by one-context'
echo -e '* * * * * run-parts /etc/periodic/1min'
) | crontab -u root -
fi
# When existing file is changed, the new one might be created with
# .apk-new suffix. Such files need to be processed by update-conf.
if update-conf -al 2>/dev/null | grep -q context; then

@ -1,12 +1,13 @@
#!/usr/bin/env bash
SERVICES=${SERVICES:-one-context one-context-online one-context-local}
SERVICES=${SERVICES:-one-context one-context-online one-context-local one-context-reconfigure one-context-reconfigure-delayed}
TIMERS=${TIMERS:-one-context-reconfigure.timer}
# Disable services
if which systemctl >/dev/null 2>&1 && [ -d /etc/systemd ]; then
for S in ${SERVICES}; do
systemctl --no-reload disable "${S}.service" >/dev/null 2>&1 || :
systemctl stop "${S}.service" >/dev/null 2>&1 || :
for S in ${TIMERS} ${SERVICES}; do
systemctl --no-reload disable "${S}" >/dev/null 2>&1 || :
systemctl stop "${S}" >/dev/null 2>&1 || :
done
fi

@ -0,0 +1,6 @@
# Periodically run one-context-reconfigure on VMware
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
MAILTO=''
* * * * * root if [ "$(virt-what 2>/dev/null)" = 'vmware' ]; then service one-context-reconfigure start >/dev/null 2>&1 || service one-context-reconfigure onestart >/dev/null 2>&1; fi

@ -0,0 +1,5 @@
#!/bin/sh
# Periodically run one-context-reconfigure on VMware
if [ "$(virt-what 2>/dev/null)" = 'vmware' ]; then
service one-context-reconfigure restart >/dev/null 2>&1
fi

@ -0,0 +1,11 @@
[Unit]
Description=Periodic OpenNebula reconfiguration
After=one-context.service
ConditionVirtualization=vmware
[Timer]
OnCalendar=*-*-* *:*:0
AccuracySec=1s
[Install]
WantedBy=timers.target

@ -21,8 +21,8 @@ case "${TARGET}" in
RELSUFFIX=${RELSUFFIX:-}
TYPE=${TYPE:-freebsd}
EXT=${EXT:-txz}
TAGS=${TAGS:-bsd bsd_rc one sysv}
DEPENDS=${DEPENDS:-sudo bash curl base64 ruby open-vm-tools-nox11 gawk}
TAGS=${TAGS:-bsd bsd_rc one sysv crond}
DEPENDS=${DEPENDS:-sudo bash curl base64 ruby open-vm-tools-nox11 gawk virt-what}
PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-addon-context}
CONFLICTS=${CONFLICTS:-${REPLACES} one-context-ec2}
@ -37,8 +37,8 @@ case "${TARGET}" in
NAME=${NAME:-one-context}
RELSUFFIX=${RELSUFFIX:-.el6}
TYPE=${TYPE:-rpm}
TAGS=${TAGS:-linux rpm sysv one network-scripts}
DEPENDS=${DEPENDS:-util-linux-ng bash curl bind-utils cloud-utils-growpart dracut-modules-growroot parted ruby rubygem-json sudo shadow-utils openssh-server open-vm-tools qemu-guest-agent gawk}
TAGS=${TAGS:-linux rpm sysv one network-scripts crond}
DEPENDS=${DEPENDS:-util-linux-ng bash curl bind-utils cloud-utils-growpart dracut-modules-growroot parted ruby rubygem-json sudo shadow-utils openssh-server open-vm-tools qemu-guest-agent gawk virt-what}
PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-cloud-init}
CONFLICTS=${CONFLICTS:-${REPLACES} one-context-ec2}
@ -53,7 +53,7 @@ case "${TARGET}" in
RELSUFFIX=${RELSUFFIX:-.el7}
TYPE=${TYPE:-rpm}
TAGS=${TAGS:-linux rpm systemd one network-scripts}
DEPENDS=${DEPENDS:-util-linux bash curl bind-utils cloud-utils-growpart parted ruby rubygem-json sudo shadow-utils openssh-server open-vm-tools qemu-guest-agent gawk}
DEPENDS=${DEPENDS:-util-linux bash curl bind-utils cloud-utils-growpart parted ruby rubygem-json sudo shadow-utils openssh-server open-vm-tools qemu-guest-agent gawk virt-what}
PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-cloud-init}
CONFLICTS=${CONFLICTS:-${REPLACES} one-context-ec2}
@ -68,7 +68,7 @@ case "${TARGET}" in
RELSUFFIX=${RELSUFFIX:-.el8}
TYPE=${TYPE:-rpm}
TAGS=${TAGS:-linux rpm systemd one network-scripts}
DEPENDS=${DEPENDS:-util-linux bash curl bind-utils cloud-utils-growpart parted ruby rubygem-json sudo shadow-utils openssh-server open-vm-tools qemu-guest-agent network-scripts gawk}
DEPENDS=${DEPENDS:-util-linux bash curl bind-utils cloud-utils-growpart parted ruby rubygem-json sudo shadow-utils openssh-server open-vm-tools qemu-guest-agent network-scripts gawk virt-what}
PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-cloud-init}
CONFLICTS=${CONFLICTS:-${REPLACES} one-context-ec2}
@ -83,7 +83,7 @@ case "${TARGET}" in
RELSUFFIX=${RELSUFFIX:-alt}
TYPE=${TYPE:-rpm}
TAGS=${TAGS:-linux rpm systemd one networkd}
DEPENDS=${DEPENDS:-bind-utils btrfs-progs cloud-utils-growpart curl e2fsprogs iproute2 openssl parted passwd qemu-guest-agent open-vm-tools ruby-json-pure sudo systemd-services wget which xfsprogs gawk}
DEPENDS=${DEPENDS:-bind-utils btrfs-progs cloud-utils-growpart curl e2fsprogs iproute2 openssl parted passwd qemu-guest-agent open-vm-tools ruby-json-pure sudo systemd-services wget which xfsprogs gawk virt-what}
PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-cloud-init}
CONFLICTS=${CONFLICTS:-${REPLACES} one-context-ec2}
@ -99,7 +99,7 @@ case "${TARGET}" in
RELSUFFIX=${RELSUFFIX:-.suse}
TYPE=${TYPE:-rpm}
TAGS=${TAGS:-linux rpm systemd one network-scripts}
DEPENDS=${DEPENDS:-util-linux bash curl bind-utils growpart parted parted ruby sudo shadow openssh open-vm-tools qemu-guest-agent gawk} # rubygem-json}
DEPENDS=${DEPENDS:-util-linux bash curl bind-utils growpart parted parted ruby sudo shadow openssh open-vm-tools qemu-guest-agent gawk virt-what} # rubygem-json}
PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-cloud-init cloud-init-config-suse}
CONFLICTS=${CONFLICTS:-${REPLACES} one-context-ec2}
@ -114,7 +114,7 @@ case "${TARGET}" in
RELSUFFIX=${RELSUFFIX:-}
TYPE=${TYPE:-deb}
TAGS=${TAGS:-linux deb sysv systemd upstart one}
DEPENDS=${DEPENDS:-util-linux bash curl bind9-host cloud-utils parted ruby ifupdown|ifupdown2 acpid sudo passwd dbus openssh-server open-vm-tools qemu-guest-agent gawk}
DEPENDS=${DEPENDS:-util-linux bash curl bind9-host cloud-utils parted ruby ifupdown|ifupdown2 acpid sudo passwd dbus openssh-server open-vm-tools qemu-guest-agent gawk virt-what}
PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-cloud-init}
CONFLICTS=${CONFLICTS:-${REPLACES} one-context-ec2}
@ -129,7 +129,7 @@ case "${TARGET}" in
RELSUFFIX=${RELSUFFIX:-}
TYPE=${TYPE:-apk}
TAGS=${TAGS:-linux apk one}
DEPENDS=${DEPENDS:-util-linux bash curl udev sfdisk parted e2fsprogs-extra sudo shadow ruby ruby-json bind-tools openssh open-vm-tools qemu-guest-agent gawk}
DEPENDS=${DEPENDS:-util-linux bash curl udev sfdisk parted e2fsprogs-extra sudo shadow ruby ruby-json bind-tools openssh open-vm-tools qemu-guest-agent gawk virt-what}
PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-} #not respected
CONFLICTS=${CONFLICTS:-one-context-ec2}
@ -151,7 +151,7 @@ case "${TARGET}" in
EXT=${EXT:-pkg.tar.xz}
TAGS=${TAGS:-linux arch systemd one networkd}
# mkinitcpio-growrootfs ruby-json
DEPENDS=${DEPENDS:-filesystem util-linux bash curl bind-tools ruby sudo shadow open-vm-tools qemu-guest-agent gawk}
DEPENDS=${DEPENDS:-filesystem util-linux bash curl bind-tools ruby sudo shadow open-vm-tools qemu-guest-agent gawk virt-what}
PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-cloud-init}
CONFLICTS=${CONFLICTS:-${REPLACES} one-context-ec2}

Loading…
Cancel
Save