From b062583254dfb6ed074015f4ad06402d7733ce62 Mon Sep 17 00:00:00 2001 From: shadowfax-chc Date: Fri, 11 Jan 2013 02:59:07 -0500 Subject: [PATCH] Added function to makeconf module to remove a var Allows for completely removing a variable from the make.conf file --- salt/modules/makeconf.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/salt/modules/makeconf.py b/salt/modules/makeconf.py index 48ba8af434..64112c96b8 100644 --- a/salt/modules/makeconf.py +++ b/salt/modules/makeconf.py @@ -71,6 +71,29 @@ def set_var(var, value): new_value = get_var(var) return {var: {'old': old_value, 'new': new_value}} +def remove_var(var): + ''' + Remove a variable from the make.conf + + Return a dict containing the new value for the variable:: + + {'': {'old': '', + 'new': ''}} + CLI Example:: + + salt '*' makeconf.remove_var 'LINGUAS' + ''' + makeconf = _get_makeconf() + + old_value = get_var(var) + + # If var is in file + if old_value is not None: + __salt__['file.sed'](makeconf, '^{0}=.*'.format(var), '') + + new_value = get_var(var) + return {var: {'old': old_value, 'new': new_value}} + def append_var(var, value): ''' Add to or create a new variable in the make.conf