mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-09 13:44:24 +00:00
chore(postgresql): create role and user statements do not use if not exists
This commit is contained in:
@@ -110,7 +110,6 @@
|
||||
# remove anything involving 'rdsadmin'
|
||||
# remove changes to protected RDS users
|
||||
# remove protected 'superuser' and 'replication' assignments
|
||||
# add 'IF NOT EXISTS' to creation statements
|
||||
vars:
|
||||
# **Hack notice**: Ansible has issues with splitting on new lines if this template is quoted differently
|
||||
permissions_dump_content_as_lines: "{{ dump_file.content | ansible.builtin.b64decode | split('\n') }}"
|
||||
@@ -125,7 +124,6 @@
|
||||
| reject('match', '.*rdsadmin.*')
|
||||
| reject('match', '^(CREATE|ALTER) ROLE rds_')
|
||||
| map('regex_replace', '(NO)(SUPERUSER|REPLICATION)\s?', '')
|
||||
| map('regex_replace', '(CREATE \w+ \w+)(.*)', '\1 IF NOT EXISTS\2')
|
||||
}}
|
||||
|
||||
- name: Manipulate dictionaries
|
||||
|
||||
@@ -69,6 +69,15 @@ select usename FROM pg_catalog.pg_user;
|
||||
-- Check the current user has SuperUser permissions
|
||||
SHOW is_superuser
|
||||
|
||||
-- Create roles
|
||||
-- Does *not* support IF NOT EXISTS
|
||||
CREATE ROLE miriam;
|
||||
CREATE ROLE miriam WITH LOGIN PASSWORD 'jw8s0F4' VALID UNTIL '2005-01-01';
|
||||
|
||||
-- Create users
|
||||
-- Does *not* support IF NOT EXISTS
|
||||
CREATE USER mike;
|
||||
|
||||
-- Grant users SuperUser permissions
|
||||
-- Executing user must be already SuperUser
|
||||
ALTER USER joel WITH SUPERUSER;
|
||||
|
||||
Reference in New Issue
Block a user