marcusianlevine.rename-database
marcusianlevine.rename-database
Small utility role to create, rename, and swap databases on a remote database server (currently only targets PostgreSQL)
Requirements
Utilizes the postgresql_ Ansible modules, which require psycopg2 to be installed on the host running this role.
Role Variables
Required
db_host: hostname of the remote database server to operate ondb_port: port that the database server accepts connections onlogin_user: connect to the remote database with this usernamelogin_password: connect to the remote database with this password (NOTE: Use ansible-vault to provide this value from an encrypted file! Don't store your database password unencrypted in your repo!)databases: list of dictionaries describing the databases which will be created/renamed/swapped. Should have the following items:target: name of the database .replacement: current name of the database which will replacetarget.new_target_name: Optionally specify the new name whichtargetshould be given after being replaced byreplacement. (seedefaults/main.ymlfor default prefix and suffix used if not specified)
db_owner: name of role/user on remote database server that should own the databases created by this role. Defaults tologin_userswap_db: failsafe control variable to prevent accidental swaps. In order to swap/replace the targets with their replacements, you must set this variable to be truthy.keep_replacement: by default, this role recreates the original databases after they are renamed. Set this to false to disable.
Example Playbook
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: localhost
roles:
- role: marcusianlevine.rename-database
db_host: db.example.co
login_user: myuser
login_password: secret
target_db: my_target
replacement_db: my_staging_db
swap_db: yes
License
BSD
Author Information
Written by Marcus Levine for CKM Advisors
About
Create, rename, and swap databases on a remote database server (currently only PostgreSQL)
Install
ansible-galaxy install marcusianlevine.rename-databaseLicense
Unknown
Downloads
106
Owner
Data Science + DevOps = DataEng
