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.

63 lines
1.7 KiB

  1. # -*- ispell-local-dictionary: "english" -*-
  2. * Description
  3. =postgres-stub= allows you to declare an external =postgres= so that
  4. your local services can connect to it. It assumes you have the host,
  5. port of the external postgres access, and a login, password, and a
  6. database (already created) to connect to.
  7. For now, this stub can't manage an admin access to create database, and
  8. more. This would be an easy addition thou.
  9. This can be useful for instance if you have an external provider giving
  10. you access to their postgres (use SSL then!), or in your private cloud,
  11. or on the same host but not managed by docker, either directly on the host
  12. or by other virtual services (LXC, VMWare...).
  13. * Usage
  14. You can declare a stub service by specifying at least the host of your
  15. external =postgres= database.
  16. #+begin_src yaml
  17. my-postgres-stub:
  18. charm: postgres-stub
  19. options:
  20. host: my-host.mydomain.fr:20432
  21. #+end_src
  22. If you don't specify a port, then it'll be defaulted to ~5432~
  23. Any service that want to connect to this database could then:
  24. #+begin_src yaml
  25. myservice:
  26. # ...
  27. relations:
  28. postgres-database:
  29. postgres-stub:
  30. my-postgres-stub:
  31. dbname: my-db-name
  32. user: my-username
  33. password: my-p4s5w0rd
  34. #+end_src
  35. ** database name and user automatic assignation
  36. It can be useful, if you have several services in the same ~compose.yml~
  37. to assign database names and user automatically to avoid repeating them.
  38. #+begin_src yaml
  39. my-postgres-stub:
  40. charm: postgres-stub
  41. options:
  42. host: my-host.mydomain.fr:20432
  43. service-dbname-map:
  44. service1: u_foo
  45. ## Leveraging regex replacement for all other services
  46. .*: xyz_$0
  47. service-user-map:
  48. .*: u_$0
  49. #+end_src