Be more flexible when checking if Apache Debian-style mod is enabled

This commit is contained in:
Alexandre Garnier 2015-11-14 19:28:50 +01:00
parent 05a15bf564
commit 450c821432
2 changed files with 9 additions and 4 deletions

View File

@ -151,10 +151,15 @@ def check_mod_enabled(mod):
.. code-block:: bash
salt '*' apache.check_mod_enabled status.conf
salt '*' apache.check_mod_enabled status
salt '*' apache.check_mod_enabled status.load
salt '*' apache.check_mod_enabled status.conf
'''
return os.path.islink('/etc/apache2/mods-enabled/{0}'.format(mod))
if mod.endswith('.load') or mod.endswith('.conf'):
mod_file = mod
else:
mod_file = '{0}.load'.format(mod)
return os.path.islink('/etc/apache2/mods-enabled/{0}'.format(mod_file))
def a2enmod(mod):

View File

@ -36,7 +36,7 @@ def enable(name):
'''
ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
is_enabled = __salt__['apache.check_mod_enabled']('{0}.load'.format(name))
is_enabled = __salt__['apache.check_mod_enabled'](name)
if not is_enabled:
if __opts__['test']:
msg = 'Apache module {0} is set to be enabled.'.format(name)
@ -70,7 +70,7 @@ def disable(name):
'''
ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
is_enabled = __salt__['apache.check_mod_enabled']('{0}.load'.format(name))
is_enabled = __salt__['apache.check_mod_enabled'](name)
if is_enabled:
if __opts__['test']:
msg = 'Apache module {0} is set to be disabled.'.format(name)