Compare commits

...

11 Commits

Author SHA1 Message Date
Neil Hanlon d06a66d0f0
make it work for rocky 2023-11-15 11:43:48 -07:00
Zuul 0576fadab8 Merge "Stop creating default user for cloud-init" 2023-10-12 20:53:57 +00:00
Zuul 87e2321d55 Merge "Change default value of DIB_DEBIAN_ALT_INIT_PACKAGE" 2023-10-12 20:53:55 +00:00
Dmitriy Rabotyagov cff37ce502 Stop creating default user for cloud-init
All relatively modern cloud-inits are capable of creating default user
as well as granting root privileges for them. Currently
cloud-init creates pretty much the same sudoers file.
So running steps under the new DIB_DEBIAN_CLOUD_INIT_HELPER
does not make sense for last couple of Debian releases.

Change-Id: I3cebd318f1f0313bba00ecf639328978d3ad0f32
2023-10-10 16:04:31 +00:00
Zuul 64a38a518d Merge "Set grub timeout style" 2023-09-20 23:09:34 +00:00
Zuul 4c4bb801ae Merge "Refactor cloud-init element" 2023-09-20 23:09:32 +00:00
Zuul 4f9ef195e3 Merge "Remove extra spaces from GRUB_CMDLINE_LINUX_DEFAULT" 2023-09-20 23:09:29 +00:00
Clark Boylan 252692c660 Update bindep rules for Debuntu
This was precipitated by nodepool switching its image builds to Debian
Bookworm. This caused sibling jobs between nodepool and dib (and others)
to fail because python-lzma and yum-utils could not be installed on
Bookworm.

In order to make this more future proof we reorganize some of the bindep
rules so that they match (or negative match) on static lists of things
which should allow new releases of Ubuntu and Debian to function without
updating the rules again.

Change-Id: I00b099daea099b9de5ee4b563ca7e401b0f856f3
2023-09-18 08:25:21 -07:00
Maksim Malchuk 4fbf564615 Set grub timeout style
Set the grub timeout style to display the menu. By default it set to
'hidden' but can be changed to 'menu' to display the menu and then
wait for the timeout expire before booting the default entry.

Change-Id: I8c58407ef645d528dd77efe866bfe0389cbbbd33
Signed-off-by: Maksim Malchuk <maksim.malchuk@gmail.com>
2023-09-15 20:31:26 +00:00
Maksim Malchuk bccea6d5f0 Refactor cloud-init element
There is no need in pipe and sudo for changing /etc/cloud/cloud.cfg

TrivialFix

Change-Id: I905e8d3964f1322ec3ccc2eb09c517a02ef88044
Signed-off-by: Maksim Malchuk <maksim.malchuk@gmail.com>
2023-09-15 20:31:12 +00:00
Dmitriy Rabotyagov 335f8dc6fd Change default value of DIB_DEBIAN_ALT_INIT_PACKAGE
For quite a while Debian is shipped with systemd-sysv
by default. However, default value of DIB_DEBIAN_ALT_INIT_PACKAGE
is not in sync across elements. We change a default now for
the `debian` element along with removing `apt_get_bp_extra_opts`
that is not defined or used anywhere else.

Change-Id: If5d3f0a21467f926c23bb39a1853be73befa768e
2023-08-31 19:20:29 +02:00
12 changed files with 79 additions and 17 deletions

View File

@ -20,15 +20,16 @@ gnupg2 [!platform:redhat !platform:ubuntu-trusty !platform:suse]
# ubuntu
apt-transport-https [platform:dpkg]
inetutils-ping [platform:dpkg]
python-lzma [platform:dpkg !platform:ubuntu-focal !platform:ubuntu-jammy !platform:debian-bullseye]
qemu-utils [platform:dpkg]
rpm [platform:dpkg]
uuid-runtime [platform:dpkg]
yum-utils [platform:dpkg !platform:ubuntu-focal !platform:ubuntu-jammy !platform:debian-bullseye]
dnf [platform:debian-bullseye]
debootstrap [platform:dpkg]
zstd [platform:dpkg]
procps [platform:dpkg]
# Version/distro specific items
python-lzma [platform:ubuntu-bionic platform:debian-buster]
yum-utils [platform:ubuntu-bionic platform:debian-buster]
dnf [platform:dpkg !platform:debian-buster !platform:ubuntu-trusty !platform:ubuntu-bionic !platform:ubuntu-focal]
# centos/fedora
qemu-img [platform:redhat]

View File

@ -10,6 +10,11 @@ Arguments
* ``DIB_GRUB_TIMEOUT`` sets the ``grub`` menu timeout. It defaults to
5 seconds. Set this to 0 (no timeout) for fast boot times.
* ``DIB_GRUB_TIMEOUT_STYLE`` sets the visibility of the ``grub`` menu.
It defaults to ``hidden`` (or ``countdown`` as an alias). Set this to
``menu`` to display the menu and then wait for the timeout set by
``DIB_GRUB_TIMEOUT`` to expire before booting the default entry.
* ``DIB_BOOTLOADER_DEFAULT_CMDLINE`` sets parameters that are appended
to the ``GRUB_CMDLINE_LINUX_DEFAULT`` values in ``grub.cfg``
configuration. It defaults to ``nofb nomodeset gfxpayload=text``.

View File

@ -85,6 +85,7 @@ fi
echo "GRUB_DEVICE=LABEL=${DIB_ROOT_LABEL}" >> /etc/default/grub
echo 'GRUB_DISABLE_LINUX_UUID=true' >> /etc/default/grub
echo "GRUB_TIMEOUT=${DIB_GRUB_TIMEOUT:-5}" >>/etc/default/grub
echo "GRUB_TIMEOUT_STYLE=${DIB_GRUB_TIMEOUT_STYLE:-hidden}" >>/etc/default/grub
echo 'GRUB_TERMINAL="serial console"' >>/etc/default/grub
echo 'GRUB_GFXPAYLOAD_LINUX=auto' >>/etc/default/grub

View File

@ -9,9 +9,9 @@ set -o pipefail
# Set cloud-init to allow password authentication
if [ -n "${DIB_CLOUD_INIT_ALLOW_SSH_PWAUTH:-}" ]; then
if [ -f "/etc/cloud/cloud.cfg" ]; then
if [ -z "$(cat /etc/cloud/cloud.cfg | grep ssh_pwauth)" ]; then
if [ -z "$(grep ssh_pwauth /etc/cloud/cloud.cfg)" ]; then
echo "ssh_pwauth not exist. append to EOF"
sudo sh -c 'echo "ssh_pwauth: 1" >> /etc/cloud/cloud.cfg'
echo "ssh_pwauth: 1" >> /etc/cloud/cloud.cfg
else
echo "ssh_pwauth exist. make sure ssh_pwauth enabled"
sed -i -e 's/ssh_pwauth: *0/ssh_pwauth: 1/g' /etc/cloud/cloud.cfg

View File

@ -21,20 +21,29 @@ fi
set -eu
set -o pipefail
DIB_DEBIAN_ALT_INIT_PACKAGE=${DIB_DEBIAN_ALT_INIT_PACKAGE:-sysvinit}
case "${DIB_RELEASE}" in
hamm|slink|potato|woody|sarge|etch|lenny|squeeze|wheezy)
DIB_DEBIAN_ALT_INIT_PACKAGE=${DIB_DEBIAN_ALT_INIT_PACKAGE:-sysvinit}
DIB_DEBIAN_CLOUD_INIT_HELPER=${DIB_DEBIAN_CLOUD_INIT_HELPER:-'true'}
;;
*)
DIB_DEBIAN_ALT_INIT_PACKAGE=${DIB_DEBIAN_ALT_INIT_PACKAGE:-systemd-sysv}
;;
esac
adduser --gecos Debian-cloud-init-user --disabled-password --quiet debian
install -d -m 0755 -o root -g root /etc/sudoers.d
echo 'debian ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/debian-cloud-init
chmod 0440 /etc/sudoers.d/debian-cloud-init
if [ -n "${DIB_DEBIAN_CLOUD_INIT_HELPER:-}" ]; then
adduser --gecos Debian-cloud-init-user --disabled-password --quiet debian
install -d -m 0755 -o root -g root /etc/sudoers.d
echo 'debian ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/debian-cloud-init
chmod 0440 /etc/sudoers.d/debian-cloud-init
fi
if [ "$DIB_DEBIAN_ALT_INIT_PACKAGE" != "sysvinit" ]; then
# To avoid a conflict against an essential package, we need to remove sysvinit first
dpkg --purge --force remove-essential sysvinit
apt-get install -y $apt_get_bp_extra_opts $DIB_DEBIAN_ALT_INIT_PACKAGE
printf \"Package: sysvinit\nPin: origin ""\nPin-Priority: -1\n\" > \
/etc/apt/preferences.d/sysvinit > /etc/apt/preferences.d/sysvinit
apt-get install -y $DIB_DEBIAN_ALT_INIT_PACKAGE
printf "Package: sysvinit\nPin: origin \"\"\nPin-Priority: -1\n" > \
/etc/apt/preferences.d/sysvinit
fi
case "${DIB_RELEASE}" in

View File

@ -20,7 +20,7 @@
},
"family": {
"redhat": {
"lsb_release": "redhat-lsb-core"
"lsb_release": "ed hostname patch postfix tar time"
}
}
}

View File

@ -88,6 +88,8 @@ function _install_repos {
if [[ ${DISTRO_NAME} = fedora ]]; then
packages+="fedora-release-cloud fedora-release-common "
packages+="fedora-repos fedora-gpg-keys"
elif [[ ${DISTRO_NAME} = rocky ]]; then
packages+="rocky-release rocky-repos rocky-gpg-keys"
elif [[ ${DISTRO_NAME} = centos && ${DIB_RELEASE%-stream} -gt 7 ]]; then
packages+="centos-gpg-keys "
if [[ "$DIB_RELEASE" =~ (stream) ]]; then
@ -167,6 +169,8 @@ function _install_repos {
if [[ ${DISTRO_NAME} == 'openeuler' ]]; then
sudo sed -i 's/enabled=0/enabled=1/' $TARGET_ROOT/etc/yum.repos.d/*.repo
fi
}
# _install_pkg_manager packages...
@ -211,7 +215,8 @@ function _install_pkg_manager {
local _extra_pkgs=""
if [[ $DISTRO_NAME == "fedora" ]] || \
[[ $DISTRO_NAME == "centos" && $DIB_RELEASE > "7" ]]; then
[[ $DISTRO_NAME == "centos" && $DIB_RELEASE > "7" ]] || \
[[ $DISTRO_NAME == 'rocky' ]]; then
# glibc from F24 onwards has split locales into "langpack"
# packages. Host yum doesn't understand the
# weak-dependencies glibc now uses to get the
@ -238,6 +243,10 @@ function _install_pkg_manager {
sudo ln -s $TARGET_ROOT/etc/dnf/vars $TARGET_ROOT/etc/yum/vars
fi
if [[ ${DISTRO_NAME} == 'rocky' ]]; then
echo 'stg/rocky' | sudo tee /etc/dnf/vars/contentdir
fi
sudo -E ${HOST_YUM} -y \
--disableexcludes=all \
--setopt=cachedir=$YUM_CACHE/$ARCH/$DIB_RELEASE \
@ -308,7 +317,7 @@ _install_repos
# it seems, as it seems like as part of the Fedora modular updates
# (https://docs.fedoraproject.org/en-US/modularity/) we can pick up
# seemingly mismatched libraries.
if [[ ${DISTRO_NAME} =~ (fedora|openeuler) ]]; then
if [[ ${DISTRO_NAME} =~ (fedora|openeuler|rocky) ]]; then
_install_pkg_manager dnf dnf-plugins-core curl
elif [[ ${DISTRO_NAME} == centos && $DIB_RELEASE > "7" ]]; then
_install_pkg_manager dnf dnf-plugins-core curl libcurl
@ -343,6 +352,10 @@ if [[ ${DISTRO_NAME} = centos && ${DIB_RELEASE%-stream} -le 7 ]]; then
YUM="${YUM} --releasever=${DIB_RELEASE}"
fi
if [[ ${DISTRO_NAME} == 'rocky' ]]; then
YUM="DNF_VAR_contentdir=stg/rocky ${YUM}"
fi
# we just installed yum/dnf with "outside" tools (yum/rpm) which
# might have created /var/lib/[yum|rpm] (etc) that are slighlty
# incompatible. Refresh everything with the in-chroot tools

View File

@ -134,6 +134,10 @@ if [ -n "$WHITELIST" ]; then
#
# [1] https://bugzilla.redhat.com/show_bug.cgi?id=965567
set -o xtrace
if [[ -n ${DIB_YUM_DNF_CONTENTDIR:-''} ]]; then
echo $DIB_YUM_DNF_CONTENTDIR | sudo tee /etc/dnf/vars/contentdir
sudo sed -i -e 's,^mirrorlist,#mirrorlist,' -e 's,^#baseurl,baseurl,' /etc/yum.repos.d/*.repo
fi
${YUM} -v -y $ACTION $EXTRA_ARGS $PKGS
if [ "$ACTION" == "install" ]; then

View File

@ -6,6 +6,11 @@ fi
set -eu
set -o pipefail
# if [[ -n ${DIB_YUM_DNF_CONTENTDIR:-''} ]]; then
# sudo sed -i 's,^#mirrorlist,mirrorlist,' -e 's,^baseurl,#baseurl,' /etc/yum.repos.d/rocky.repo
# fi
if [[ ${YUM} == "dnf" ]]; then
cfg=/etc/dnf/dnf.conf
cachedir=/var/cache/dnf

View File

@ -0,0 +1,8 @@
---
other:
- |
Added a ``DIB_DEBIAN_CLOUD_INIT_HELPER`` variable that controls whether
``debian`` element will attempt to pre-create required users and sudoers
file for the default cloud-init user. This should not be needed for any
modern Debian distro.

View File

@ -0,0 +1,9 @@
---
other:
- |
Value of ``DIB_DEBIAN_ALT_INIT_PACKAGE`` has been switched to
``systemd-sysv`` for Debian releases older then Jessie.
If you still need to build a version of Debian that is relying
on ``sysvinit`` please override the ``DIB_DEBIAN_ALT_INIT_PACKAGE``
variable for that.

View File

@ -0,0 +1,7 @@
---
features:
- |
The ``bootloader`` element will explicitly set the timeout style to
``hidden`` to hide the menu. Set ``DIB_GRUB_TIMEOUT_STYLE`` to ``menu``
to display the menu and then wait for the timeout expire before booting
the default entry.