You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Valentin Lab 75656758a5 fix: [monujo] allow installation of version 1.0.0 4 days ago
..
hooks new: [postgres-stub] add service mapping for ``dbname`` and ``user``. 2 months ago
lib new: [postgres-stub] add service mapping for ``dbname`` and ``user``. 2 months ago
README.org new: [postgres-stub] add service mapping for ``dbname`` and ``user``. 2 months ago
metadata.yml new: [postgres-stub,postgres,*/postgres_database] new charm 2 months ago

README.org

Description

postgres-stub allows you to declare an external postgres so that your local services can connect to it. It assumes you have the host, port of the external postgres access, and a login, password, and a database (already created) to connect to.

For now, this stub can't manage an admin access to create database, and more. This would be an easy addition thou.

This can be useful for instance if you have an external provider giving you access to their postgres (use SSL then!), or in your private cloud, or on the same host but not managed by docker, either directly on the host or by other virtual services (LXC, VMWare…).

Usage

You can declare a stub service by specifying at least the host of your external postgres database.

my-postgres-stub:
  charm: postgres-stub
  options:
    host: my-host.mydomain.fr:20432

If you don't specify a port, then it'll be defaulted to 5432

Any service that want to connect to this database could then:

myservice:
  # ...
  relations:
    postgres-database:
      postgres-stub:
        my-postgres-stub:
          dbname: my-db-name
          user: my-username
          password: my-p4s5w0rd

database name and user automatic assignation

It can be useful, if you have several services in the same compose.yml to assign database names and user automatically to avoid repeating them.

my-postgres-stub:
  charm: postgres-stub
  options:
    host: my-host.mydomain.fr:20432
    service-dbname-map:
      service1: u_foo
      ## Leveraging regex replacement for all other services
      .*: xyz_$0
    service-user-map:
      .*: u_$0