Added password-crypted to root-password plugin

This commit is contained in:
Alex Hegedus 2017-11-28 09:38:15 -08:00
parent 9445273b8e
commit f95f62588b
4 changed files with 25 additions and 4 deletions

View file

@ -6,6 +6,15 @@ SSH password authentication.
Settings
~~~~~~~~
``oneOf``
- ``password``: The password for the root user.
``required``
- ``password-crypted``: The password for the root user[crypt(3) hash]
The following command (available from the **whois** package) can be used
to generate a SHA-512 based crypt(3) hash for a password:
.. code-block:: shell
mkpasswd -m sha-512

View file

@ -8,7 +8,11 @@ properties:
properties:
root_password:
type: object
oneOf:
- required: [password]
- required: [password-crypted]
properties:
password: {type: string}
required: [password]
properties:
password-crypted: {type: string}
additionalProperties: false

View file

@ -9,5 +9,11 @@ class SetRootPassword(Task):
@classmethod
def run(cls, info):
from bootstrapvz.common.tools import log_check_call
log_check_call(['chroot', info.root, 'chpasswd'],
'root:' + info.manifest.plugins['root_password']['password'])
password_crypted = info.manifest.plugins['root_password'].get('password-crypted', None)
if password_crypted is not None:
log_check_call(['chpasswd', '--root', info.root, '--encrypted'],
'root:' + password_crypted)
else:
log_check_call(['chroot', info.root, 'chpasswd'],
'root:' + info.manifest.plugins['root_password']['password'])

View file

@ -28,3 +28,5 @@ volume:
packages: {}
plugins:
vagrant: {}
root_password:
password-crypted: $6$MU3jLtZHS$UHdibqwOJrZw5yI7cqzG.AnzWqOVD9krryd3Y/SgXDSHUEMsaT7iAiQHhuCpjN4Q0tEssbJYoy4H1QFxOY3Tc/