Testing foreman with just a Laptop

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

Hello,

sorry to be negative but I can not see how this is demonstration of foreman
when it is a simple matter of using a Vagrant script with a VM such as
Virtualbox or KVM, you can define a private network where you can build
your instances including docker from the Foreman UI.

Docker is undoubted a useful tool in the toolbox but don't use a hammer to
drive home a screw.

Regards Jim

··· On 10 December 2014 at 08:31, Xavier Naveira wrote:

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:

foreman


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


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.

Hi James,

Thank you for the feedback. The only reason for sending this email is that
when I shared what I was doing in the IRC channel some of the people there
ask me to. I'm sure that there are other ways of testing foreman locally on
your machine, I was just trying to avoid using the same virtualization
resource for both the hosts and the foreman server, plus I really wanted to
learn some docker.

It'd great if you decide to share your vagrant configuration, it might give
us some other ways of testing foreman.

Cheers,

Xavier

··· On Wed, Dec 10, 2014 at 10:52 AM, James Bailey wrote:

Hello,

sorry to be negative but I can not see how this is demonstration of
foreman when it is a simple matter of using a Vagrant script with a VM such
as Virtualbox or KVM, you can define a private network where you can build
your instances including docker from the Foreman UI.

Docker is undoubted a useful tool in the toolbox but don’t use a hammer to
drive home a screw.

Regards Jim

On 10 December 2014 at 08:31, Xavier Naveira xnaveira@gmail.com wrote:

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:

foreman


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


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.

In the interests of sharing, Greg Sutcliffe has a good article on his blog
showing how to get something similar going with Libvirt, KVM &
Foreman: http://emeraldreverie.org/blog/2012/10/26/creating-development-environment-with/

I've done something similar at work using RHEL7 Workstation on a laptop,
then PXE booting of all Libvirt guests with hard coded DHCP "Reservations"
through the libvirt network xml config. But the PXE boot was from a
kickstart & repo on the host machine rather than the Foreman guest. I
really should sort that out sometime, but that laptop was for messing
around with Satellite 6 betas etc rather than the more naked Foreman. I'll
try to write up what I did and link it from here.

It's worth getting information out there. There are many ways to cook an
egg (avoiding the cat version of the idiom), and I know, well, not many of
them.

Cheers

D

Man, I really need to update that… :slight_smile:

··· On 11 December 2014 at 10:02, Duncan Innes wrote: > In the interests of sharing, Greg Sutcliffe has a good article on his blog > showing how to get something similar going with Libvirt, KVM & Foreman: > http://emeraldreverie.org/blog/2012/10/26/creating-development-environment-with/