show exceptions in state

This commit is contained in:
Andrea-Redi Tsarida 2015-03-29 18:02:54 +02:00
parent a7c0641b06
commit 122109f6e8
2 changed files with 7 additions and 4 deletions

View File

@ -197,7 +197,7 @@ def create_user(user_name, path=None, region=None, key=None, keyid=None,
return False
def delete_user(user_name, path=None, region=None, key=None, keyid=None,
def delete_user(user_name, region=None, key=None, keyid=None,
profile=None):
'''
Delete a user
@ -216,7 +216,7 @@ def delete_user(user_name, path=None, region=None, key=None, keyid=None,
except boto.exception.BotoServerError as e:
log.debug(e)
log.error('Failed to delete user {0}'.format(user_name))
return False
return e
def get_user(user_name=None, region=None, key=None, keyid=None, profile=None):

View File

@ -110,17 +110,20 @@ def user_absent(name, region=None, key=None, keyid=None, profile=None):
'''
ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
if not __salt__['boto_iam.get_user'](name, region, key, keyid, profile):
ret['result'] = True
ret['comment'] = 'IAM User {0} does not exist.'.format(name)
return ret
if __opts__['test']:
ret['comment'] = 'IAM user {0} is set to be deleted.'.format(name)
ret['result'] = None
return ret
if __salt__['boto_iam.delete_user'](name, region, key, keyid, profile):
deleted = __salt__['boto_iam.delete_user'](name, region, key, keyid, profile)
if deleted is True:
ret['comment'] = 'IAM user {0} is deleted.'.format(name)
ret['result'] = True
ret['changes']['deleted'] = name
return ret
ret['comment'] = 'IAM user {0} could not be deleted.'.format(name)
ret['comment'] = 'IAM user {0} could not be deleted.\n {1}'.format(name, deleted)
ret['result'] = False
return ret