mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 07:26:29 +00:00
[admin_user]: Update per comments
As requested, this commit converts to tab indentation. Signed-off-by: Manoj Srivastava <srivasta@golden-gryphon.com>
This commit is contained in:
parent
a56f20657b
commit
efeddc43a8
2 changed files with 120 additions and 113 deletions
|
@ -55,9 +55,11 @@ class AdminUserCredentialsPassword(Task):
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
log.debug('Setting the password for the admin user.')
|
||||
log_check_call(['chroot', info.root, 'chpasswd'],
|
||||
log_check_call(
|
||||
['chroot', info.root, 'chpasswd'],
|
||||
info.manifest.plugins['admin_user']['username'] +
|
||||
':' + info.manifest.plugins['admin_user']['password'])
|
||||
':' + info.manifest.plugins['admin_user']['password']
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
|
@ -79,27 +81,32 @@ class AdminUserCredentialsPublicKey(Task):
|
|||
log.debug('Copying public key from {path}'.format(path=full_path))
|
||||
|
||||
if 'ec2-get-credentials' in info.initd['install']:
|
||||
log.warn('You are using a static public key for the admin account.'
|
||||
log.warn(
|
||||
'You are using a static public key for the admin account.'
|
||||
' This will conflict with the ec2 public key injection mechanisn.'
|
||||
' The ec2-get-credentials startup script has therefore been disabled.')
|
||||
del info.initd['install']['ec2-get-credentials']
|
||||
|
||||
username = info.manifest.plugins['admin_user']['username']
|
||||
|
||||
ssh_file = os.path.join('/home/', username, '/.ssh/authorized_keys')
|
||||
ssh_file = os.path.join('/home/', username, '.ssh/authorized_keys')
|
||||
rel_ssh_file = os.path.realpath(info.root + '/%s' % ssh_file)
|
||||
|
||||
ssh_dir = os.path.dirname(ssh_file)
|
||||
rel_ssh_dir = os.path.realpath(info.root + '/%s' % ssh_dir)
|
||||
if not os.path.exists(rel_ssh_dir):
|
||||
log.debug('Creating %s mode 700' % rel_ssh_dir)
|
||||
os.mkdir(rel_ssh_dir, 0700)
|
||||
else:
|
||||
log.debug('Creating %s.' % rel_ssh_dir)
|
||||
os.mkdir(rel_ssh_dir)
|
||||
|
||||
log.debug('setting %s mode 700' % rel_ssh_dir)
|
||||
os.chmod(rel_ssh_dir, 0700)
|
||||
mode = (stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
||||
os.chmod(rel_ssh_dir, mode)
|
||||
|
||||
copy(full_path, rel_ssh_file)
|
||||
|
||||
mode = (stat.S_IRUSR | stat.S_IWUSR)
|
||||
os.chmod(rel_ssh_file, mode)
|
||||
|
||||
log_check_call(['chroot', info.root, 'chown', '-R', username, ssh_dir])
|
||||
return
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue