Skip to content
This repository was archived by the owner on Dec 27, 2021. It is now read-only.
This repository was archived by the owner on Dec 27, 2021. It is now read-only.

Configure pg_hba.conf and postgresql.conf using PostgreSQLRole #130

@geovanisouza92

Description

@geovanisouza92

Hi everyone!

I'm tested provisioning a pg server with provy rather than chef_solo (of vagrant) and all worked very well!

But, after some tries, I noted that pg_hba.conf and postgresql.conf aren't configured automatically.

So, I do it with ensure_line and execute (to restart server). It works.

So, I suggest to make a way to do these configs using the role, what appears much less monkey patch...

Here is my config:

Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "precise64"
  config.vm.network :private_network, ip: "10.11.12.13"
end

provyfile.py

#!/usr/bin/env python
# coding: utf-8

from provy.core import Role
from provy.more.debian.database.postgresql import PostgreSQLRole


class DatabaseRole(Role):

    def provision(self):
        self.provision_role(PostgreSQLRole)
        self.ensure_line('host  all  all  10.11.12.0/24  trust',
            '/etc/postgresql/9.1/main/pg_hba.conf', sudo=True)
        self.ensure_line("listen_addresses = '10.11.12.13'",
            '/etc/postgresql/9.1/main/postgresql.conf', sudo=True)
        self.execute('service postgresql restart', sudo=True)


servers = {
    'db': {
        'address': '10.11.12.13',
        'user': 'vagrant',
        'roles': [
            DatabaseRole,
        ]
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions