mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 07:26:29 +00:00
Permit cloud-init to be configured for its metadata sources using debconf.
This commit is contained in:
parent
d0ec90f491
commit
682b747efc
6 changed files with 24 additions and 4 deletions
|
@ -44,7 +44,8 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"cloud_init": {
|
"cloud_init": {
|
||||||
"username": "admin"
|
"username": "admin",
|
||||||
|
"metadata_sources": "Ec2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,8 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"cloud_init": {
|
"cloud_init": {
|
||||||
"username": "admin"
|
"username": "admin",
|
||||||
|
"metadata_sources": "Ec2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,8 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"cloud_init": {
|
"cloud_init": {
|
||||||
"username": "admin"
|
"username": "admin",
|
||||||
|
"metadata_sources": "Ec2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,9 +22,10 @@ def validate_manifest(data, schema_validate):
|
||||||
|
|
||||||
def resolve_tasks(tasklist, manifest):
|
def resolve_tasks(tasklist, manifest):
|
||||||
from tasks import SetUsername
|
from tasks import SetUsername
|
||||||
|
from tasks import SetMetadataSource
|
||||||
from providers.ec2.tasks.initd import AddEC2InitScripts
|
from providers.ec2.tasks.initd import AddEC2InitScripts
|
||||||
from common.tasks import initd
|
from common.tasks import initd
|
||||||
tasklist.add(SetUsername)
|
tasklist.add(SetUsername, SetMetadataSource)
|
||||||
tasklist.remove(AddEC2InitScripts,
|
tasklist.remove(AddEC2InitScripts,
|
||||||
initd.AddExpandRoot,
|
initd.AddExpandRoot,
|
||||||
initd.AdjustExpandRootScript,
|
initd.AdjustExpandRootScript,
|
||||||
|
|
|
@ -11,6 +11,9 @@
|
||||||
"properties": {
|
"properties": {
|
||||||
"username": {
|
"username": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"metadata_sources": {
|
||||||
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["username"]
|
"required": ["username"]
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
from base import Task
|
from base import Task
|
||||||
from common import phases
|
from common import phases
|
||||||
from plugins.packages.tasks import InstallRemotePackages
|
from plugins.packages.tasks import InstallRemotePackages
|
||||||
|
from common.tasks import apt
|
||||||
|
from common.tools import log_check_call
|
||||||
|
|
||||||
|
|
||||||
class SetUsername(Task):
|
class SetUsername(Task):
|
||||||
|
@ -18,3 +20,14 @@ class SetUsername(Task):
|
||||||
' sudo: ALL=(ALL) NOPASSWD:ALL\n'
|
' sudo: ALL=(ALL) NOPASSWD:ALL\n'
|
||||||
' shell: /bin/bash').format(username=username)
|
' shell: /bin/bash').format(username=username)
|
||||||
sed_i(cloud_cfg, search, replace)
|
sed_i(cloud_cfg, search, replace)
|
||||||
|
|
||||||
|
class SetMetadataSource(Task):
|
||||||
|
description = 'Setting metadata source'
|
||||||
|
phase = phases.system_modification
|
||||||
|
predecessors = [apt.AptSources]
|
||||||
|
successors = [apt.AptUpdate]
|
||||||
|
|
||||||
|
def run(self, info):
|
||||||
|
sources = "cloud-init cloud-init/datasources multiselect " + info.manifest.plugins['cloud_init']['metadata_sources']
|
||||||
|
log_check_call(['/usr/sbin/chroot', info.root, '/usr/bin/debconf-set-selections' ], sources)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue