vagrant works

This commit is contained in:
2019-12-10 01:39:53 -05:00
parent f1809bef83
commit 565eb9c2e7
47 changed files with 620 additions and 469 deletions

View File

@ -4,32 +4,38 @@ This file is used to list changes made in the last 3 major versions of the postg
## Unreleased
## v7.1.4 (28-03-2019)
## v7.1.5 (2019-11-18)
- Allow to install extensions with hyphens, ex: `postgresql_extension '"uuid-ossp"'`
- Update Circle CI config to match sous-chefs defaults #617
- Remove Fedora testing from CI, not an official supported OS by sous-chefs, PR welcome #617
## v7.1.4 (2019-03-28)
- Fix installation of extensions.
## v7.1.3 (15-01-2019)
## v7.1.3 (2019-01-15)
- Added support for dash in database role name.
## v7.1.2 (06-01-2019)
## v7.1.2 (2019-06-01)
- Cleanup and update the user resource documentation and code. Removed extraneous 'sensitive' property which is a common property in all Chef resources.
- Change default permissions on the postgres.conf to be world readable so that psql can work.
## v7.1.1 (26-09-2018)
## v7.1.1 (2018-09-26)
- Rename slave to follower
- Use CircleCI for testing
- Simplyfy extension resource
## v7.1.0 (22-06-2018)
## v7.1.0 (2018-06-22)
- Update the `initdb` script to use initdb rather than a service. #542
- Refactor database commands to use the common connect method. #535
- Increase the unit test coverage.
## v7.0.0 (25-05-2018)
## v7.0.0 (2018-05-25)
_Breaking Change_ Please see UPGRADING.md and the README.md for information how to use.
@ -57,7 +63,7 @@ _Breaking Change_ Please see UPGRADING.md and the README.md for information how
## v6.1.2 (2018-04-16)
**this will be the last release of the 6.0 series before all recipes are removed from the cookbook**
this will be the last release of the 6.0 series before all recipes are removed from the cookbook
- Deprecate all recipes

View File

@ -2,10 +2,16 @@
[![Cookbook Version](https://img.shields.io/cookbook/v/postgresql.svg)](https://supermarket.chef.io/cookbooks/postgresql)
[![Build Status](https://img.shields.io/circleci/project/github/sous-chefs/postgresql/master.svg)](https://circleci.com/gh/sous-chefs/postgresql)
[![pullreminders](https://pullreminders.com/badge.svg)](https://pullreminders.com?ref=badge)
[![OpenCollective](https://opencollective.com/sous-chefs/backers/badge.svg)](#backers)
[![OpenCollective](https://opencollective.com/sous-chefs/sponsors/badge.svg)](#sponsors)
[![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/licenses/Apache-2.0)
Installs and configures PostgreSQL as a client or a server.
## Maintainers
This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of Chef cookbook maintainers working together to maintain important cookbooks. If youd like to know more please visit [sous-chefs.org](https://sous-chefs.org/) or come chat with us on the Chef Community Slack in [#sous-chefs](https://chefcommunity.slack.com/messages/C2V7B88SF).
## Upgrading
If you are wondering where all the recipes went in v7.0+, or how on earth I use this new cookbook please see upgrading.md for a full description.
@ -18,7 +24,6 @@ If you are wondering where all the recipes went in v7.0+, or how on earth I use
- Debian 7+
- Ubuntu 14.04+
- Red Hat/CentOS/Scientific 6+
- Fedora
### PostgreSQL version
@ -51,7 +56,7 @@ Name | Types | Description
`hba_file` | String | | `#{conf_dir}/main/pg_hba.conf` | no
`ident_file` | String | | `#{conf_dir}/main/pg_ident.conf` | no
`external_pid_file` | String | | `/var/run/postgresql/#{version}-main.pid` | no
`password` | String, nil | Pass in a password, or have the cookbook generate one for you | <random string> | no
`password` | String, nil | Pass in a password, or have the cookbook generate one for you | random string | no
#### Examples
@ -211,14 +216,14 @@ end
This generates the following line in the `pg_hba.conf`:
```
```config
# Local postgres superuser access
local all postgres ident
```
**Note**: The template by default generates a local access for Unix domain sockets only to support running the SQL execute resources. In Postgres version 9.1 and higher, the method is 'peer' instead of 'ident' which is identical. It looks like this:
```
```config
# "local" is for Unix domain socket connections only
local all all peer
```
@ -257,7 +262,7 @@ end
This generates the following line in the `pg_ident.conf`:
```
```config
# MAPNAME SYSTEM-USERNAME PG-USERNAME
# John Mapping
@ -279,7 +284,7 @@ end
This generates the following line in the `pg_hba.conf`:
```
```config
# Local postgres superuser access
host all foo 127.0.0.1/32 ident
```
@ -400,34 +405,27 @@ postgresql_server_conf 'PostgreSQL Config' do
end
```
## Contributing
## Contributors
Please refer to each project's style guidelines and guidelines for submitting patches and additions. In general, we follow the "fork-and-pull" Git workflow.
This project exists thanks to all the people who [contribute.](https://opencollective.com/sous-chefs/contributors.svg?width=890&button=false)
1. **Fork** the repo on GitHub
2. **Clone** the project to your own machine
3. **Commit** changes to your own branch
4. **Push** your work back up to your fork
5. Submit a **Pull request** so that we can review your changes
### Backers
NOTE: Be sure to merge the latest from "upstream" before making a pull request!
Thank you to all our backers!
[Contribution informations for this project](CONTRIBUTING.md)
![https://opencollective.com/sous-chefs#backers](https://opencollective.com/sous-chefs/backers.svg?width=600&avatarHeight=40)
## License
### Sponsors
Copyright 2010-2017, Chef Software, Inc.
Support this project by becoming a sponsor. Your logo will show up here with a link to your website.
```text
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
![https://opencollective.com/sous-chefs/sponsor/0/website](https://opencollective.com/sous-chefs/sponsor/0/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/1/website](https://opencollective.com/sous-chefs/sponsor/1/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/2/website](https://opencollective.com/sous-chefs/sponsor/2/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/3/website](https://opencollective.com/sous-chefs/sponsor/3/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/4/website](https://opencollective.com/sous-chefs/sponsor/4/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/5/website](https://opencollective.com/sous-chefs/sponsor/5/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/6/website](https://opencollective.com/sous-chefs/sponsor/6/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/7/website](https://opencollective.com/sous-chefs/sponsor/7/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/8/website](https://opencollective.com/sous-chefs/sponsor/8/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/9/website](https://opencollective.com/sous-chefs/sponsor/9/avatar.svg?avatarHeight=100)

View File

@ -22,7 +22,7 @@ module PostgresqlCookbook
require 'securerandom'
def psql_command_string(new_resource, query, grep_for: nil, value_only: false)
cmd = "/usr/bin/psql -c \"#{query}\""
cmd = %(/usr/bin/psql -c "#{query}")
cmd << " -d #{new_resource.database}" if new_resource.database
cmd << " -U #{new_resource.user}" if new_resource.user
cmd << " --host #{new_resource.host}" if new_resource.host
@ -35,12 +35,12 @@ module PostgresqlCookbook
def execute_sql(new_resource, query)
# If we don't pass in a user to the resource
# default to the postgres user
user = new_resource.user ? new_resource.user : 'postgres'
user = new_resource.user || 'postgres'
# Query could be a String or an Array of Strings
statement = query.is_a?(String) ? query : query.join("\n")
cmd = shell_out(statement, user: user)
cmd = shell_out(statement, user: user, environment: psql_environment)
# Pass back cmd so we can decide what to do with it in the calling method.
cmd
@ -81,7 +81,7 @@ module PostgresqlCookbook
end
def create_extension_sql(new_resource)
sql = "CREATE EXTENSION IF NOT EXISTS #{new_resource.extension}"
sql = %(CREATE EXTENSION IF NOT EXISTS #{new_resource.extension})
sql << " FROM \"#{new_resource.old_version}\"" if new_resource.old_version
psql_command_string(new_resource, sql)
@ -239,6 +239,12 @@ module PostgresqlCookbook
platform?('amazon') ? '6' : '$releasever'
end
# Fedora doesn't seem to know the right symbols for psql
def psql_environment
return {} unless platform?('fedora')
{ LD_LIBRARY_PATH: '/usr/lib64' }
end
# Generate a password if the value is set to generate.
def postgres_password(new_resource)
new_resource.password == 'generate' ? secure_random : new_resource.password

File diff suppressed because one or more lines are too long

View File

@ -4,8 +4,7 @@ maintainer 'Sous Chefs'
maintainer_email 'help@sous-chefs.org'
license 'Apache-2.0'
description 'Installs and configures postgresql for clients or servers'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '7.1.4'
version '7.1.5'
source_url 'https://github.com/sous-chefs/postgresql'
issues_url 'https://github.com/sous-chefs/postgresql/issues'
chef_version '>= 13.8'

View File

@ -16,12 +16,12 @@
# limitations under the License.
#
property :access_type, String, required: true, default: 'local'
property :access_db, String, required: true, default: 'all'
property :access_user, String, required: true, default: 'postgres'
property :access_method, String, required: true, default: 'ident'
property :cookbook, String, default: 'postgresql'
property :source, String, default: 'pg_hba.conf.erb'
property :access_type, String, default: 'local'
property :access_db, String, default: 'all'
property :access_user, String, default: 'postgres'
property :access_method, String, default: 'ident'
property :cookbook, String, default: 'postgresql'
property :source, String, default: 'pg_hba.conf.erb'
property :access_addr, String
property :comment, String

View File

@ -30,6 +30,7 @@ action :create do
code create_extension_sql(new_resource)
user 'postgres'
action :run
environment(psql_environment)
not_if { follower? || extension_installed?(new_resource) }
end
end
@ -39,6 +40,7 @@ action :drop do
code psql_command_string(new_resource, "DROP EXTENSION IF EXISTS \"#{new_resource.extension}\"")
user 'postgres'
action :run
environment(psql_environment)
not_if { follower? }
only_if { extension_installed?(new_resource) }
end

View File

@ -40,6 +40,7 @@ action :create do
user 'postgres'
command create_user_sql(new_resource)
sensitive new_resource.sensitive
environment(psql_environment)
not_if { follower? || user_exists?(new_resource) }
end
end
@ -49,6 +50,7 @@ action :update do
execute "update postgresql user #{new_resource.create_user}" do
user 'postgres'
command update_user_sql(new_resource)
environment(psql_environment)
sensitive true
not_if { follower? }
only_if { user_exists?(new_resource) }
@ -64,6 +66,7 @@ action :update do
execute "Update postgresql user #{new_resource.create_user} to set #{attr}" do
user 'postgres'
command update_user_with_attributes_sql(new_resource, v)
environment(psql_environment)
sensitive true
not_if { follower? }
only_if { user_exists?(new_resource) }
@ -76,6 +79,7 @@ action :drop do
execute "drop postgresql user #{new_resource.create_user}" do
user 'postgres'
command drop_user_sql(new_resource)
environment(psql_environment)
sensitive true
not_if { follower? }
only_if { user_exists?(new_resource) }