-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a state to manage replication slots
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
def slot(name): | ||
ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''} | ||
|
||
sql = "SELECT * FROM pg_replication_slots WHERE slot_name = '%s'" % name | ||
if __salt__["postgres.psql_query"](sql): | ||
ret["result"] = True | ||
ret["comment"] = "Replication slot '{}' already exists.".format( | ||
name, | ||
) | ||
return ret | ||
|
||
if __opts__['test']: | ||
ret['comment'] = 'Replication slot "{0}" will be created.'.format(name) | ||
ret['changes'] = { | ||
'old': None, | ||
'new': name, | ||
} | ||
ret["result"] = None | ||
return ret | ||
|
||
__salt__["postgres.psql_query"]( | ||
""" SELECT * FROM | ||
pg_create_physical_replication_slot('%s'); | ||
""" % name | ||
) | ||
|
||
ret["result"] = True | ||
ret["comment"] = "Created replication slot: '{}'.".format(name) | ||
ret["changes"] = { | ||
"old": None, | ||
"new": name, | ||
} | ||
|
||
return ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters