Open mikeytown2 opened 5 years ago
Vultr is now using DHCP for ipv6; making editing netplan a lot harder.
#!/usr/bin/env python
import pyaml
import yaml
import sys
with open(sys.argv[1], 'r') as stream:
try:
config = yaml.safe_load(stream)
if sys.argv[2] == "":
if len(config['network']['ethernets']) == 1:
sys.argv[2] = next(iter(config['network']['ethernets']))
if config['network']['ethernets'][sys.argv[2]].has_key('addresses'):
if sys.argv[3] not in config['network']['ethernets'][sys.argv[2]]['addresses']:
config['network']['ethernets'][sys.argv[2]]['addresses'].append(sys.argv[3])
else:
config['network']['ethernets'][sys.argv[2]]['addresses'] = sys.argv[3]
print pyaml.dump(config)
newconfig = open(sys.argv[1], 'w')
newconfig.write(pyaml.dump(config))
except yaml.YAMLError as exc:
print(exc)
That will add the address but odds are it'll break existing connections.
Need to detect if vultr and give directions on what to do. Same for digital ocean
Should be using new ones