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 on 2013-09-20

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

67. By Richard Asbridge on 2013-09-23
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
1=== modified file 'config.yaml'
2--- config.yaml 2013-09-12 20:09:44 +0000
3+++ config.yaml 2013-09-23 09:39:26 +0000
4@@ -1,4 +1,14 @@
5 options:
6+ admin_addresses:
7+ default: ""
8+ type: string
9+ description: |
10+ A comma-separated list of IP Addresses (or single IP) admin tools like
11+ pgAdmin3 will connect from, this is most useful for developers running
12+ juju in local mode who need to connect tools like pgAdmin to a postgres.
13+ The IP addresses added here will be included in the pg_hba.conf file
14+ allowing ip connections to all databases on the server from the given
15+ using md5 password encryption.
16 locale:
17 default: "C"
18 type: string
19
20=== modified file 'hooks/hooks.py'
21--- hooks/hooks.py 2013-09-12 20:09:44 +0000
22+++ hooks/hooks.py 2013-09-23 09:39:26 +0000
23@@ -494,6 +494,24 @@
24 }
25 relation_data.append(local_replication)
26
27+ # Admin IP addresses for people using tools like pgAdminIII in a local JuJu
28+ # We accept a single IP or a comma separated list of IPs, these are added
29+ # to the list of relations that end up in pg_hba.conf thus granting
30+ # the IP addresses socket access to the postgres server.
31+ if config_data["admin_addresses"] != '':
32+ if "," in config_data["admin_addresses"]:
33+ admin_ip_list = config_data["admin_addresses"].split(",")
34+ else:
35+ admin_ip_list = [config_data["admin_addresses"]]
36+
37+ for admin_ip in admin_ip_list:
38+ admin_host = {'database':'all',
39+ 'user':'all',
40+ 'private-address':munge_address(admin_ip),
41+ }
42+ relation_data.append(admin_host)
43+
44+
45 pg_hba_template = Template(open("templates/pg_hba.conf.tmpl").read())
46 host.write_file(
47 postgresql_hba, pg_hba_template.render(access_list=relation_data),

Subscribers

People subscribed via source and target branches