Hi,
I've been playing around for a while with docker, foreman and libvirt to be
able to demonstrate foreman on my laptop.
The idea is to run Foreman in a Docker and then have it provision machines
in
my local libvirt installation. I'm using the simplest case where you run
foreman with libvirt support and dns/dhcp/puppet servers and its proxies
installed by foreman installer all in the same docker container, CentOS 6.6.
This approach have several drawbacks, like not being able to control the ip
in
the docker host (not out of the box at least) and it is in general a very
shaky setup, but it allows for some playing around and mainly gives you the
opportunity to demonstrate Foreman in a self contained way, without setting
up
any kind of infrastructure.
So, basically you need to create a docker container running foreman (this
can
be a start point: https://registry.hub.docker.com/u/xnaveira/foreman-docker/
),
then you need to configure the proxies, to that I run the excellent plugin
foreman_setup (which gets installed by default), it generates the
foreman-installer command that you need to run on your server to set
everything up (dhcp/dns etc), you can find it under
Infrastructure->Provisioning setup.
Once everything is setup in foreman, it's time to configure libvirt so the
machines that we'll be creating on it will be able to talk to foreman and
thus
to get ip from dhcp, kickstart and so on. Make sure that you have a working
libvirt installation on your machine (create a test machine with
virt-manager
perhaps) and then (this is on an ubuntu machine):
- Activate UNSECURE tcp communication with libvirt:
Edit /etc/libvirt/libvirtd.conf to set:
listen_tls = 0
listen_tcp = 1
auth_tcp="none"
tcp_port = "16509"
/etc/default/libvirt-bin:
libvirtd_opts="-d -l"
Restart libvirt
- Create a new network in libvirt that includes the docker bridge:
Create /etc/libvirt/qemu/networks/foreman.xml:
<network>
<name>foreman</name>
<forward mode='bridge'/>
<bridge name='docker0'/>
</network>
And then in virsh:
net-define foreman.xml
net-autostart foreman
- Configure libvirt computer resource in Foreman using the ip of the
docker bridge on your machine:
Add a libvirt compute resource with the url: qemu+tcp://ip_of_docker0/system
- You need to create the subnet your foreman server is connected to,
that'll
be used to create the virtual hosts in.
And that's it, when creating a new host make sure that you choose the right
network in the "Virtual Machine" tab and you'd be able to both talking to
the
foreman server and to the internet.
I realize these instructions are somewhat incomplete, this is not a howto
but
more of a braindump after being playing around with this for a few days.
Let me know if you want to know more details.
Xavier