Set write_needed flag correctly, include newline in so-status.conf string

This commit is contained in:
William Wernert
2021-07-29 14:59:26 -04:00
parent e38219aa2e
commit b30f771fa2

View File

@@ -106,12 +106,12 @@ def mod_so_status(action: str, items: str):
containers = conf.readlines() containers = conf.readlines()
for item in items: for item in items:
if f'so-{item}' in containers: if f'so-{item}\n' in containers:
if action == 'remove': containers.remove(f'so-{item}') if action == 'remove': containers.remove(f'so-{item}\n')
if action == 'add': pass if action == 'add': pass
else: else:
if action == 'remove': pass if action == 'remove': pass
if action == 'add': containers.append(f'so-{item}') if action == 'add': containers.append(f'so-{item}\n')
conf.seek(0) conf.seek(0)
conf.truncate(0) conf.truncate(0)
@@ -180,7 +180,7 @@ def enable_disable_modules(args, enable: bool):
else: else:
pillar_modules[module]['enabled'] = enable pillar_modules[module]['enabled'] = enable
mod_so_status(action_str, module) mod_so_status(action_str, module)
write_needed = enable write_needed = True
if write_needed: if write_needed:
args.pillar_dict.update() args.pillar_dict.update()
write_pillar(args.pillar, args.pillar_dict) write_pillar(args.pillar, args.pillar_dict)