Skip to content

Commit

Permalink
Add PNIN as a system manifest parameter.
Browse files Browse the repository at this point in the history
Fixes: andsens#349

Adds a new boolean parameter indicating weather to use PNIN or not to
the system section of the manifest.

The default, False enables tasks for extlinux and grub to pass
net.ifnames=0 biosdevnames=0 parameters to the kernel.

Previously for grub PNIN was disabled for stretch and later. This
remains the default but setting system.pnin True will allow the behavior
to be overridden. The additional parameters have no effect on earlier
releases are passed regardless. Extlinux had no prior special behavior,
it now mirrors grub.
  • Loading branch information
john-pierce committed Jul 12, 2018
1 parent a4f2e1c commit e61ba85
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions bootstrapvz/base/manifest-schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ properties:
type: string
pattern: ^\S+$
locale: {type: string}
pnin: {type: boolean}
release: {type: string}
timezone: {type: string}
required:
Expand Down
5 changes: 4 additions & 1 deletion bootstrapvz/common/task_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ def get_bootloader_group(manifest):
from bootstrapvz.common.releases import jessie
from bootstrapvz.common.releases import stretch
group = []
pnin = manifest.system.get('pnin', None)
if manifest.system['bootloader'] == 'grub':
group.extend([grub.AddGrubPackage,
grub.InitGrubConfig,
Expand All @@ -173,7 +174,7 @@ def get_bootloader_group(manifest):
group.append(grub.InstallGrub_1_99)
else:
group.append(grub.InstallGrub_2)
if manifest.release >= stretch:
if pnin is False or (pnin is None and manifest.release >= stretch):
group.append(grub.DisablePNIN)
if manifest.system['bootloader'] == 'extlinux':
group.append(extlinux.AddExtlinuxPackage)
Expand All @@ -183,6 +184,8 @@ def get_bootloader_group(manifest):
else:
group.extend([extlinux.ConfigureExtlinuxJessie,
extlinux.InstallExtlinuxJessie])
if pnin is False or (pnin is None and manifest.release >= stretch):
group.append([extlinux.DisablePNIN])
return group


Expand Down
13 changes: 13 additions & 0 deletions bootstrapvz/common/tasks/extlinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ def run(cls, info):
r'EXTLINUX_PARAMETERS="\1 console=ttyS0"')


class DisablePNIN(Task):
description = 'Disabling Predictable Network Interfaces'
phase = phases.system_modification
predecessors = [filesystem.FStab]

@classmethod
def run(cls, info):
from bootstrapvz.common.tools import sed_i
extlinux_def = os.path.join(info.root, 'etc/default/extlinux')
sed_i(extlinux_def, r'^EXTLINUX_PARAMETERS="([^"]+)"$',
r'EXTLINUX_PARAMETERS="\1 net.ifnames=0 biosdevname=0"')


class InstallExtlinux(Task):
description = 'Installing extlinux'
phase = phases.system_modification
Expand Down
5 changes: 5 additions & 0 deletions manifests/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ system and does not fit under any other section.
- ``locale``: The default locale of the system.
Valid values: Any locale mentioned in ``/etc/locale.gen``
``required``
- ``pnin``: Enable Persistent Network Interface Naming in the bootloader.
Only supported with the ``grub`` and ``extlinux`` bootloaders.
Valid values: ``true``, ``false``
Default: ``false``
``optional``
- ``release``: Defines which debian release should be bootstrapped.
Valid values: ``wheezy``, ``jessie``, ``stretch``, ``sid``,
``oldstable``, ``stable``, ``testing``, ``unstable``
Expand Down

0 comments on commit e61ba85

Please sign in to comment.