Skip to content

Instantly share code, notes, and snippets.

@tiran
Created July 24, 2020 06:59
Show Gist options
  • Save tiran/632964f06ccdc4094a2e746835251c3b to your computer and use it in GitHub Desktop.
Save tiran/632964f06ccdc4094a2e746835251c3b to your computer and use it in GitHub Desktop.
Build FreeIPA libvirt image
#!/bin/sh
set -e
VER=32
IMG=f${VER}-base.qcow2
if [ ! -f $IMG ]; then
virt-builder \
--format qcow2 \
--update \
--output $IMG \
fedora-${VER}
fi
virt-customize \
--format qcow2 \
--timezone Europe/Berlin \
--run-command "id $USER || useradd -m -u $UID -U -s /bin/bash -G wheel $USER" \
--password "$USER:password:Secret123" \
--run-command "rm -rf /home/$USER/.ssh" \
--ssh-inject "$USER:file:/home/$USER/.ssh/id_yubikey.pub" \
--ssh-inject "root:file:/home/$USER/.ssh/id_yubikey.pub" \
--write "/etc/sudoers.d/passwordless:%wheel ALL = (ALL) NOPASSWD: ALL" \
--update \
--install openssh-server,openssl,vim-enhanced,gcc,make,git,rsync,screen,rpm-build,mc \
--install freeipa-server-dns,freeipa-client,pki-ca,389-ds-base,httpd \
--run-command 'dnf module -y enable nodejs:12' \
--selinux-relabel \
-a $IMG
virt-sysprep --operations defaults,-ssh-userdir -a $IMG
qemu-img create -b $IMG -f qcow2 f${VER}-server.qcow2
virt-customize --hostname ipaserver.fas.example -a f${VER}-server.qcow2
# qemu-img create -b $IMG -f qcow2 f${VER}-client.qcow2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment