mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 07:26:29 +00:00
Make admin_user plugin more robust
Don't fail if the ec2-get-credentials script is not installed Don't fail if SSH server is not installed
This commit is contained in:
parent
abe6a5fef3
commit
1e0aa634d2
2 changed files with 16 additions and 4 deletions
|
@ -8,8 +8,11 @@ def validate_manifest(data, schema_validate):
|
||||||
|
|
||||||
def resolve_tasks(tasklist, manifest):
|
def resolve_tasks(tasklist, manifest):
|
||||||
import tasks
|
import tasks
|
||||||
|
from providers.ec2.tasks import initd
|
||||||
|
if initd.AddEC2InitScripts in tasklist.tasks:
|
||||||
|
tasklist.add(tasks.AdminUserCredentials)
|
||||||
|
|
||||||
tasklist.add(tasks.AddSudoPackage,
|
tasklist.add(tasks.AddSudoPackage,
|
||||||
tasks.CreateAdminUser,
|
tasks.CreateAdminUser,
|
||||||
tasks.PasswordlessSudo,
|
tasks.PasswordlessSudo,
|
||||||
tasks.AdminUserCredentials,
|
|
||||||
tasks.DisableRootLogin)
|
tasks.DisableRootLogin)
|
||||||
|
|
|
@ -59,6 +59,15 @@ class DisableRootLogin(Task):
|
||||||
phase = phases.system_modification
|
phase = phases.system_modification
|
||||||
|
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
from common.tools import sed_i
|
from subprocess import CalledProcessError
|
||||||
sshdconfig_path = os.path.join(info.root, 'etc/ssh/sshd_config')
|
from common.tools import log_check_call
|
||||||
sed_i(sshdconfig_path, 'PermitRootLogin yes', 'PermitRootLogin no')
|
try:
|
||||||
|
log_check_call(['/usr/sbin/chroot', info.root,
|
||||||
|
'/usr/bin/dpkg-query', '-W', 'openssh-server'])
|
||||||
|
from common.tools import sed_i
|
||||||
|
sshdconfig_path = os.path.join(info.root, 'etc/ssh/sshd_config')
|
||||||
|
sed_i(sshdconfig_path, 'PermitRootLogin yes', 'PermitRootLogin no')
|
||||||
|
except CalledProcessError:
|
||||||
|
import logging
|
||||||
|
logging.getLogger(__name__).warn('The OpenSSH server has not been installed, '
|
||||||
|
'not disabling SSH root login.')
|
||||||
|
|
Loading…
Add table
Reference in a new issue