2013-05-16 08:00:28 +02:00
|
|
|
from manifest import Manifest
|
2013-07-01 20:56:38 +02:00
|
|
|
import logging
|
2013-06-26 23:40:42 +02:00
|
|
|
from tasks import packages
|
|
|
|
from tasks import connection
|
|
|
|
from tasks import host
|
|
|
|
from tasks import ebs
|
2013-06-27 00:11:09 +02:00
|
|
|
from tasks import filesystem
|
2013-06-27 23:26:29 +02:00
|
|
|
from tasks import bootstrap
|
2013-07-01 22:52:54 +02:00
|
|
|
from tasks import locale
|
2013-07-01 22:51:28 +02:00
|
|
|
from tasks import apt
|
2013-07-01 23:15:49 +02:00
|
|
|
from tasks import boot
|
2013-07-01 23:41:22 +02:00
|
|
|
from tasks import security
|
2013-07-01 23:54:18 +02:00
|
|
|
from tasks import network
|
2013-07-07 14:58:03 +02:00
|
|
|
from tasks import initd
|
2013-07-07 16:59:12 +02:00
|
|
|
from tasks import cleanup
|
2013-05-16 08:00:28 +02:00
|
|
|
|
|
|
|
|
2013-07-01 20:56:38 +02:00
|
|
|
def initialize():
|
|
|
|
# Regardless of of loglevel, we don't want boto debug stuff, it's very noisy
|
|
|
|
logging.getLogger('boto').setLevel(logging.INFO)
|
|
|
|
|
|
|
|
|
2013-06-23 15:26:08 +02:00
|
|
|
def tasks(tasklist, manifest):
|
2013-07-01 22:38:33 +02:00
|
|
|
tasklist.add(packages.HostPackages(),
|
|
|
|
packages.ImagePackages(),
|
|
|
|
host.CheckPackages(),
|
|
|
|
connection.GetCredentials(),
|
|
|
|
host.GetInfo(),
|
|
|
|
connection.Connect())
|
2013-06-24 23:03:43 +02:00
|
|
|
if manifest.volume['backing'].lower() == 'ebs':
|
2013-07-01 22:38:33 +02:00
|
|
|
tasklist.add(ebs.CreateVolume(),
|
|
|
|
ebs.AttachVolume())
|
2013-06-27 00:11:09 +02:00
|
|
|
tasklist.add(filesystem.FormatVolume())
|
|
|
|
if manifest.volume['filesystem'].lower() == 'xfs':
|
|
|
|
tasklist.add(filesystem.AddXFSProgs())
|
2013-07-01 23:25:11 +02:00
|
|
|
if manifest.volume['filesystem'].lower() in ['ext2', 'ext3', 'ext4']:
|
2013-06-27 00:11:09 +02:00
|
|
|
tasklist.add(filesystem.TuneVolumeFS())
|
2013-06-27 22:00:01 +02:00
|
|
|
tasklist.add(filesystem.CreateMountDir(), filesystem.MountVolume())
|
2013-06-27 23:26:29 +02:00
|
|
|
if manifest.bootstrapper['tarball']:
|
|
|
|
tasklist.add(bootstrap.MakeTarball())
|
2013-07-01 22:38:33 +02:00
|
|
|
tasklist.add(bootstrap.Bootstrap(),
|
|
|
|
filesystem.MountSpecials(),
|
2013-07-01 22:52:54 +02:00
|
|
|
locale.GenerateLocale(),
|
|
|
|
locale.SetTimezone(),
|
2013-07-07 17:33:19 +02:00
|
|
|
apt.DisableDaemonAutostart(),
|
2013-07-01 22:52:54 +02:00
|
|
|
apt.AptSources(),
|
2013-07-01 23:15:49 +02:00
|
|
|
apt.AptUpgrade(),
|
2013-07-01 23:25:11 +02:00
|
|
|
boot.ConfigureGrub(),
|
2013-07-07 13:02:04 +02:00
|
|
|
filesystem.ModifyFstab(),
|
2013-07-01 23:33:59 +02:00
|
|
|
boot.BlackListModules(),
|
2013-07-01 23:41:22 +02:00
|
|
|
boot.DisableGetTTYs(),
|
|
|
|
security.EnableShadowConfig(),
|
|
|
|
security.DisableSSHPasswordAuthentication(),
|
2013-07-01 23:54:18 +02:00
|
|
|
security.DisableSSHDNSLookup(),
|
|
|
|
network.RemoveDNSInfo(),
|
|
|
|
network.ConfigureNetworkIF(),
|
2013-07-07 14:58:03 +02:00
|
|
|
network.ConfigureDHCP(),
|
|
|
|
initd.ResolveInitScripts(),
|
2013-07-07 16:59:12 +02:00
|
|
|
initd.InstallInitScripts(),
|
|
|
|
cleanup.ClearMOTD(),
|
|
|
|
cleanup.ShredHostkeys(),
|
2013-07-07 18:03:49 +02:00
|
|
|
cleanup.CleanTMP(),
|
|
|
|
apt.PurgeUnusedPackages(),
|
|
|
|
apt.AptClean(),
|
2013-07-07 17:55:21 +02:00
|
|
|
apt.EnableDaemonAutostart(),
|
|
|
|
filesystem.UnmountSpecials(),
|
|
|
|
filesystem.UnmountVolume(),
|
|
|
|
ebs.DetachVolume(),
|
2013-07-07 19:24:52 +02:00
|
|
|
filesystem.DeleteMountDir(),
|
|
|
|
ebs.CreateSnapshot())
|
2013-06-24 23:12:39 +02:00
|
|
|
|
|
|
|
from common.tasks import TriggerRollback
|
|
|
|
tasklist.add(TriggerRollback())
|
2013-06-26 23:40:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
def rollback_tasks(tasklist, tasks_completed, manifest):
|
|
|
|
completed = [type(task) for task in tasks_completed]
|
2013-06-27 22:21:43 +02:00
|
|
|
|
|
|
|
def counter_task(task, counter):
|
|
|
|
if task in completed and counter not in completed:
|
|
|
|
tasklist.add(counter())
|
|
|
|
|
2013-06-26 23:40:42 +02:00
|
|
|
if manifest.volume['backing'].lower() == 'ebs':
|
2013-06-27 22:21:43 +02:00
|
|
|
counter_task(ebs.CreateVolume, ebs.DeleteVolume)
|
|
|
|
counter_task(ebs.AttachVolume, ebs.DetachVolume)
|
|
|
|
counter_task(filesystem.CreateMountDir, filesystem.DeleteMountDir)
|
|
|
|
counter_task(filesystem.MountVolume, filesystem.UnmountVolume)
|
2013-07-01 20:48:51 +02:00
|
|
|
counter_task(filesystem.MountSpecials, filesystem.UnmountSpecials)
|