Merge pull request #6379 from doublerr/apacheTasks

fix spacing, switch to cmd.retcode
This commit is contained in:
Thomas S Hatch 2013-07-27 16:40:05 -07:00
commit 1040387b8a

View File

@ -251,60 +251,60 @@ def userdel(pwfile, user):
out = __salt__['cmd.run'](cmd).splitlines()
return out
def check_site_enabled(site):
'''
Checks to see if the specific Site symlink is in /etc/apache2/sites-enabled
'''
if os.path.islink('/etc/apache2/sites-enabled/{0}'.format(site)):
return True
elif (site == 'default' and os.path.islink('/etc/apache2/sites-enabled/000-{0}'.format(site))):
return True
else:
return False
'''
Checks to see if the specific Site symlink is in /etc/apache2/sites-enabled
'''
if os.path.islink('/etc/apache2/sites-enabled/{0}'.format(site)):
return True
elif (site == 'default' and os.path.islink('/etc/apache2/sites-enabled/000-{0}'.format(site))):
return True
else:
return False
def a2ensite(site):
''' Runs a2ensite for the given site '''
ret = {}
command = 'a2ensite {0}'.format(site)
try:
status = __salt__['cmd.run'](command)
except Exception as e:
return e
ret['Name'] = 'Apache2 Enable Site'
ret['Site'] = site
if status == 1:
ret['Status'] = 'Site {0} Not found'.format(site)
elif status == 0:
ret['Status'] = 'Site {0} enabled'.format(site)
else:
ret['Status'] = status
return ret
''' Runs a2ensite for the given site '''
ret = {}
command = 'a2ensite {0}'.format(site)
try:
status = __salt__['cmd.retcode'](command)
except Exception as e:
return e
ret['Name'] = 'Apache2 Enable Site'
ret['Site'] = site
if status == 1:
ret['Status'] = 'Site {0} Not found'.format(site)
elif status == 0:
ret['Status'] = 'Site {0} enabled'.format(site)
else:
ret['Status'] = status
return ret
def a2dissite(site):
''' Runs a2dissite for the given site '''
ret = {}
command = 'a2dissite {0}'.format(site)
try:
status = __salt__['cmd.run'](command)
except Exception as e:
return e
ret['Name'] = 'Apache2 Disable Site'
ret['Site'] = site
if status == 256:
ret['Status'] = 'Site {0} Not found'.format(site)
elif status == 0:
ret['Status'] = 'Site {0} disabled'.format(site)
else:
ret['Status'] = status
return ret
''' Runs a2dissite for the given site '''
ret = {}
command = 'a2dissite {0}'.format(site)
try:
status = __salt__['cmd.retcode'](command)
except Exception as e:
return e
ret['Name'] = 'Apache2 Disable Site'
ret['Site'] = site
if status == 256:
ret['Status'] = 'Site {0} Not found'.format(site)
elif status == 0:
ret['Status'] = 'Site {0} disabled'.format(site)
else:
ret['Status'] = status
return ret