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
|
@ -34,7 +34,11 @@
|
|||
"bootloader": { "enum": ["pvgrub", "grub", "extlinux"] },
|
||||
"timezone": { "type": "string" },
|
||||
"locale": { "type": "string" },
|
||||
"charmap": { "type": "string" }
|
||||
"charmap": { "type": "string" },
|
||||
"hostname": {
|
||||
"type": "string",
|
||||
"pattern": "^\\S+$"
|
||||
}
|
||||
},
|
||||
"required": ["release", "architecture", "bootloader", "timezone", "locale", "charmap"]
|
||||
},
|
||||
|
|
|
@ -23,6 +23,22 @@ class RemoveHostname(Task):
|
|||
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):
|
||||
description = 'Configuring network interfaces'
|
||||
phase = phases.system_modification
|
||||
|
|
|
@ -13,13 +13,11 @@ def resolve_tasks(taskset, manifest):
|
|||
from bootstrapvz.common.tasks import network
|
||||
taskset.discard(security.DisableSSHPasswordAuthentication)
|
||||
taskset.discard(loopback.MoveImage)
|
||||
taskset.discard(network.RemoveHostname)
|
||||
|
||||
from bootstrapvz.common.tasks import volume
|
||||
taskset.update([tasks.CheckBoxPath,
|
||||
tasks.CreateVagrantBoxDir,
|
||||
tasks.AddPackages,
|
||||
tasks.SetHostname,
|
||||
tasks.CreateVagrantUser,
|
||||
tasks.PasswordlessSudo,
|
||||
tasks.SetRootPassword,
|
||||
|
|
|
@ -25,12 +25,7 @@
|
|||
"vagrant": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"hostname": {
|
||||
"type": "string",
|
||||
"pattern": "^\\S+$"
|
||||
}
|
||||
},
|
||||
"required": ["hostname"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,22 +48,6 @@ class AddPackages(Task):
|
|||
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):
|
||||
description = 'Creating the vagrant user'
|
||||
phase = phases.system_modification
|
||||
|
|
|
@ -61,6 +61,11 @@ def resolve_tasks(taskset, manifest):
|
|||
if manifest.volume['partitions']['type'] != 'none':
|
||||
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,
|
||||
tasks.packages.DefaultPackages,
|
||||
tasks.connection.GetCredentials,
|
||||
|
@ -72,7 +77,6 @@ def resolve_tasks(taskset, manifest):
|
|||
boot.DisableGetTTYs,
|
||||
security.EnableShadowConfig,
|
||||
network.RemoveDNSInfo,
|
||||
network.RemoveHostname,
|
||||
network.ConfigureNetworkIF,
|
||||
tasks.network.EnableDHCPCDDNS,
|
||||
initd.AddExpandRoot,
|
||||
|
|
|
@ -37,6 +37,11 @@ def resolve_tasks(tasklist, manifest):
|
|||
if manifest.volume['partitions']['type'] != 'none':
|
||||
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,
|
||||
|
||||
loopback.Create,
|
||||
|
@ -44,7 +49,6 @@ def resolve_tasks(tasklist, manifest):
|
|||
security.EnableShadowConfig,
|
||||
network.RemoveDNSInfo,
|
||||
network.ConfigureNetworkIF,
|
||||
network.RemoveHostname,
|
||||
initd.AddSSHKeyGeneration,
|
||||
initd.InstallInitScripts,
|
||||
cleanup.ClearMOTD,
|
||||
|
|
|
@ -37,6 +37,11 @@ def resolve_tasks(taskset, manifest):
|
|||
if manifest.volume['partitions']['type'] != 'none':
|
||||
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,
|
||||
|
||||
loopback.Create,
|
||||
|
@ -44,7 +49,6 @@ def resolve_tasks(taskset, manifest):
|
|||
security.EnableShadowConfig,
|
||||
network.RemoveDNSInfo,
|
||||
network.ConfigureNetworkIF,
|
||||
network.RemoveHostname,
|
||||
initd.AddSSHKeyGeneration,
|
||||
initd.InstallInitScripts,
|
||||
cleanup.ClearMOTD,
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
"bootloader": "grub",
|
||||
"timezone": "UTC",
|
||||
"locale": "en_US",
|
||||
"charmap": "UTF-8"
|
||||
"charmap": "UTF-8",
|
||||
"hostname": "localhost"
|
||||
},
|
||||
"packages": {},
|
||||
"volume": {
|
||||
|
@ -34,7 +35,6 @@
|
|||
},
|
||||
"plugins": {
|
||||
"vagrant": {
|
||||
"hostname": "localhost"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue