Skip to content

Commit

Permalink
Merge branch 'maas-offline-v2' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
mwhudson committed Apr 24, 2018
2 parents 51fa6a5 + b98c37b commit 9a08d34
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 18 deletions.
68 changes: 52 additions & 16 deletions subiquity/models/installpath.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2015 Canonical, Ltd.
# Copyright 2018 Canonical, Ltd.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -26,9 +26,10 @@ class InstallpathModel(object):
('UI Text seen by user', <signal name>, <callback function string>)
"""

path = None
packages = {}
debconf = {}
path = 'ubuntu'
# update() is not run, upon selecting the default choice...
source = '/media/filesystem'
curtin = {}

@property
def paths(self):
Expand All @@ -40,25 +41,60 @@ def paths(self):

def update(self, results):
if self.path == 'ubuntu':
self.packages = {}
self.debconf = {}
self.source = '/media/filesystem'
self.curtin = {}
elif self.path == 'maas_region':
self.packages = {'packages': ['maas']}
self.debconf['debconf_selections'] = {
self.source = '/media/region'
self.curtin['debconf_selections'] = {
'maas-username': 'maas-region-controller maas/username string %s' % results['username'],
'maas-password': 'maas-region-controller maas/password password %s' % results['password'],
}
}
self.curtin['late_commands'] = {
# Maintainer scripts cache results, from config files, if they exist
# These shouldn't exist, since this was fixed in livecd-rootfs
# but remove these, just to be sure
'900-maas': ['rm', '-f', '/target/etc/maas/rackd.conf'],
'901-maas': ['rm', '-f', '/target/etc/maas/region.conf'],
# All the crazy things are workarounds for maas maintainer scripts deficiencies
# see https://bugs.launchpad.net/ubuntu/+source/maas/+bugs?field.tag=subiquity
#
# uuid is not initialized by reconfigure, maybe it should, if it is at all used
# make it so, to make it match the udeb/deb installs
'902-maas': ['curtin', 'in-target', '--', 'maas-rack', 'config', '--init'],
# this should do setups of maas-url for the rack controller, and secret if needed.
'903-maas': ['curtin', 'in-target', '--', 'dpkg-reconfigure', '-u', '-fnoninteractive', 'maas-rack-controller'],
# Below are workaround to make postgresql database running, and invoke-rc.d --force to not fail
# And a running postgresql is needed, to change the role password and to create an admin user
'904-maas': ['mount', '-o', 'bind', '/proc', '/target/proc'],
'905-maas': ['mount', '-o', 'bind', '/sys', '/target/sys'],
'906-maas': ['mount', '-o', 'bind', '/dev', '/target/dev'],
'907-maas': ['mount', '-o', 'bind', '/target/bin/true', '/target/usr/sbin/invoke-rc.d'],
'908-maas': ['chroot', '/target', 'sh', '-c', 'pg_ctlcluster --skip-systemctl-redirect $(/bin/ls /var/lib/postgresql/) main start'],
# These are called like this, because reconfigure doesn't create nor change an admin user account, nor regens the semi-autogenerated maas-url
'909-maas': ['chroot', '/target', 'sh', '-c', 'debconf -fnoninteractive -omaas-region-controller /var/lib/dpkg/info/maas-region-controller.config configure'],
'910-maas': ['chroot', '/target', 'sh', '-c', 'debconf -fnoninteractive -omaas-region-controller /var/lib/dpkg/info/maas-region-controller.postinst configure'],
'911-maas': ['chroot', '/target', 'sh', '-c', 'pg_ctlcluster --skip-systemctl-redirect $(/bin/ls /var/lib/postgresql/) main stop'],
'912-maas': ['umount', '/target/usr/sbin/invoke-rc.d'],
'913-maas': ['umount', '/target/dev'],
'914-maas': ['umount', '/target/sys'],
'915-maas': ['umount', '/target/proc'],
}
elif self.path == 'maas_rack':
self.packages = {'packages': ['maas-rack-controller']}
self.debconf['debconf_selections'] = {
self.source = '/media/rack'
self.curtin['debconf_selections'] = {
'maas-url': 'maas-rack-controller maas-rack-controller/maas-url string %s' % results['url'],
'maas-secret': 'maas-rack-controller maas-rack-controller/shared-secret password %s' % results['secret'],
}
}
self.curtin['late_commands'] = {
'90-maas': ['rm', '-f', '/target/etc/maas/rackd.conf'],
'91-maas': ['curtin', 'in-target', '--', 'maas-rack', 'config', '--init'],
# maas-rack-controller is broken, and does db_input & go on the password question in the postinst...
# when it should have been done in .config
# and it doesn't gracefully handle the case of db_go returning 30 skipped
'93-maas': ['curtin', 'in-target', '--', 'sh', '-c', 'debconf -fnoninteractive -omaas-rack-controller /var/lib/dpkg/info/maas-rack-controller.postinst configure || :'],
}
else:
raise ValueError("invalid Installpath %s" % self.path)

def render(self):
return self.debconf

def render_cloudinit(self):
return self.packages
return self.curtin
3 changes: 1 addition & 2 deletions subiquity/models/subiquity.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def _cloud_init_config(self):
'resize_rootfs': False,
'users': [user_info],
}
config.update(self.installpath.render_cloudinit())
return config

def _cloud_init_files(self):
Expand Down Expand Up @@ -111,7 +110,7 @@ def render(self, target, syslog_identifier):
},

'sources': {
'rofs': 'cp:///rofs',
'rofs': 'cp://%s' % self.installpath.source,
},

'verbosity': 3,
Expand Down

0 comments on commit 9a08d34

Please sign in to comment.