module Vpsb module Resources class DbPostgresJson < BaseResource res :db_postgres_json def call(data) template(data) end private def template(data) version = data.get(:db_postgres_version) { name: "db", description: "Database Server Role", chef_type: "role", json_class: "Chef::Role", default_attributes: { postgresql: { version: version, enable_pgdg_apt: true, dir: "/etc/postgresql/#{version}/main", config:{ data_directory: "/var/lib/postgresql/#{version}/main", hba_file: "/etc/postgresql/#{version}/main/pg_hba.conf", ident_file: "/etc/postgresql/#{version}/main/pg_ident.conf", external_pid_file: "/var/run/postgresql/#{version}-main.pid", ssl_cert_file: "/etc/ssl/certs/ssl-cert-snakeoil.pem", ssl_key_file:"/etc/ssl/private/ssl-cert-snakeoil.key" }, client: { packages: [ "postgresql-client-#{version}" ] }, server:{ service_name: "postgresql", packages: [ "postgresql-common", "postgresql-#{version}", "postgresql-server-dev-#{version}", "libpq-dev"] }, contrib:{ packages:["postgresql-contrib-#{version}"] }, password: { postgres: "postgres" }, pg_hba: [ { type: "local", db: "all", user: "postgres", addr: "", method: "ident" }, { type: "local", db: "all", user: "all", addr: "", method: "trust" }, { type: "host", db: "all", user: "all", addr: "127.0.0.1/32", method: "trust" }, { type: "host", db: "all", user: "all", addr: "::1/128", method: "trust" }, { type: "host", db: "all", user: "postgres", addr: "127.0.0.1/32", method: "trust" } ] } }, run_list: [ "recipe[postgresql::server]", "recipe[postgresql::client]" ] } end end end end