mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 07:26:29 +00:00
cloud-init: modify groups
This commit is contained in:
parent
7a4903f9e0
commit
c8ab73472f
4 changed files with 25 additions and 0 deletions
|
@ -13,6 +13,9 @@ Settings
|
||||||
|
|
||||||
- ``username``: The username of the account to create.
|
- ``username``: The username of the account to create.
|
||||||
``required``
|
``required``
|
||||||
|
- ``groups``: A list of strings specifying which additional groups the account
|
||||||
|
should be added to.
|
||||||
|
``optional``
|
||||||
- ``disable_modules``: A list of strings specifying which cloud-init
|
- ``disable_modules``: A list of strings specifying which cloud-init
|
||||||
modules should be disabled.
|
modules should be disabled.
|
||||||
``optional``
|
``optional``
|
||||||
|
|
|
@ -24,6 +24,8 @@ def resolve_tasks(taskset, manifest):
|
||||||
options = manifest.plugins['cloud_init']
|
options = manifest.plugins['cloud_init']
|
||||||
if 'username' in options:
|
if 'username' in options:
|
||||||
taskset.add(tasks.SetUsername)
|
taskset.add(tasks.SetUsername)
|
||||||
|
if 'groups' in options and len(options['groups']):
|
||||||
|
taskset.add(tasks.SetGroups)
|
||||||
if 'disable_modules' in options:
|
if 'disable_modules' in options:
|
||||||
taskset.add(tasks.DisableModules)
|
taskset.add(tasks.DisableModules)
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,10 @@ properties:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
username: {type: string}
|
username: {type: string}
|
||||||
|
groups:
|
||||||
|
type: array
|
||||||
|
items: {type: string}
|
||||||
|
uniqueItems: true
|
||||||
metadata_sources: {type: string}
|
metadata_sources: {type: string}
|
||||||
disable_modules:
|
disable_modules:
|
||||||
type: array
|
type: array
|
||||||
|
|
|
@ -38,6 +38,22 @@ class SetUsername(Task):
|
||||||
sed_i(cloud_cfg, search, replace)
|
sed_i(cloud_cfg, search, replace)
|
||||||
|
|
||||||
|
|
||||||
|
class SetGroups(Task):
|
||||||
|
description = 'Setting groups in cloud.cfg'
|
||||||
|
phase = phases.system_modification
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def run(cls, info):
|
||||||
|
from bootstrapvz.common.tools import sed_i
|
||||||
|
cloud_cfg = os.path.join(info.root, 'etc/cloud/cloud.cfg')
|
||||||
|
groups = info.manifest.plugins['cloud_init']['groups']
|
||||||
|
search = ('^ groups: \[adm, audio, cdrom, dialout, floppy, video,'
|
||||||
|
' plugdev, dip\]$')
|
||||||
|
replace = (' groups: [adm, audio, cdrom, dialout, floppy, video,'
|
||||||
|
' plugdev, dip, {groups}]').format(groups=', '.join(groups))
|
||||||
|
sed_i(cloud_cfg, search, replace)
|
||||||
|
|
||||||
|
|
||||||
class SetMetadataSource(Task):
|
class SetMetadataSource(Task):
|
||||||
description = 'Setting metadata source'
|
description = 'Setting metadata source'
|
||||||
phase = phases.package_installation
|
phase = phases.package_installation
|
||||||
|
|
Loading…
Add table
Reference in a new issue