Commit da83f1d8 authored by Joanne Hugé's avatar Joanne Hugé

playbook/ors: fix conflicts with configure-slapos and vifib playbook

parent b93fcda6
...@@ -7,7 +7,6 @@ CONF_PATH = "/etc/opt/slapos/slapos.cfg" ...@@ -7,7 +7,6 @@ CONF_PATH = "/etc/opt/slapos/slapos.cfg"
ors_config = { ors_config = {
'slapformat': { 'slapformat': {
'create_tun': 'True', 'create_tun': 'True',
'create_tap': 'False',
'partition_amount': '20', 'partition_amount': '20',
}, },
'networkcache': { 'networkcache': {
...@@ -17,28 +16,32 @@ https://lab.node.vifib.com/nexedi/slapos/raw/1.0.''', ...@@ -17,28 +16,32 @@ https://lab.node.vifib.com/nexedi/slapos/raw/1.0.''',
}, },
} }
config = configparser.ConfigParser() with open('/opt/upgrader/configure-slapos.log', 'w+') as l:
config.read(CONF_PATH)
def is_slapformat_valid(): l.write("[configure-slapos] Configuring slapos...\n")
config = configparser.ConfigParser()
config.read(CONF_PATH)
def is_slapformat_valid():
for k in ors_config['slapformat']: for k in ors_config['slapformat']:
if ors_config['slapformat'][k] != \ if ors_config['slapformat'][k] != \
config.setdefault('slapformat', {}).setdefault(k, ''): config.setdefault('slapformat', {}).setdefault(k, ''):
l.write("[configure-slapos] {} not valid ( {} != {} )\n".format(k, ors_config['slapformat'][k], config.setdefault('slapformat', {}).setdefault(k, '')))
return False return False
return True return True
slapformat_valid = is_slapformat_valid() slapformat_valid = is_slapformat_valid()
config['slapformat'].update(ors_config['slapformat']) config['slapformat'].update(ors_config['slapformat'])
config['networkcache'].update(ors_config['networkcache']) config['networkcache'].update(ors_config['networkcache'])
with open(CONF_PATH, 'w+') as f: with open(CONF_PATH, 'w+') as f:
config.write(f) config.write(f)
if not slapformat_valid:
# Delete routes if not slapformat_valid:
s = subprocess.run(['ip', 'route'], check=True, capture_output=True) l.write("[configure-slapos] slapos.cfg not valid\n")
for r in s.stdout.decode().split('\n'): # Delete slaptun devices
if "slaptun" in r: for i in range(0,19):
l = r.split(' ') subprocess.run(['ip', 'link', 'delete', 'slaptun'])
subprocess.run(['ip', 'route', 'del',] + l[:l.index('dev') + 2], check=True)
subprocess.run(['rm', '-f', '/opt/slapos/slapos.xml'], check=True) subprocess.run(['rm', '-f', '/opt/slapos/slapos.xml'], check=True)
subprocess.run(['slapos', 'node', 'format', '--now'], check=True, capture_output=True) subprocess.run(['slapos', 'node', 'format', '--now'], check=True, capture_output=True)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment