The larsks/rdo-puppet-base module includes “puppet” and all the Puppet
modules required by RDO (installed in
/usr/share/openstack-puppet/modules).

Running docker build with this Dockerfile results in:

Error: Could not run: Could not retrieve facts for
a9cde05eb735.example.com: no address for
a9cde05eb735.example.com

Puppet is trying to determine the FQDN of the container, and is then
trying to determine the canonical ip address of the container. This is
never going to work, absent some mechanism that automatically
registers DNS entries when you boot containers (e.g., skydock).

The obvious way to fix this would be to modify /etc/hosts and add
the calculated fqdn to the entry for localhost, but /etc/hosts
inside Docker containers is read-only.

Since Puppet is using Facter to get information about the host, I
looked into whether or not it would be possible (and convenient) to
override Facter generated facts. It turns out that it is relatively
easy; just set FACTER_<fact_name> in the environment.
For example:

Error: Could not start Service[sshd]: Execution of '/sbin/service
sshd start' returned 1: Redirecting to /bin/systemctl start sshd.service
Failed to get D-Bus connection: No connection to service manager.
Wrapped exception:
Execution of '/sbin/service sshd start' returned 1: Redirecting to
/bin/systemctl start sshd.service
Failed to get D-Bus connection: No connection to service manager.

This is happening because the Puppet module is trying to manipulate
the corresponding service resource, but there is no service manager
(e.g., “systemd” or “upstart”, etc) inside the container.

Some modules provide a module parameter to disable service management,
but that solution isn’t available in this module. Instead, I created
a “dummy” service provider. The “code” (or lack thereof) looks like
this:

Obviously, in order to turn this into a functional module you would
need to add an appropriate CMD or ENTRYPOINT script to make it
generate host keys and start sshd, but I think this successfully
demonstrates what is necessary to make a stock Puppet module run
as part of the docker build process.