Skip to content

Instantly share code, notes, and snippets.

@dhilst
Last active November 22, 2019 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhilst/8b5b55850545909729fd558d574b647e to your computer and use it in GitHub Desktop.
Save dhilst/8b5b55850545909729fd558d574b647e to your computer and use it in GitHub Desktop.
mkdir -p /opt/versatushpc/{etc,xcat}
mkdir -p /opt/versatushpc/xcat/post{install,scripts}
copycds CentOS-7-x86_64-DVD-1810.iso
cat <<'EOF' > /opt/versatushpc/xcat/postinstall/add-cluster-key
#!/bin/bash
pubkey=$(cat ~/.ssh/id_ed25519.pub)
authorized_keys="$IMG_ROOTIMGDIR/root/.ssh/authorized_keys"
if [ ! -f $authorized_keys ]; then
mkdir -p $IMG_ROOTIMGDIR/root/.ssh || : # ignore error
chmod 0700 $IMG_ROOTIMGDIR/root/.ssh
echo "$pubkey" >> $authorized_keys
else
grep "$pubkey" $authorized_keys || echo "$pubkey" >> $authorized_keys
fi
EOF
chmod +x /opt/versatushpc/xcat/postinstall/add-cluster-key
chdef -t osimage -o centos7.6-x86_64-netboot-compute -p postinstall=/opt/versatushpc/xcat/postinstall/add-cluster-key
cat <<'EOF' > /opt/versatushpc/xcat/centos7.6-compute.pkglist
#NEW_INSTALL_LIST#
freeipa-client
EOF
chdef -t osimage -o centos7.6-x86_64-netboot-compute -p pkglist=/opt/versatushpc/xcat/centos7.6-compute.pkglist
chdef -t osimage -o centos7.6-x86_64-netboot-compute -p pkgdir=http://mirror.centos.org/centos/7/os/x86_64/
chdef -t osimage -o centos7.6-x86_64-netboot-compute -p pkgdir=http://mirror.centos.org/centos/7/updates/x86_64/
chdef -t osimage -o centos7.6-x86_64-netboot-compute -p pkgdir=http://mirror.centos.org/centos/7/extras/x86_64/
chdef -t osimage -o centos7.6-x86_64-netboot-compute -p pkgdir=http://mirror.centos.org/centos/7/centosplus/x86_64/
chdef -t osimage -o centos7.6-x86_64-netboot-compute -p pkgdir=http://download.fedoraproject.org/pub/epel/7/x86_64
chdef -t osimage -o centos7.6-x86_64-netboot-compute -p pkgdir=http://build.openhpc.community/OpenHPC:/1.3/CentOS_7
chdef -t osimage -o centos7.6-x86_64-netboot-compute -p pkgdir=http://build.openhpc.community/OpenHPC:/1.3/updates/CentOS_7
# Create keys
for t in ecdsa ed25519 rsa; do ssh-keygen -t $t -f /opt/versatushpc/xcat/ssh_host_${t}_key -N '' <<< n; don
cat <<'EOF' > /opt/versatushpc/xcat/postinstall/create-ssh-key
#!/bin/bash -x
cp -vf /opt/versatushpc/xcat/ssh_host_* $IMG_ROOTIMGDIR/etc/ssh/
exit 0
EOF
chmod +x /opt/versatushpc/xcat/postinstall/create-ssh-key
chdef -t osimage -o centos7.6-x86_64-netboot-compute -p postinstall=/opt/versatushpc/xcat/postinstall/create-ssh-key
genimage centos7.6-x86_64-netboot-compute
packimage centos7.6-x86_64-netboot-compute
mkdef -f -t node -o node001 ip=172.26.0.1 bmc=172.25.0.1 mac=56:6f:90:d5:00:45 bmcusername=ADMIN bmcpassword=password mgt=ipmi groups=compute,all netboot=xnba arch=x86_64
ipa host-add --ip-address=172.26.0.1 node001.cluster.example.com
ipa host-add-managedby --hosts=headnode.cluster.example.com node001.cluster.example.com
# Add all public keys, they are generated at genimage time, so this need to run after genimage
# we can get read of this by creating keys before genimage anc copying it to the image
ipa host-mod $(cat /opt/versatushpc/xcat/ssh_host_*.pub | awk '{ print $2 }' | xargs -n1 -I% echo --sshpubkey=\'%\' | paste -s) --updatedns node001.cluster.example.com
makehosts node001
makedhcp node001
nodeset node001 osimage=centos7.6-x86_64-netboot-compute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment