Doesn't foreman-installer take care of this? With @GregSutcliffe's work it should also be able to install foreman with the libvirt compute resource.