Permit cloud-init to be configured for its metadata sources using debconf.

This commit is contained in:
James Bromberger 2013-12-17 15:51:03 +00:00
parent d0ec90f491
commit 682b747efc
6 changed files with 24 additions and 4 deletions

View file

@ -44,7 +44,8 @@
]
},
"cloud_init": {
"username": "admin"
"username": "admin",
"metadata_sources": "Ec2"
}
}
}

View file

@ -44,7 +44,8 @@
]
},
"cloud_init": {
"username": "admin"
"username": "admin",
"metadata_sources": "Ec2"
}
}
}

View file

@ -44,7 +44,8 @@
]
},
"cloud_init": {
"username": "admin"
"username": "admin",
"metadata_sources": "Ec2"
}
}
}

View file

@ -22,9 +22,10 @@ def validate_manifest(data, schema_validate):
def resolve_tasks(tasklist, manifest):
from tasks import SetUsername
from tasks import SetMetadataSource
from providers.ec2.tasks.initd import AddEC2InitScripts
from common.tasks import initd
tasklist.add(SetUsername)
tasklist.add(SetUsername, SetMetadataSource)
tasklist.remove(AddEC2InitScripts,
initd.AddExpandRoot,
initd.AdjustExpandRootScript,

View file

@ -11,6 +11,9 @@
"properties": {
"username": {
"type": "string"
},
"metadata_sources": {
"type": "string"
}
},
"required": ["username"]

View file

@ -1,6 +1,8 @@
from base import Task
from common import phases
from plugins.packages.tasks import InstallRemotePackages
from common.tasks import apt
from common.tools import log_check_call
class SetUsername(Task):
@ -18,3 +20,14 @@ class SetUsername(Task):
' sudo: ALL=(ALL) NOPASSWD:ALL\n'
' shell: /bin/bash').format(username=username)
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)