mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 07:26:29 +00:00
Implemented network tasks
This commit is contained in:
parent
9ee096f262
commit
14d6f5fb4f
2 changed files with 40 additions and 1 deletions
|
@ -10,6 +10,7 @@ from tasks import locale
|
||||||
from tasks import apt
|
from tasks import apt
|
||||||
from tasks import boot
|
from tasks import boot
|
||||||
from tasks import security
|
from tasks import security
|
||||||
|
from tasks import network
|
||||||
|
|
||||||
|
|
||||||
def initialize():
|
def initialize():
|
||||||
|
@ -47,7 +48,10 @@ def tasks(tasklist, manifest):
|
||||||
boot.DisableGetTTYs(),
|
boot.DisableGetTTYs(),
|
||||||
security.EnableShadowConfig(),
|
security.EnableShadowConfig(),
|
||||||
security.DisableSSHPasswordAuthentication(),
|
security.DisableSSHPasswordAuthentication(),
|
||||||
security.DisableSSHDNSLookup())
|
security.DisableSSHDNSLookup(),
|
||||||
|
network.RemoveDNSInfo(),
|
||||||
|
network.ConfigureNetworkIF(),
|
||||||
|
network.ConfigureDHCP())
|
||||||
|
|
||||||
from common.tasks import TriggerRollback
|
from common.tasks import TriggerRollback
|
||||||
tasklist.add(TriggerRollback())
|
tasklist.add(TriggerRollback())
|
||||||
|
|
35
providers/ec2/tasks/network.py
Normal file
35
providers/ec2/tasks/network.py
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
from base import Task
|
||||||
|
from common import phases
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
|
||||||
|
class RemoveDNSInfo(Task):
|
||||||
|
description = 'Removing resolv.conf'
|
||||||
|
phase = phases.system_modification
|
||||||
|
|
||||||
|
def run(self, info):
|
||||||
|
from os import remove
|
||||||
|
remove(os.path.join(info.root, 'etc/resolv.conf'))
|
||||||
|
|
||||||
|
|
||||||
|
class ConfigureNetworkIF(Task):
|
||||||
|
description = 'Configuring network interfaces'
|
||||||
|
phase = phases.system_modification
|
||||||
|
|
||||||
|
def run(self, info):
|
||||||
|
interfaces_path = os.path.join(info.root, 'etc/network/interfaces')
|
||||||
|
if_config = {'squeeze': ('auto lo\niface lo inet loopback\n'
|
||||||
|
'auto eth0\niface eth0 inet dhcp'),
|
||||||
|
'wheezy': 'auto eth0\niface eth0 inet dhcp'}
|
||||||
|
with open(interfaces_path, 'a') as interfaces:
|
||||||
|
interfaces.write(if_config.get(info.manifest.system['release']))
|
||||||
|
|
||||||
|
|
||||||
|
class ConfigureDHCP(Task):
|
||||||
|
description = 'Configuring the DHCP client'
|
||||||
|
phase = phases.system_modification
|
||||||
|
|
||||||
|
def run(self, info):
|
||||||
|
from common.tools import sed_i
|
||||||
|
dhcpcd = os.path.join(info.root, 'etc/default/dhcpcd')
|
||||||
|
sed_i(dhcpcd, '^#*SET_DNS=.*', 'SET_DNS=\'yes\'')
|
Loading…
Add table
Reference in a new issue