mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
fix syntax issue and formatting for mysql_grants state
We may want to consider merging these mysql states into 1
This commit is contained in:
parent
96e0c64210
commit
90a74c33a3
@ -28,17 +28,33 @@ def present(name,
|
||||
ret = {'name': name,
|
||||
'changes': {},
|
||||
'result': True,
|
||||
'comment': 'Grant {0} for {1}@{2} on {3} is already present'.format(grant,user,host,database,)}
|
||||
'comment': 'Grant {0} for {1}@{2} on {3} is already present'.format(
|
||||
grant,
|
||||
user,
|
||||
host,
|
||||
database
|
||||
)
|
||||
}
|
||||
# check if grant exists
|
||||
if __salt__['mysql.grant_exists'](grant,database,user,host):
|
||||
return ret
|
||||
|
||||
# The grant is not present, make it!
|
||||
if __salt__['mysql.grant_add'](grant,database,user,host)
|
||||
ret['comment'] = 'Grant {0} for {1}@{2} on {3} has been added'.format(grant,user,host,database,)
|
||||
if __salt__['mysql.grant_add'](grant,database,user,host):
|
||||
ret['comment'] = 'Grant {0} for {1}@{2} on {3} has been added'.format(
|
||||
grant,
|
||||
user,
|
||||
host,
|
||||
database
|
||||
)
|
||||
ret['changes'][name] = 'Present'
|
||||
else:
|
||||
ret['comment'] = 'Failed to grant {0} for {1}@{2} on {3}'.format(grant,user,host,database,)
|
||||
ret['comment'] = 'Failed to grant {0} for {1}@{2} on {3}'.format(
|
||||
grant,
|
||||
user,
|
||||
host,
|
||||
database
|
||||
)
|
||||
ret['result'] = False
|
||||
return ret
|
||||
|
||||
@ -62,10 +78,22 @@ def absent(name,
|
||||
#check if db exists and remove it
|
||||
if __salt__['mysql.grant_exists'](grant,database,user,host,):
|
||||
if __salt__['mysql.grant_revoke'](grant,database,user,host):
|
||||
ret['comment'] = 'Grant {0} for {1}@{2} on {3} has been revoked'.format(grant,user,host,database,)
|
||||
ret['comment'] = ('Grant {0} for {1}@{2} on {3} has been'
|
||||
' revoked').format(
|
||||
grant,
|
||||
user,
|
||||
host,
|
||||
database
|
||||
)
|
||||
ret['changes'][name] = 'Absent'
|
||||
return ret
|
||||
|
||||
# fallback
|
||||
ret['comment'] = 'Grant {0} for {1}@{2} on {3} is not present, so it cannot be revoked'.format(grant,user,host,database,)
|
||||
ret['comment'] = ('Grant {0} for {1}@{2} on {3} is not present, so it'
|
||||
' cannot be revoked').format(
|
||||
grant,
|
||||
user,
|
||||
host,
|
||||
database
|
||||
)
|
||||
return ret
|
||||
|
Loading…
Reference in New Issue
Block a user