mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-22 18:00:35 +00:00
Vagrant plugin creates its own user etc. now
There is no need to rely on other plugins any longer
This commit is contained in:
parent
e340a96db3
commit
dcae0e156e
4 changed files with 45 additions and 27 deletions
|
@ -33,13 +33,6 @@
|
|||
}
|
||||
},
|
||||
"plugins": {
|
||||
"admin_user": {
|
||||
"username": "vagrant"
|
||||
},
|
||||
"root_password": {
|
||||
"password": "vagrant"
|
||||
},
|
||||
"vagrant": {
|
||||
}
|
||||
"vagrant": {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,9 @@ def resolve_tasks(taskset, manifest):
|
|||
from common.tasks import volume
|
||||
taskset.update([tasks.CreateVagrantBoxDir,
|
||||
tasks.AddPackages,
|
||||
tasks.CreateVagrantUser,
|
||||
tasks.PasswordlessSudo,
|
||||
tasks.SetRootPassword,
|
||||
tasks.AddInsecurePublicKey,
|
||||
tasks.PackageBox,
|
||||
tasks.RemoveVagrantBoxDir,
|
||||
|
|
|
@ -18,22 +18,6 @@
|
|||
}
|
||||
},
|
||||
"required": ["backing"]
|
||||
},
|
||||
"plugins": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"root_password": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"password": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": ["password"]
|
||||
}
|
||||
},
|
||||
"required": ["root_password"]
|
||||
}
|
||||
},
|
||||
"required": ["plugins"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ from base import Task
|
|||
from common import phases
|
||||
from common.tasks import workspace
|
||||
from common.tasks import apt
|
||||
from plugins.admin_user.tasks import CreateAdminUser
|
||||
import os
|
||||
import shutil
|
||||
|
||||
|
@ -28,12 +27,41 @@ class AddPackages(Task):
|
|||
@classmethod
|
||||
def run(cls, info):
|
||||
info.packages.add('openssh-server')
|
||||
info.packages.add('sudo')
|
||||
info.packages.add('nfs-client')
|
||||
|
||||
|
||||
class CreateVagrantUser(Task):
|
||||
description = 'Creating the vagrant user'
|
||||
phase = phases.system_modification
|
||||
|
||||
@classmethod
|
||||
def run(cls, info):
|
||||
from common.tools import log_check_call
|
||||
log_check_call(['/usr/sbin/chroot', info.root,
|
||||
'/usr/sbin/useradd',
|
||||
'--create-home', '--shell', '/bin/bash',
|
||||
'vagrant'])
|
||||
|
||||
|
||||
class PasswordlessSudo(Task):
|
||||
description = 'Allowing the vagrant user to use sudo without a password'
|
||||
phase = phases.system_modification
|
||||
|
||||
@classmethod
|
||||
def run(cls, info):
|
||||
sudo_vagrant_path = os.path.join(info.root, 'etc/sudoers.d/vagrant')
|
||||
with open(sudo_vagrant_path, 'w') as sudo_vagrant:
|
||||
sudo_vagrant.write('vagrant ALL=(ALL) NOPASSWD:ALL')
|
||||
import stat
|
||||
ug_read_only = (stat.S_IRUSR | stat.S_IRGRP)
|
||||
os.chmod(sudo_vagrant_path, ug_read_only)
|
||||
|
||||
|
||||
class AddInsecurePublicKey(Task):
|
||||
description = 'Adding vagrant insecure public key'
|
||||
phase = phases.system_modification
|
||||
predecessors = [CreateAdminUser]
|
||||
predecessors = [CreateVagrantUser]
|
||||
|
||||
@classmethod
|
||||
def run(cls, info):
|
||||
|
@ -49,6 +77,16 @@ class AddInsecurePublicKey(Task):
|
|||
authorized_keys.write(insecure_public_key)
|
||||
|
||||
|
||||
class SetRootPassword(Task):
|
||||
description = 'Setting the root password to `vagrant\''
|
||||
phase = phases.system_modification
|
||||
|
||||
@classmethod
|
||||
def run(cls, info):
|
||||
from common.tools import log_check_call
|
||||
log_check_call(['/usr/sbin/chroot', info.root, '/usr/sbin/chpasswd'], 'root:vagrant')
|
||||
|
||||
|
||||
class PackageBox(Task):
|
||||
description = 'Packaging the volume as a vagrant box'
|
||||
phase = phases.image_registration
|
||||
|
|
Loading…
Add table
Reference in a new issue