Merge lp:~richard-asbridge/charms/precise/postgresql/postgresql-admin-ip into lp:charms/postgresql

Proposed by Richard Asbridge
Status: Merged
Merged at revision: 65
Proposed branch: lp:~richard-asbridge/charms/precise/postgresql/postgresql-admin-ip
Merge into: lp:charms/postgresql
Diff against target: 47 lines (+28/-0)
2 files modified
config.yaml (+10/-0)
hooks/hooks.py (+18/-0)
To merge this branch: bzr merge lp:~richard-asbridge/charms/precise/postgresql/postgresql-admin-ip
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
Richard Asbridge Pending
Review via email: mp+184789@code.launchpad.net

This proposal supersedes a proposal from 2013-09-10.

Description of the change

I added a new config option called admin_ip that defaults to "none" when this option is set using the usual "juju set" command, it causes the given IP address to be added to the pg_hba.conf file in the following manner...

host all all 10.0.3.1 md5

...if admin_ip is left unconfigured then it has no effect.

This is handy for developers using juju in local mode where they want to connect tools such as pgAdmin from their host machine to the postgres instances running inside of juju.

To post a comment you must log in.
Revision history for this message
Marco Ceppi (marcoceppi) wrote : Posted in a previous version of this proposal

Please resubmit with the merge into branch being "lp:charms/postgresql" and the proposed branch "lp:~richard-asbridge/charms/precise/postgresql/postgresql-admin-ip"

review: Needs Resubmitting
Revision history for this message
Stuart Bishop (stub) wrote :

Thanks for this. I see the use case (I even have most of a charm that lets you run pgadmin via ssh and x forwarding).

I think the current implementation is too limiting to put into the store charm. I think that we should turn the string called admin_ip into a list called admin_addresses. It is a minor modification to allow multiple admin addresses, and we can extend it in the future to allow multiple ip addres ranges using xx.xx.xx.xx/xx syntax.

Do you want to make the modifications? Otherwise I can make the changes.

review: Needs Fixing
66. By Richard Asbridge

changed to work with a list of admin IP addresses rather than just a single address

67. By Richard Asbridge
Revision history for this message
Stuart Bishop (stub) wrote :

Looks ready. I'll land this.

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'config.yaml'
--- config.yaml 2013-09-12 20:09:44 +0000
+++ config.yaml 2013-09-23 09:39:26 +0000
@@ -1,4 +1,14 @@
1options:1options:
2 admin_addresses:
3 default: ""
4 type: string
5 description: |
6 A comma-separated list of IP Addresses (or single IP) admin tools like
7 pgAdmin3 will connect from, this is most useful for developers running
8 juju in local mode who need to connect tools like pgAdmin to a postgres.
9 The IP addresses added here will be included in the pg_hba.conf file
10 allowing ip connections to all databases on the server from the given
11 using md5 password encryption.
2 locale:12 locale:
3 default: "C"13 default: "C"
4 type: string14 type: string
515
=== modified file 'hooks/hooks.py'
--- hooks/hooks.py 2013-09-12 20:09:44 +0000
+++ hooks/hooks.py 2013-09-23 09:39:26 +0000
@@ -494,6 +494,24 @@
494 }494 }
495 relation_data.append(local_replication)495 relation_data.append(local_replication)
496496
497 # Admin IP addresses for people using tools like pgAdminIII in a local JuJu
498 # We accept a single IP or a comma separated list of IPs, these are added
499 # to the list of relations that end up in pg_hba.conf thus granting
500 # the IP addresses socket access to the postgres server.
501 if config_data["admin_addresses"] != '':
502 if "," in config_data["admin_addresses"]:
503 admin_ip_list = config_data["admin_addresses"].split(",")
504 else:
505 admin_ip_list = [config_data["admin_addresses"]]
506
507 for admin_ip in admin_ip_list:
508 admin_host = {'database':'all',
509 'user':'all',
510 'private-address':munge_address(admin_ip),
511 }
512 relation_data.append(admin_host)
513
514
497 pg_hba_template = Template(open("templates/pg_hba.conf.tmpl").read())515 pg_hba_template = Template(open("templates/pg_hba.conf.tmpl").read())
498 host.write_file(516 host.write_file(
499 postgresql_hba, pg_hba_template.render(access_list=relation_data),517 postgresql_hba, pg_hba_template.render(access_list=relation_data),

Subscribers

People subscribed via source and target branches