Browse Source

Run a glean-early service to mount configdrive

Currently for the systemd/udev path, every device activated by udev
runs the "glean.sh" script, which attempts to mount the config drive
and set the ssh keys/hostname.

We should run an early service that mounts the config drive and does
this common setup.  Then each interface activated by udev only needs
to configure it's own network settings by calling the glean tool
directly.

This modifies things to run a glean-early.service, which does the
mounting, etc.  This runs the "glean-early.sh" script, which replaces
the no-longer necessary generic "glean.sh" script (an earlier change
moved legacy users depending on glean to iterate interfaces to use
"glean-legacy.sh").

Each of the udev-activated services is updated to depend on this early
configuration.  These now call "python-glean", which is our small
wrapper to call the glean python tool under the interpreter it was
installed with.

Change-Id: I4b36e99ff8ee10e0b855733d97ec4ee12f941c11
changes/17/782017/12
Ian Wienand 2 months ago
parent
commit
3cb334dbbb
6 changed files with 39 additions and 19 deletions
  1. +16
    -0
      glean/init/glean-early.service
  2. +7
    -10
      glean/init/glean-early.sh
  3. +3
    -1
      glean/init/glean-networkd.service
  4. +3
    -3
      glean/init/glean-nm@.service
  5. +3
    -2
      glean/init/glean@.service
  6. +7
    -3
      glean/install.py

+ 16
- 0
glean/init/glean-early.service View File

@ -0,0 +1,16 @@
[Unit]
Description=Early glean execution
Before=network-pre.target
Wants=network-pre.target
After=local-fs.target
[Service]
Type=oneshot
User=root
ExecStart=%%GLEANSH_PATH%%/glean-early.sh --debug
RemainAfterExit=true
StandardOutput=journal+console
[Install]
WantedBy=multi-user.target

glean/init/glean.sh → glean/init/glean-early.sh View File


+ 3
- 1
glean/init/glean-networkd.service View File

@ -1,12 +1,14 @@
[Unit]
Description=Glean system configuration
Before=systemd-networkd.service
After=glean-early.service
Requires=systemd-networkd.service
Wants=glean-early.service
[Service]
Type=oneshot
User=root
ExecStart=%%GLEANSH_PATH%%/glean.sh --distro networkd %%EXTRA_ARGS%%
ExecStart=%%GLEANSH_PATH%%/python-glean --distro networkd %%EXTRA_ARGS%%
RemainAfterExit=true
[Install]


+ 3
- 3
glean/init/glean-nm@.service View File

@ -1,8 +1,8 @@
[Unit]
Description=Glean for interface %I with NetworkManager
Before=network-pre.target
Wants=network-pre.target
After=local-fs.target
Wants=network-pre.target glean-early.service
After=local-fs.target glean-early.service
# Red Hat
ConditionPathExists=!/etc/sysconfig/network-scripts/ifcfg-%I
@ -13,7 +13,7 @@ ConditionPathExists=!/etc/sysconfig/network/ifcfg-%I
Type=oneshot
User=root
Environment="ARGS=--interface %I"
ExecStart=%%GLEANSH_PATH%%/glean.sh --use-nm --debug $ARGS %%EXTRA_ARGS%%
ExecStart=%%GLEANSH_PATH%%/python-glean --use-nm --debug %%EXTRA_ARGS%% $ARGS
RemainAfterExit=true
StandardOutput=journal+console


+ 3
- 2
glean/init/glean@.service View File

@ -2,7 +2,8 @@
Description=Glean for interface %I
DefaultDependencies=no
Before=network-pre.target
Wants=network-pre.target
After = glean-early.service
Wants=network-pre.target glean-early.service
# Red Hat
ConditionPathExists=!/etc/sysconfig/network-scripts/ifcfg-%I
@ -15,7 +16,7 @@ ConditionPathExists=!/etc/network/interfaces.d/%I.cfg
Type=oneshot
User=root
Environment="ARGS=--interface %I"
ExecStartPre=%%GLEANSH_PATH%%/glean.sh ${ARGS} %%EXTRA_ARGS%%
ExecStartPre=%%GLEANSH_PATH%%/python-glean %%EXTRA_ARGS%% ${ARGS}
ExecStart=/sbin/ifup %I
RemainAfterExit=true


+ 7
- 3
glean/install.py View File

@ -27,9 +27,6 @@ def _find_gleansh_path():
# glean.sh is a script installed by setup.cfg as a sibling to this
# script
p = pkg_resources.resource_filename(__name__, "init")
if not os.path.exists(os.path.join(p, "glean.sh")):
log.error("Unable to find glean.sh!")
sys.exit(1)
return p
@ -132,6 +129,13 @@ def main():
log.info("Installing systemd services")
log.info("glean.sh in %s" % p)
log.info("Install early service")
install(
'glean-early.service',
'/usr/lib/systemd/system/glean-early.service',
mode='0644',
replacements={'GLEANSH_PATH': p})
subprocess.call(['systemctl', 'enable', 'glean-early.service'])
if os.path.exists('/etc/gentoo-release'):
install(
'glean-networkd.service',


Loading…
Cancel
Save