Generate fedora-atomic images using dib
It consumes an external deployed tree, and generates a cloud bootable image based on that. It relies on lvm element to generate the volumes needed for the image. Change-Id: Ie681064d799279519adcc8e1bcf7a61ff9120042
This commit is contained in:
parent
38fef24416
commit
e2def6f8d3
|
@ -0,0 +1,67 @@
|
||||||
|
=============
|
||||||
|
fedora-atomic
|
||||||
|
=============
|
||||||
|
|
||||||
|
Generates a Fedora Atomic image based on a public deployed tree. This element has been tested under Debian, Ubuntu, CentOS and Fedora operating systems.
|
||||||
|
|
||||||
|
Pre-requisites to run diskimage-builder
|
||||||
|
---------------------------------------
|
||||||
|
For diskimage-builder to work, following packages need to be
|
||||||
|
present:
|
||||||
|
|
||||||
|
* python-dev
|
||||||
|
* build-essential
|
||||||
|
* python-pip
|
||||||
|
* kpartx
|
||||||
|
* python-lzma
|
||||||
|
* qemu-utils
|
||||||
|
* yum
|
||||||
|
* yum-utils
|
||||||
|
* python-yaml
|
||||||
|
|
||||||
|
For Debian/Ubuntu systems, use::
|
||||||
|
|
||||||
|
apt-get install python-dev build-essential python-pip kpartx python-lzma qemu-utils yum yum-utils python-yaml
|
||||||
|
|
||||||
|
For CentOS and Fedora < 22, use::
|
||||||
|
|
||||||
|
yum install python-dev build-essential python-pip kpartx python-lzma qemu-utils yum yum-utils python-yaml
|
||||||
|
|
||||||
|
For Fedora >= 22, use::
|
||||||
|
|
||||||
|
dnf install python-dev build-essential python-pip kpartx python-lzma qemu-utils yum yum-utils python-yaml
|
||||||
|
|
||||||
|
diskimage-builder can be installed using pip::
|
||||||
|
|
||||||
|
pip install diskimage-builder
|
||||||
|
|
||||||
|
How to generate Fedora Atomic image
|
||||||
|
-----------------------------------
|
||||||
|
To generate an atomic image for Fedora 23 these commands can be
|
||||||
|
executed::
|
||||||
|
|
||||||
|
export ELEMENTS_PATH=/path/to/diskimage-builder/elements:/path/to/magnum/elements
|
||||||
|
export DIB_RELEASE=23 # this can be switched to the desired version
|
||||||
|
export DIB_IMAGE_SIZE=2 # we need to give a bit more space to loopback device
|
||||||
|
disk-image-create fedora-atomic
|
||||||
|
|
||||||
|
This element can consume already published trees, but you can use it
|
||||||
|
to consume your own generated trees. Documentation about creating own trees
|
||||||
|
can be found at `http://developers.redhat.com/blog/2015/01/08/creating-custom-atomic-trees-images-and-installers-part-1/ <http://developers.redhat.com/blog/2015/01/08/creating-custom-atomic-trees-images-and-installers-part-1/>`_
|
||||||
|
|
||||||
|
Environment Variables
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
To properly reference the tree, the following env vars can be set:
|
||||||
|
|
||||||
|
FEDORA_ATOMIC_TREE_URL
|
||||||
|
:Required: Yes
|
||||||
|
:Description: Url for the public fedora-atomic tree to use. It can
|
||||||
|
reference to own published trees.
|
||||||
|
:Default: `https://dl.fedoraproject.org/pub/fedora/linux/atomic/23/ <https://dl.fedoraproject.org/pub/fedora/linux/atomic/23/>`_
|
||||||
|
|
||||||
|
|
||||||
|
FEDORA_ATOMIC_TREE_REF
|
||||||
|
:Required: Yes
|
||||||
|
:Description: Reference of the tree to install.
|
||||||
|
:Default: 954bdbeebebfa87b625d9d7bd78c81400bdd6756fcc3205987970af4b64eb678
|
|
@ -0,0 +1,4 @@
|
||||||
|
fedora-minimal
|
||||||
|
growroot
|
||||||
|
package-installs
|
||||||
|
vm
|
|
@ -0,0 +1,2 @@
|
||||||
|
export FEDORA_ATOMIC_TREE_URL=${FEDORA_ATOMIC_TREE_URL:-https://dl.fedoraproject.org/pub/fedora/linux/atomic/23/}
|
||||||
|
export FEDORA_ATOMIC_TREE_REF=${FEDORA_ATOMIC_TREE_REF:-954bdbeebebfa87b625d9d7bd78c81400bdd6756fcc3205987970af4b64eb678}
|
|
@ -0,0 +1,73 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
|
||||||
|
set -x
|
||||||
|
fi
|
||||||
|
set -eu
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
# generate ostree in root
|
||||||
|
cd /
|
||||||
|
ostree admin os-init fedora-atomic
|
||||||
|
ostree remote add --set=gpg-verify=false fedora-atomic ${FEDORA_ATOMIC_TREE_URL}
|
||||||
|
ostree pull fedora-atomic ${FEDORA_ATOMIC_TREE_REF}
|
||||||
|
ostree remote delete fedora-atomic
|
||||||
|
ostree admin deploy --os=fedora-atomic ${FEDORA_ATOMIC_TREE_REF} --karg-proc-cmdline --karg=selinux=0
|
||||||
|
|
||||||
|
# copy /etc/fstab to the deployed directory
|
||||||
|
SYSROOT=/ostree/deploy/fedora-atomic/deploy/${FEDORA_ATOMIC_TREE_REF}.0
|
||||||
|
cp /etc/fstab $SYSROOT/etc/
|
||||||
|
|
||||||
|
# need to find the generated images
|
||||||
|
DEPLOYED_DIRECTORY=$(find /boot/ostree -name fedora-atomic-* -type d)
|
||||||
|
DEPLOYED_ID=${DEPLOYED_DIRECTORY##*-}
|
||||||
|
INIT_IMAGE=$(find ${DEPLOYED_DIRECTORY} -name initramfs*.img)
|
||||||
|
|
||||||
|
# generate ostree boot
|
||||||
|
cat > /etc/grub.d/15_ostree <<EOF
|
||||||
|
cat <<EOL
|
||||||
|
menuentry 'Fedora 23 (ostree)' --class gnu-linux --class gnu --class os --unrestricted "ostree-0-${DIB_IMAGE_ROOT_FS_UUID}" {
|
||||||
|
set gfxpayload=text
|
||||||
|
insmod gzio
|
||||||
|
insmod part_msdos
|
||||||
|
insmod ext2
|
||||||
|
search --no-floppy --set=root --label ${DIB_ROOT_LABEL}
|
||||||
|
linux16 ${DEPLOYED_DIRECTORY}/vmlinuz root=LABEL=${DIB_ROOT_LABEL} ro nofb nomodeset vga=normal console=tty0 console=ttyS0,115200 no_timer_check rd.shell=0 ostree=/ostree/boot.1/fedora-atomic/${DEPLOYED_ID}/0
|
||||||
|
initrd16 ${INIT_IMAGE}
|
||||||
|
}
|
||||||
|
EOL
|
||||||
|
EOF
|
||||||
|
chmod +x /etc/grub.d/15_ostree
|
||||||
|
|
||||||
|
# start cloud-init on boot
|
||||||
|
ln -sf $SYSROOT/usr/lib/systemd/system/cloud-config.service $SYSROOT/etc/systemd/system/multi-user.target.wants/cloud-config.service
|
||||||
|
ln -sf $SYSROOT/usr/lib/systemd/system/cloud-final.service $SYSROOT/etc/systemd/system/multi-user.target.wants/cloud-final.service
|
||||||
|
ln -sf $SYSROOT/usr/lib/systemd/system/cloud-init.service $SYSROOT/etc/systemd/system/multi-user.target.wants/cloud-init.service
|
||||||
|
ln -sf $SYSROOT/usr/lib/systemd/system/cloud-init-local.service $SYSROOT/etc/systemd/system/multi-user.target.wants/cloud-init-local.service
|
||||||
|
|
||||||
|
# update docker configuration
|
||||||
|
cat > $SYSROOT/etc/sysconfig/docker-storage <<EOF
|
||||||
|
DOCKER_STORAGE_OPTIONS="--storage-opt dm.thinpooldev=/dev/mapper/docker-docker--pool"
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# disabled docker-storage-setup
|
||||||
|
rm $SYSROOT/etc/systemd/system/multi-user.target.wants/docker-storage-setup.service
|
||||||
|
|
||||||
|
# remove previous entry and generate config
|
||||||
|
rm /etc/grub.d/10_linux
|
||||||
|
grub2-mkconfig -o /boot/grub2/grub.cfg
|
||||||
|
|
||||||
|
# remove non usable images
|
||||||
|
rm -rf /boot/vmlinuz*
|
||||||
|
rm -rf /boot/initramfs*
|
||||||
|
|
||||||
|
# image cleanup
|
||||||
|
if [ $DIB_RELEASE -ge 22 ]; then
|
||||||
|
dnf -y remove dracut grubby kernel initscript man-pages redhat-lsb-core selinux-policy selinux-policy-targeted
|
||||||
|
dnf autoremove
|
||||||
|
dnf clean all
|
||||||
|
else
|
||||||
|
yum -y remove dracut grubby kernel initscript man-pages redhat-lsb-core selinux-policy selinux-policy-targeted
|
||||||
|
yum autoremove
|
||||||
|
yum clean all
|
||||||
|
fi
|
|
@ -0,0 +1,2 @@
|
||||||
|
# Install packages needed for atomic
|
||||||
|
ostree:
|
Loading…
Reference in New Issue