Commit f9435cce authored by Marco Mariani's avatar Marco Mariani

abilian: moved postgres to ipv4

parent f6cba2aa
...@@ -70,7 +70,7 @@ class Recipe(GenericBaseRecipe): ...@@ -70,7 +70,7 @@ class Recipe(GenericBaseRecipe):
""" """
def _options(self, options): def _options(self, options):
options['url'] = 'postgresql://%(superuser)s:%(password)s@[%(ipv6-random)s]:%(port)s/%(dbname)s' % options options['url'] = 'postgresql://%(superuser)s:%(password)s@[%(ipv4)s]:%(port)s/%(dbname)s' % options
def install(self): def install(self):
...@@ -128,13 +128,15 @@ class Recipe(GenericBaseRecipe): ...@@ -128,13 +128,15 @@ class Recipe(GenericBaseRecipe):
pgdata = self.options['pgdata-directory'] pgdata = self.options['pgdata-directory']
ipv4 = self.options['ipv4'] ipv4 = self.options['ipv4']
ipv6 = self.options['ipv6'] ipv6 = self.options.get('ipv6', set())
postgresql_conf_path = os.path.join(pgdata, 'postgresql.conf') postgresql_conf_path = os.path.join(pgdata, 'postgresql.conf')
with open(postgresql_conf_path, 'wb') as cfg: with open(postgresql_conf_path, 'wb') as cfg:
ret.append(postgresql_conf_path) ret.append(postgresql_conf_path)
template = self.options['template-postgresql-conf'].lstrip() template = self.options['template-postgresql-conf'].lstrip()
cfg.write(template.format(listen_addresses=','.join(ipv4.union(ipv6)), cfg.write(template.format(ipv4_listen_addresses=','.join(ipv4),
ipv6_listen_addresses=','.join(ipv6),
listen_addresses=','.join(ipv4.union(ipv6)),
unix_socket_directory=pgdata)) unix_socket_directory=pgdata))
cfg.write('\n') cfg.write('\n')
...@@ -143,13 +145,13 @@ class Recipe(GenericBaseRecipe): ...@@ -143,13 +145,13 @@ class Recipe(GenericBaseRecipe):
ret.append(pghba_conf_path) ret.append(pghba_conf_path)
# see http://www.postgresql.org/docs/9.2/static/auth-pg-hba-conf.html # see http://www.postgresql.org/docs/9.2/static/auth-pg-hba-conf.html
template_hba_ipv4 = self.options.get('template-hba-ipv4').strip() template_hba_ipv4 = self.options.get('template-hba-ipv4', '').strip()
ipv4_auth = '' ipv4_auth = ''
if template_hba_ipv4: if template_hba_ipv4:
for ip in ipv4: for ip in ipv4:
ipv4_auth += template_hba_ipv4.format(ip=ip) ipv4_auth += template_hba_ipv4.format(ip=ip)
template_hba_ipv6 = self.options.get('template-hba-ipv6').strip() template_hba_ipv6 = self.options.get('template-hba-ipv6', '').strip()
ipv6_auth = '' ipv6_auth = ''
if template_hba_ipv6: if template_hba_ipv6:
for ip in ipv6: for ip in ipv6:
......
...@@ -23,9 +23,7 @@ offline = true ...@@ -23,9 +23,7 @@ offline = true
recipe = slapos.cookbook:postgres recipe = slapos.cookbook:postgres
# Options # Options
ipv6 = $${instance-parameters:ipv6}
ipv4 = $${instance-parameters:ipv4} ipv4 = $${instance-parameters:ipv4}
ipv6-random = $${instance-parameters:ipv6-random}
superuser = postgres superuser = postgres
password = $${postgres-passwd:passwd} password = $${postgres-passwd:passwd}
port = 5432 port = 5432
...@@ -37,7 +35,7 @@ services = $${directories:services} ...@@ -37,7 +35,7 @@ services = $${directories:services}
template-postgresql-conf = template-postgresql-conf =
# This configuration file is generated by a SlapOS instance profile. Manual edits will be overwritten. # This configuration file is generated by a SlapOS instance profile. Manual edits will be overwritten.
listen_addresses = '{listen_addresses}' listen_addresses = '{ipv4_listen_addresses}'
port = $${:port} port = $${:port}
logging_collector = on logging_collector = on
log_rotation_size = 50MB log_rotation_size = 50MB
...@@ -57,16 +55,11 @@ template-pg-hba-conf = ...@@ -57,16 +55,11 @@ template-pg-hba-conf =
# "local" is for Unix domain socket connections only (check unix_socket_permissions!) # "local" is for Unix domain socket connections only (check unix_socket_permissions!)
local all all trust local all all trust
host all all 127.0.0.1/32 md5 host all all 127.0.0.1/32 md5
host all all ::1/128 md5
{ipv4_auth} {ipv4_auth}
{ipv6_auth}
template-hba-ipv4 = template-hba-ipv4 =
host all all {ip}/32 md5 host all all {ip}/32 md5
template-hba-ipv6 =
host all all {ip}/128 md5
#---------------- #----------------
...@@ -86,7 +79,7 @@ bytes = 16 ...@@ -86,7 +79,7 @@ bytes = 16
[postgres-promise] [postgres-promise]
recipe = slapos.cookbook:check_port_listening recipe = slapos.cookbook:check_port_listening
path = $${directories:promises}/postgres path = $${directories:promises}/postgres
hostname = $${instance-parameters:ipv6-random} hostname = $${instance-parameters:ipv4-random}
port = $${postgres-instance:port} port = $${postgres-instance:port}
......
...@@ -112,7 +112,7 @@ name = Web Frontend ...@@ -112,7 +112,7 @@ name = Web Frontend
software-url = http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg software-url = http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg
slave = true slave = true
config = url config = url
config-url = https://[$${instance-parameters:ipv6-random}]:$${extranet-promise:port}/ config-url = https://[$${instance-parameters:ipv6-random}]:$${extranet-promise:port}
return = site_url return = site_url
......
...@@ -229,14 +229,14 @@ configure-command = ...@@ -229,14 +229,14 @@ configure-command =
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance.cfg.in url = ${:_profile_base_location_}/instance.cfg.in
output = ${buildout:directory}/instance.cfg output = ${buildout:directory}/instance.cfg
md5sum = 3b6105aa9335141c2d73871bdde80e9d md5sum = a865bcd6f894f28c69edf58d4df143ca
mode = 0644 mode = 0644
[instance-postgres] [instance-postgres]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-postgres.cfg.in url = ${:_profile_base_location_}/instance-postgres.cfg.in
output = ${buildout:directory}/instance-postgres.cfg output = ${buildout:directory}/instance-postgres.cfg
md5sum = a8fee23bcada451f94ee70d89c4b94c4 md5sum = 118f5eacb47909aa4fefbd3391cb2077
mode = 0644 mode = 0644
[instance-redis] [instance-redis]
......
...@@ -43,7 +43,7 @@ bin = ${postgresql:location}/bin ...@@ -43,7 +43,7 @@ bin = ${postgresql:location}/bin
services = $${directories:services} services = $${directories:services}
template-postgresql-conf = template-postgresql-conf =
# This configuration file is generated by a SlapOS instance profile. Manual edits will be overwritten. # This configuration file is generated by a SlapOS instance profile. Manual edits will be overwritten.
listen_addresses = '{listen_addresses}' listen_addresses = '{ipv4_listen_addresses},{ipv6_listen_addresses}'
logging_collector = on logging_collector = on
log_rotation_size = 50MB log_rotation_size = 50MB
max_connections = 100 max_connections = 100
......
...@@ -18,7 +18,7 @@ parts = ...@@ -18,7 +18,7 @@ parts =
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance.cfg.in url = ${:_profile_base_location_}/instance.cfg.in
output = ${buildout:directory}/instance.cfg output = ${buildout:directory}/instance.cfg
md5sum = e78188b903d61de2d2e1e36d1d4bbec8 md5sum = bfeba61d906ee861804ee8e4c35ad312
mode = 0644 mode = 0644
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment