add plugins to manage user packages, allow root login via ssh when root password is defined in conf, install opennebula context package

This commit is contained in:
Olivier Sallou 2013-07-31 16:57:29 +02:00
parent cd6e10c6a1
commit 237069b941
7 changed files with 66 additions and 6 deletions

View file

@ -41,6 +41,12 @@
"prebootstrapped": { "prebootstrapped": {
"enabled": false, "enabled": false,
"snapshot": "" "snapshot": ""
} },
"user_packages": {
"enabled": true,
"repo": [ "apache2" ],
"local": []
}
} }
} }

View file

@ -0,0 +1,6 @@
def tasks(tasklist, manifest):
from user_packages import AddUserPackages, AddLocalUserPackages
tasklist.add(AddUserPackages())
tasklist.add(AddLocalUserPackages())

View file

@ -0,0 +1,45 @@
from base import Task
from common import phases
import os
from providers.one.tasks.packages import ImagePackages
from providers.one.tasks.host import CheckPackages
from providers.one.tasks.filesystem import MountVolume
class AddUserPackages(Task):
description = 'Adding user defined packages to the image packages'
phase = phases.preparation
after = [ImagePackages]
before = [CheckPackages]
def run(self, info):
if 'repo' not in info.manifest.plugins['user_packages']:
return
for pkg in info.manifest.plugins['user_packages']['repo']:
info.img_packages[0].add(pkg)
class AddLocalUserPackages(Task):
description = 'Adding user local packages to the image packages'
phase = phases.system_modification
after = [MountVolume]
def run(self, info):
if 'local' not in info.manifest.plugins['user_packages']:
return
import stat
rwxr_xr_x = (stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |
stat.S_IRGRP | stat.S_IXGRP |
stat.S_IROTH | stat.S_IXOTH)
from shutil import copy
from common.tools import log_check_call
for pkg in info.manifest.plugins['user_packages']['local']:
script_src = os.path.normpath(pkg)
script_dst = os.path.join(info.root, 'tmp/'+os.path.basename(script_src))
copy(script_src, script_dst)
os.chmod(script_dst, rwxr_xr_x)
log_check_call(['/usr/sbin/chroot', info.root, 'dpkg', '-i', '/tmp/'+os.path.basename(script_src)])

View file

@ -52,8 +52,7 @@ def tasks(tasklist, manifest):
boot.DisableGetTTYs(), boot.DisableGetTTYs(),
security.EnableShadowConfig(), security.EnableShadowConfig(),
security.SetRootPassword(), security.SetRootPassword(),
# Disable for the time of debugging security.DisableSSHPasswordAuthentication(),
#security.DisableSSHPasswordAuthentication(),
security.DisableSSHDNSLookup(), security.DisableSSHDNSLookup(),
network.RemoveDNSInfo(), network.RemoveDNSInfo(),
network.ConfigureNetworkIF(), network.ConfigureNetworkIF(),

View file

@ -16,7 +16,7 @@ class GenerateLocale(Task):
search = '# ' + locale_str search = '# ' + locale_str
sed_i(locale_gen, search, locale_str) sed_i(locale_gen, search, locale_str)
command = ['/usr/sbin/chroot', info.root, '/usr/sbin/dpkg-reconfigure', '--priority=critical', 'locales'] command = ['/usr/sbin/chroot', info.root, '/usr/sbin/locale-gen']
log_check_call(command) log_check_call(command)

View file

@ -1,11 +1,13 @@
from base import Task from base import Task
from common import phases from common import phases
import os import os
from providers.one.tasks.locale import GenerateLocale
class OpenNebulaContext(Task): class OpenNebulaContext(Task):
description = 'Setup OpenNebula init context' description = 'Setup OpenNebula init context'
phase = phases.system_modification phase = phases.system_modification
after = [GenerateLocale]
def run(self, info): def run(self, info):
import stat import stat

View file

@ -26,8 +26,10 @@ class DisableSSHPasswordAuthentication(Task):
def run(self, info): def run(self, info):
from common.tools import sed_i from common.tools import sed_i
sshd_config_path = os.path.join(info.root, 'etc/ssh/sshd_config') if 'root' not in info.manifest.credentials:
sed_i(sshd_config_path, '^#PasswordAuthentication yes', 'PasswordAuthentication no') # If no password set for root
sshd_config_path = os.path.join(info.root, 'etc/ssh/sshd_config')
sed_i(sshd_config_path, '^#PasswordAuthentication yes', 'PasswordAuthentication no')
class DisableSSHDNSLookup(Task): class DisableSSHDNSLookup(Task):