Simple program to write static config from config-drive
Go to file
Ian Wienand 0eefc7321e Stop requiring /usr/local/bin links for glean.sh
Since Ic16f134fe34293bb68e7c632dd320f523366320d simple-init has
installed glean into a virtualenv.  Despite this, it still needs to
setup a range of global symlinks (in /usr/local/bin) so glean can
blindly call "glean" or "glean.sh".

This means that glean installation isn't actually stand-alone.  Unless
simple-init sets up these global symlinks the glean install doesn't
work.  This makes it very annoying to try and update the way the
scripts are working, because we have to merge changes into simple-init
as well.

We can make the installation self-consistent by using the install
tool.  The init scripts call glean.sh -- we can find the full path to
glean.sh using pkg_resources and write that into the files.

glean.sh wants to call the python tool "glean".  This is slightly
harder, because at runtime the script doesn't really know how to
invoke this (i.e. in a virtualenv, it should call
/path/to/virtualenv/bin/glean).  To allow for this, write a sibling
file next to "glean.sh" to invoke glean with the interpreter the
install is running under patched in.  This way, glean.sh can call this
wrapper relative to itself and get the right thing.  Add a __main__ to
allow glean to be called like this, and update the glean.sh script.

Change-Id: I1adfecf0d5c53648ee857be502216fd8d6cc5e16
2021-04-28 08:18:02 +10:00
doc/source Use openstackdocstheme. 2019-04-05 17:22:00 -07:00
glean Stop requiring /usr/local/bin links for glean.sh 2021-04-28 08:18:02 +10:00
.coveragerc Change ignore-errors to ignore_errors 2015-09-21 14:23:11 +00:00
.gitignore Add coverage generated files to .gitignore 2016-07-06 10:12:21 -07:00
.gitreview OpenDev Migration Patch 2019-04-19 19:26:10 +00:00
.mailmap Initial Cookiecutter Commit. 2015-03-02 19:05:03 -05:00
.testr.conf Initial Cookiecutter Commit. 2015-03-02 19:05:03 -05:00
.zuul.yaml Add Python 3.6 to supported versions 2021-03-19 13:56:39 +01:00
CONTRIBUTING.rst Reference storyboard instead of launchpad 2015-04-12 15:56:20 -04:00
HACKING.rst gleam is taken, let's do glean instead 2015-04-12 16:06:41 -04:00
LICENSE Initial Cookiecutter Commit. 2015-03-02 19:05:03 -05:00
MANIFEST.in Initial Cookiecutter Commit. 2015-03-02 19:05:03 -05:00
README.rst Add NetworkManager distro plugin support 2018-11-29 21:28:25 +11:00
rebuild-test-output.sh Support explicitly configured DHCP interfaces 2015-07-17 19:53:15 +00:00
setup.cfg Stop requiring /usr/local/bin links for glean.sh 2021-04-28 08:18:02 +10:00
setup.py Import content from project-config patch 2015-03-02 20:12:23 -05:00
test-requirements.txt Update hacking and fix pep8 violations 2021-04-28 08:17:52 +10:00
tox.ini Move to Zuul standard hacking rules 2021-04-28 08:18:02 +10:00

README.rst

glean

Glean is a program intended to configure a system based on configuration provided in a configuration drive.

Why would you want glean?

Different cloud providers have different ways of providing networking and other configuration to guest virtual-machines. Many use DHCP but others, notably Rackspace, use configuration provided via a configuration drive.

What does glean do?

Broadly, glean checks for configuration drive based information and, if found, uses that to configure the network. If config-drive is not found, it falls back to configuring any available interfaces with DHCP.

Specifically, it will mount the special block-device with label config-2 and parse the network_info.json and vendor_info.json files within. If appropriate network configuration is found, it will write out network configuration files.

The format of the network_info.json file is documented here. Please note that glean does not implement every feature listed.

If no network info is found there, available interfaces can be probed from /sys/class/net and any that appear to be up will be configured for use with DHCP.

It will also handle authorized_keys and host-name info provided from meta_data.json.

How does glean do this?

Glean determines the network configuration environment for the running platform and configures the interfaces appropriately.

systemd environment

On platforms where systemd is detected glean-install will add a udev rules file (99-glean.rules) that triggers on any network device being added. This will run the glean@.service systemd template for the interface specified.

This systemd unit firstly determines if there is already a /etc/sysconfig/network/ configuration for the interface; if so, the interface is considered configured and skipped.

If not, glean is started with the interface that triggered this event specified as an argument. The configuration drive is probed to see if network configuration for the interface is available. If so, it will be added, otherwise the interface will configured for DHCP.

By default glean provides configuration for the network init scripts service network.service on RedHat platforms (or the equivalent on other platforms). You should ensure this service is enabled and other tools such as NetworkManager are disabled for correct operation in this mode. Note on Fedora 29 onwards, this is in a separate package network-scripts and is considered deprecated.

Alternatively, to use NetworkManager with the ifcfg-rh plugin with to manage the interfaces, call glean-install with the --use-nm flag. In this case, ensure NetworkManager is installed. This will trigger glean to write out configuration files that are suitable for use with NetworkManager and use a slightly different service file that doesn't trigger legacy tools like ifup.

networkd

networkd support is implemented as a separate distribution type. Currently it is only supported on Gentoo, and will be automatically selected by glean-install. It will similarly install a systemd service file or openrc config file (both are supported on Gentoo) and udev rules to call glean.

Other platforms

upstart and sysv environments are also supported. These will have init scripts installed to run glean at boot.

How do I use glean?

Glean ships glean-install, a script which install glean into your system startup environment. It should handle sysv, upstart and systemd to cover all major distributions. This should be run once, during install or image build.

The startup environment will be modified as described above to configure any found interfaces.

Differences to cloud-init?

Glean differs to cloud-init mainly in its very reduced dependency footprint. In a dynamic CI environment such as OpenStack, many of the python dependencies for cloud-init can cause conflicts with packages or versions required for testing.

Glean also better supports static IP allocation within config-drive, particuarly important within the Rackspace environment.

More details