mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-10-07 17:40:30 +00:00
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:
parent
cd6e10c6a1
commit
237069b941
7 changed files with 66 additions and 6 deletions
|
@ -41,6 +41,12 @@
|
|||
"prebootstrapped": {
|
||||
"enabled": false,
|
||||
"snapshot": ""
|
||||
}
|
||||
},
|
||||
"user_packages": {
|
||||
"enabled": true,
|
||||
"repo": [ "apache2" ],
|
||||
"local": []
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
6
plugins/user_packages/__init__.py
Normal file
6
plugins/user_packages/__init__.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
|
||||
|
||||
def tasks(tasklist, manifest):
|
||||
from user_packages import AddUserPackages, AddLocalUserPackages
|
||||
tasklist.add(AddUserPackages())
|
||||
tasklist.add(AddLocalUserPackages())
|
45
plugins/user_packages/user_packages.py
Normal file
45
plugins/user_packages/user_packages.py
Normal 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)])
|
||||
|
|
@ -52,8 +52,7 @@ def tasks(tasklist, manifest):
|
|||
boot.DisableGetTTYs(),
|
||||
security.EnableShadowConfig(),
|
||||
security.SetRootPassword(),
|
||||
# Disable for the time of debugging
|
||||
#security.DisableSSHPasswordAuthentication(),
|
||||
security.DisableSSHPasswordAuthentication(),
|
||||
security.DisableSSHDNSLookup(),
|
||||
network.RemoveDNSInfo(),
|
||||
network.ConfigureNetworkIF(),
|
||||
|
|
|
@ -16,7 +16,7 @@ class GenerateLocale(Task):
|
|||
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)
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
from base import Task
|
||||
from common import phases
|
||||
import os
|
||||
from providers.one.tasks.locale import GenerateLocale
|
||||
|
||||
|
||||
class OpenNebulaContext(Task):
|
||||
description = 'Setup OpenNebula init context'
|
||||
phase = phases.system_modification
|
||||
after = [GenerateLocale]
|
||||
|
||||
def run(self, info):
|
||||
import stat
|
||||
|
|
|
@ -26,8 +26,10 @@ class DisableSSHPasswordAuthentication(Task):
|
|||
|
||||
def run(self, info):
|
||||
from common.tools import sed_i
|
||||
sshd_config_path = os.path.join(info.root, 'etc/ssh/sshd_config')
|
||||
sed_i(sshd_config_path, '^#PasswordAuthentication yes', 'PasswordAuthentication no')
|
||||
if 'root' not in info.manifest.credentials:
|
||||
# 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):
|
||||
|
|
Loading…
Add table
Reference in a new issue