From 4913296480f2ff365d3ef0ae5c1162e50c81df97 Mon Sep 17 00:00:00 2001 From: Anders Ingemann Date: Sat, 10 Aug 2013 16:15:49 +0200 Subject: [PATCH] Moved apt to common tasks. Reverted one mirror to use the geo-redirector. --- {providers/ec2 => common}/tasks/apt.py | 0 manifests/one-ide.manifest | 3 +- manifests/one-virtio.manifest | 3 +- providers/ec2/__init__.py | 2 +- providers/raw/__init__.py | 7 +-- providers/raw/tasks/apt.py | 81 -------------------------- 6 files changed, 6 insertions(+), 90 deletions(-) rename {providers/ec2 => common}/tasks/apt.py (100%) delete mode 100644 providers/raw/tasks/apt.py diff --git a/providers/ec2/tasks/apt.py b/common/tasks/apt.py similarity index 100% rename from providers/ec2/tasks/apt.py rename to common/tasks/apt.py diff --git a/manifests/one-ide.manifest b/manifests/one-ide.manifest index 26db2a9..e1add0c 100644 --- a/manifests/one-ide.manifest +++ b/manifests/one-ide.manifest @@ -21,8 +21,7 @@ "architecture": "amd64", "timezone" : "UTC", "locale" : "en_US", - "charmap" : "UTF-8", - "mirror" : "ftp://ftp.fr.debian.org/debian/" + "charmap" : "UTF-8" }, "volume": { "backing" : "raw", diff --git a/manifests/one-virtio.manifest b/manifests/one-virtio.manifest index 02ce685..19b2748 100644 --- a/manifests/one-virtio.manifest +++ b/manifests/one-virtio.manifest @@ -21,8 +21,7 @@ "architecture": "amd64", "timezone" : "UTC", "locale" : "en_US", - "charmap" : "UTF-8", - "mirror" : "ftp://ftp.fr.debian.org/debian/" + "charmap" : "UTF-8" }, "volume": { "backing" : "raw", diff --git a/providers/ec2/__init__.py b/providers/ec2/__init__.py index 57e2284..a5eb2c4 100644 --- a/providers/ec2/__init__.py +++ b/providers/ec2/__init__.py @@ -9,7 +9,7 @@ from tasks import loopback from tasks import filesystem from tasks import bootstrap from tasks import locale -from tasks import apt +from common.tasks import apt from tasks import boot from tasks import security from tasks import network diff --git a/providers/raw/__init__.py b/providers/raw/__init__.py index 2cd2f36..7d77d25 100644 --- a/providers/raw/__init__.py +++ b/providers/raw/__init__.py @@ -5,7 +5,7 @@ from tasks import host from tasks import filesystem from tasks import bootstrap from tasks import locale -from tasks import apt +from common.tasks import apt from tasks import boot from tasks import security from tasks import network @@ -13,7 +13,6 @@ from tasks import initd from tasks import cleanup from tasks import fake - def initialize(): # Regardless of of loglevel, we don't want boto debug stuff, it's very noisy logging.getLogger('boto').setLevel(logging.INFO) @@ -39,14 +38,14 @@ def tasks(tasklist, manifest): locale.SetTimezone(), apt.DisableDaemonAutostart(), apt.AptSources(), - #No network for the moment, skip + #No network for the moment, skip #apt.AptUpgrade(), boot.ConfigureGrub(), filesystem.ModifyFstab(), boot.BlackListModules(), boot.DisableGetTTYs(), security.EnableShadowConfig(), - security.SetRootPassword(), + security.SetRootPassword(), security.DisableSSHPasswordAuthentication(), security.DisableSSHDNSLookup(), network.RemoveDNSInfo(), diff --git a/providers/raw/tasks/apt.py b/providers/raw/tasks/apt.py deleted file mode 100644 index d2d86d3..0000000 --- a/providers/raw/tasks/apt.py +++ /dev/null @@ -1,81 +0,0 @@ -from base import Task -from common import phases -from common.tools import log_check_call -import os -from locale import GenerateLocale - - -class AptSources(Task): - description = 'Adding aptitude sources' - phase = phases.system_modification - - def run(self, info): - mirror = 'http://http.debian.net/debian' - if info.manifest.system['mirror']: - mirror = info.manifest.system['mirror'] - sources_path = os.path.join(info.root, 'etc/apt/sources.list') - with open(sources_path, 'w') as apt_sources: - apt_sources.write(('deb {apt_mirror} {release} main\n' - 'deb-src {apt_mirror} {release} main\n' - .format(apt_mirror=mirror, - release=info.manifest.system['release']))) - apt_sources.write(('deb {apt_mirror} {release}/updates main\n' - 'deb-src {apt_mirror} {release}/updates main\n' - .format(apt_mirror='http://security.debian.org/', - release=info.manifest.system['release']))) - - -class DisableDaemonAutostart(Task): - description = 'Disabling daemon autostart' - phase = phases.system_modification - - def run(self, info): - rc_policy_path = os.path.join(info.root, 'usr/sbin/policy-rc.d') - with open(rc_policy_path, 'w') as rc_policy: - rc_policy.write(('#!/bin/sh\n' - 'exit 101')) - import stat - os.chmod(rc_policy_path, - stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | - stat.S_IRGRP | stat.S_IXGRP | - stat.S_IROTH | stat.S_IXOTH) - - -class AptUpgrade(Task): - description = 'Upgrading packages and fixing broken dependencies' - phase = phases.system_modification - after = [GenerateLocale, AptSources, DisableDaemonAutostart] - - def run(self, info): - log_check_call(['/usr/sbin/chroot', info.root, '/usr/bin/apt-get', 'update']) - log_check_call(['/usr/sbin/chroot', info.root, '/usr/bin/apt-get', '-f', '-y', 'install']) - log_check_call(['/usr/sbin/chroot', info.root, '/usr/bin/apt-get', '-y', 'upgrade']) - - -class PurgeUnusedPackages(Task): - description = 'Removing unused packages' - phase = phases.system_cleaning - - def run(self, info): - log_check_call(['/usr/sbin/chroot', info.root, '/usr/bin/apt-get', 'autoremove', '--purge']) - - -class AptClean(Task): - description = 'Clearing the aptitude cache' - phase = phases.system_cleaning - - def run(self, info): - log_check_call(['/usr/sbin/chroot', info.root, '/usr/bin/apt-get', 'clean']) - - lists = os.path.join(info.root, 'var/lib/apt/lists') - for list_file in [os.path.join(lists, f) for f in os.listdir(lists)]: - if os.path.isfile(list_file): - os.remove(list_file) - - -class EnableDaemonAutostart(Task): - description = 'Re-enabling daemon autostart after installation' - phase = phases.system_cleaning - - def run(self, info): - os.remove(os.path.join(info.root, 'usr/sbin/policy-rc.d'))