mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-10-07 17:40:30 +00:00
parent
69a76f2597
commit
18fce45d91
9 changed files with 40 additions and 31 deletions
|
@ -29,12 +29,16 @@
|
||||||
"sections": {
|
"sections": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"minItems": 1
|
"minItems": 1
|
||||||
},
|
},
|
||||||
"architecture": { "enum": ["i386", "amd64"] },
|
"architecture": { "enum": ["i386", "amd64"] },
|
||||||
"bootloader": { "enum": ["pvgrub", "grub", "extlinux"] },
|
"bootloader": { "enum": ["pvgrub", "grub", "extlinux"] },
|
||||||
"timezone": { "type": "string" },
|
"timezone": { "type": "string" },
|
||||||
"locale": { "type": "string" },
|
"locale": { "type": "string" },
|
||||||
"charmap": { "type": "string" }
|
"charmap": { "type": "string" },
|
||||||
|
"hostname": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^\\S+$"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"required": ["release", "architecture", "bootloader", "timezone", "locale", "charmap"]
|
"required": ["release", "architecture", "bootloader", "timezone", "locale", "charmap"]
|
||||||
},
|
},
|
||||||
|
|
|
@ -23,6 +23,22 @@ class RemoveHostname(Task):
|
||||||
os.remove(os.path.join(info.root, 'etc/hostname'))
|
os.remove(os.path.join(info.root, 'etc/hostname'))
|
||||||
|
|
||||||
|
|
||||||
|
class SetHostname(Task):
|
||||||
|
description = 'Writing hostname into the hostname file'
|
||||||
|
phase = phases.system_modification
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def run(cls, info):
|
||||||
|
hostname = info.manifest.system['hostname'].format(**info.manifest_vars)
|
||||||
|
hostname_file_path = os.path.join(info.root, 'etc/hostname')
|
||||||
|
with open(hostname_file_path, 'w') as hostname_file:
|
||||||
|
hostname_file.write(hostname)
|
||||||
|
|
||||||
|
hosts_path = os.path.join(info.root, 'etc/hosts')
|
||||||
|
from bootstrapvz.common.tools import sed_i
|
||||||
|
sed_i(hosts_path, '^127.0.0.1\tlocalhost$', '127.0.0.1\tlocalhost\n127.0.1.1\t' + hostname)
|
||||||
|
|
||||||
|
|
||||||
class ConfigureNetworkIF(Task):
|
class ConfigureNetworkIF(Task):
|
||||||
description = 'Configuring network interfaces'
|
description = 'Configuring network interfaces'
|
||||||
phase = phases.system_modification
|
phase = phases.system_modification
|
||||||
|
|
|
@ -13,13 +13,11 @@ def resolve_tasks(taskset, manifest):
|
||||||
from bootstrapvz.common.tasks import network
|
from bootstrapvz.common.tasks import network
|
||||||
taskset.discard(security.DisableSSHPasswordAuthentication)
|
taskset.discard(security.DisableSSHPasswordAuthentication)
|
||||||
taskset.discard(loopback.MoveImage)
|
taskset.discard(loopback.MoveImage)
|
||||||
taskset.discard(network.RemoveHostname)
|
|
||||||
|
|
||||||
from bootstrapvz.common.tasks import volume
|
from bootstrapvz.common.tasks import volume
|
||||||
taskset.update([tasks.CheckBoxPath,
|
taskset.update([tasks.CheckBoxPath,
|
||||||
tasks.CreateVagrantBoxDir,
|
tasks.CreateVagrantBoxDir,
|
||||||
tasks.AddPackages,
|
tasks.AddPackages,
|
||||||
tasks.SetHostname,
|
|
||||||
tasks.CreateVagrantUser,
|
tasks.CreateVagrantUser,
|
||||||
tasks.PasswordlessSudo,
|
tasks.PasswordlessSudo,
|
||||||
tasks.SetRootPassword,
|
tasks.SetRootPassword,
|
||||||
|
|
|
@ -25,12 +25,7 @@
|
||||||
"vagrant": {
|
"vagrant": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"hostname": {
|
}
|
||||||
"type": "string",
|
|
||||||
"pattern": "^\\S+$"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": ["hostname"]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,22 +48,6 @@ class AddPackages(Task):
|
||||||
info.packages.add('nfs-client')
|
info.packages.add('nfs-client')
|
||||||
|
|
||||||
|
|
||||||
class SetHostname(Task):
|
|
||||||
description = 'Writing hostname into the hostname file'
|
|
||||||
phase = phases.system_modification
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def run(cls, info):
|
|
||||||
hostname = info.manifest.plugins['vagrant']['hostname'].format(**info.manifest_vars)
|
|
||||||
hostname_file_path = os.path.join(info.root, 'etc/hostname')
|
|
||||||
with open(hostname_file_path, 'w') as hostname_file:
|
|
||||||
hostname_file.write(hostname)
|
|
||||||
|
|
||||||
hosts_path = os.path.join(info.root, 'etc/hosts')
|
|
||||||
from bootstrapvz.common.tools import sed_i
|
|
||||||
sed_i(hosts_path, '^127.0.0.1\tlocalhost$', '127.0.0.1\tlocalhost\n127.0.0.1\t' + hostname)
|
|
||||||
|
|
||||||
|
|
||||||
class CreateVagrantUser(Task):
|
class CreateVagrantUser(Task):
|
||||||
description = 'Creating the vagrant user'
|
description = 'Creating the vagrant user'
|
||||||
phase = phases.system_modification
|
phase = phases.system_modification
|
||||||
|
|
|
@ -61,6 +61,11 @@ def resolve_tasks(taskset, manifest):
|
||||||
if manifest.volume['partitions']['type'] != 'none':
|
if manifest.volume['partitions']['type'] != 'none':
|
||||||
taskset.update(task_sets.partitioning_set)
|
taskset.update(task_sets.partitioning_set)
|
||||||
|
|
||||||
|
if manifest.system.get('hostname', False):
|
||||||
|
taskset.add(network.SetHostname)
|
||||||
|
else:
|
||||||
|
taskset.add(network.RemoveHostname)
|
||||||
|
|
||||||
taskset.update([tasks.host.AddExternalCommands,
|
taskset.update([tasks.host.AddExternalCommands,
|
||||||
tasks.packages.DefaultPackages,
|
tasks.packages.DefaultPackages,
|
||||||
tasks.connection.GetCredentials,
|
tasks.connection.GetCredentials,
|
||||||
|
@ -72,7 +77,6 @@ def resolve_tasks(taskset, manifest):
|
||||||
boot.DisableGetTTYs,
|
boot.DisableGetTTYs,
|
||||||
security.EnableShadowConfig,
|
security.EnableShadowConfig,
|
||||||
network.RemoveDNSInfo,
|
network.RemoveDNSInfo,
|
||||||
network.RemoveHostname,
|
|
||||||
network.ConfigureNetworkIF,
|
network.ConfigureNetworkIF,
|
||||||
tasks.network.EnableDHCPCDDNS,
|
tasks.network.EnableDHCPCDDNS,
|
||||||
initd.AddExpandRoot,
|
initd.AddExpandRoot,
|
||||||
|
|
|
@ -37,6 +37,11 @@ def resolve_tasks(tasklist, manifest):
|
||||||
if manifest.volume['partitions']['type'] != 'none':
|
if manifest.volume['partitions']['type'] != 'none':
|
||||||
tasklist.update(task_sets.partitioning_set)
|
tasklist.update(task_sets.partitioning_set)
|
||||||
|
|
||||||
|
if manifest.system.get('hostname', False):
|
||||||
|
tasklist.add(network.SetHostname)
|
||||||
|
else:
|
||||||
|
tasklist.add(network.RemoveHostname)
|
||||||
|
|
||||||
tasklist.update([tasks.packages.DefaultPackages,
|
tasklist.update([tasks.packages.DefaultPackages,
|
||||||
|
|
||||||
loopback.Create,
|
loopback.Create,
|
||||||
|
@ -44,7 +49,6 @@ def resolve_tasks(tasklist, manifest):
|
||||||
security.EnableShadowConfig,
|
security.EnableShadowConfig,
|
||||||
network.RemoveDNSInfo,
|
network.RemoveDNSInfo,
|
||||||
network.ConfigureNetworkIF,
|
network.ConfigureNetworkIF,
|
||||||
network.RemoveHostname,
|
|
||||||
initd.AddSSHKeyGeneration,
|
initd.AddSSHKeyGeneration,
|
||||||
initd.InstallInitScripts,
|
initd.InstallInitScripts,
|
||||||
cleanup.ClearMOTD,
|
cleanup.ClearMOTD,
|
||||||
|
|
|
@ -37,6 +37,11 @@ def resolve_tasks(taskset, manifest):
|
||||||
if manifest.volume['partitions']['type'] != 'none':
|
if manifest.volume['partitions']['type'] != 'none':
|
||||||
taskset.update(task_sets.partitioning_set)
|
taskset.update(task_sets.partitioning_set)
|
||||||
|
|
||||||
|
if manifest.system.get('hostname', False):
|
||||||
|
taskset.add(network.SetHostname)
|
||||||
|
else:
|
||||||
|
taskset.add(network.RemoveHostname)
|
||||||
|
|
||||||
taskset.update([tasks.packages.DefaultPackages,
|
taskset.update([tasks.packages.DefaultPackages,
|
||||||
|
|
||||||
loopback.Create,
|
loopback.Create,
|
||||||
|
@ -44,7 +49,6 @@ def resolve_tasks(taskset, manifest):
|
||||||
security.EnableShadowConfig,
|
security.EnableShadowConfig,
|
||||||
network.RemoveDNSInfo,
|
network.RemoveDNSInfo,
|
||||||
network.ConfigureNetworkIF,
|
network.ConfigureNetworkIF,
|
||||||
network.RemoveHostname,
|
|
||||||
initd.AddSSHKeyGeneration,
|
initd.AddSSHKeyGeneration,
|
||||||
initd.InstallInitScripts,
|
initd.InstallInitScripts,
|
||||||
cleanup.ClearMOTD,
|
cleanup.ClearMOTD,
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
"bootloader": "grub",
|
"bootloader": "grub",
|
||||||
"timezone": "UTC",
|
"timezone": "UTC",
|
||||||
"locale": "en_US",
|
"locale": "en_US",
|
||||||
"charmap": "UTF-8"
|
"charmap": "UTF-8",
|
||||||
|
"hostname": "localhost"
|
||||||
},
|
},
|
||||||
"packages": {},
|
"packages": {},
|
||||||
"volume": {
|
"volume": {
|
||||||
|
@ -34,7 +35,6 @@
|
||||||
},
|
},
|
||||||
"plugins": {
|
"plugins": {
|
||||||
"vagrant": {
|
"vagrant": {
|
||||||
"hostname": "localhost"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue