diff --git a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/.kitchen.yml b/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/.kitchen.yml deleted file mode 100644 index bc6e264..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/.kitchen.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- -driver: - name: vagrant - synced_folders: - - [<%= File.join(ENV['PWD'], '..', '..')%>, '/tmp/repo-data'] - -provisioner: - name: chef_zero - encrypted_data_bag_secret_key_path: 'secrets/fakey-mcfakerton' - data_bags_path: './data_bags' - product_name: chefdk - -platforms: - - name: ubuntu-16.04 - - name: centos-7 - -suites: - - name: default - run_list: - - recipe[test] - attributes: diff --git a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/Berksfile b/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/Berksfile deleted file mode 100644 index 61dab72..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/Berksfile +++ /dev/null @@ -1,7 +0,0 @@ -source 'https://supermarket.chef.io' - -metadata - -group :delivery do - cookbook 'test', path: './test/fixtures/cookbooks/test' -end diff --git a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/LICENSE b/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/LICENSE deleted file mode 100644 index 10b5688..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/LICENSE +++ /dev/null @@ -1,3 +0,0 @@ -Copyright 2019 The Authors - -All rights reserved, do not redistribute. diff --git a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/README.md b/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/README.md deleted file mode 100644 index 297af5a..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/README.md +++ /dev/null @@ -1,146 +0,0 @@ -# build_cookbook - -A build cookbook for running the parent project through Chef Delivery - -This build cookbook should be customized to suit the needs of the parent project. Using this cookbook can be done outside of Chef Delivery, too. If the parent project is a Chef cookbook, we've detected that and "wrapped" [delivery-truck](https://github.com/chef-cookbooks/delivery-truck). That means it is a dependency, and each of its pipeline phase recipes is included in the appropriate phase recipes in this cookbook. If the parent project is not a cookbook, it's left as an exercise to the reader to customize the recipes as needed for each phase in the pipeline. - -## .delivery/config.json - -In the parent directory to this build_cookbook, the `config.json` can be modified as necessary. For example, phases can be skipped, publishing information can be added, and so on. Refer to customer support or the Chef Delivery documentation for assistance on what options are available for this configuration. - -## Test Kitchen - Local Verify Testing - -This cookbook also has a `.kitchen.yml` which can be used to create local build nodes with Test Kitchen to perform the verification phases, `unit`, `syntax`, and `lint`. When running `kitchen converge`, the instances will be set up like Chef Delivery "build nodes" with the [delivery_build cookbook](https://github.com/chef-cookbooks/delivery_build). The reason for this is to make sure that the same exact kind of nodes are used by this build cookbook are run on the local workstation as would run Delivery. It will run `delivery job verify PHASE` for the parent project. - -Modify the `.kitchen.yml` if necessary to change the platforms or other configuration to run the verify phases. After making changes in the parent project, `cd` into this directory (`.delivery/build_cookbook`), and run: - -``` -kitchen test -``` - -## Recipes - -Each of the recipes in this build_cookbook are run in the named phase during the Chef Delivery pipeline. The `unit`, `syntax`, and `lint` recipes are additionally run when using Test Kitchen for local testing as noted in the above section. - -## Making Changes - Cookbook Example - -When making changes in the parent project (that which lives in `../..` from this directory), or in the recipes in this build cookbook, there is a bespoke workflow for Chef Delivery. As an example, we'll discuss a Chef Cookbook as the parent. - -First, create a new branch for the changes. - -``` -git checkout -b testing-build-cookbook -``` - -Next, increment the version in the metadata.rb. This should be in the _parent_, not in this, the build_cookbook. If this is not done, the verify phase will fail. - -``` -% git diff - --version '0.1.0' -+version '0.1.1' -``` - -The change we'll use for an example is to install the `zsh` package. Write a failing ChefSpec in the cookbook project's `spec/unit/recipes/default_spec.rb`. - -```ruby -require 'spec_helper' - -describe 'godzilla::default' do - context 'When all attributes are default, on Ubuntu 16.04' do - let(:chef_run) do - runner = ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04') - runner.converge(described_recipe) - end - - it 'installs zsh' do - expect(chef_run).to install_package('zsh') - end - end -end -``` - -Commit the local changes as work in progress. The `delivery job` expects to use a clean git repository. - -``` -git add ../.. -git commit -m 'WIP: Testing changes' -``` - -From _this_ directory (`.delivery/build_cookbook`, relative to the parent cookbook project), run - -``` -cd .delivery/build_cookbook -kitchen converge -``` - -This will take some time at first, because the VMs need to be created, Chef installed, the Delivery CLI installed, etc. Later runs will be faster until they are destroyed. It will also fail on the first VM, as expected, because we wrote the test first. Now edit the parent cookbook project's default recipe to install `zsh`. - -``` -cd ../../ -$EDITOR/recipes/default.rb -``` - -It should look like this: - -``` -package 'zsh' -``` - -Create another commit. - -``` -git add . -git commit -m 'WIP: Install zsh in default recipe' -``` - -Now rerun kitchen from the build_cookbook. - -``` -cd .delivery/build_cookbook -kitchen converge -``` - -This will take awhile because it will now pass on the first VM, and then create the second VM. We should have warned you this was a good time for a coffee break. - -``` -Recipe: test::default - -- execute HOME=/home/vagrant delivery job verify unit --server localhost --ent test --org kitchen - * execute[HOME=/home/vagrant delivery job verify lint --server localhost --ent test --org kitchen] action run - - execute HOME=/home/vagrant delivery job verify lint --server localhost --ent test --org kitchen - - - execute HOME=/home/vagrant delivery job verify syntax --server localhost --ent test --org kitchen - -Running handlers: -Running handlers complete -Chef Client finished, 3/32 resources updated in 54.665445968 seconds -Finished converging (1m26.83s). -``` - -Victory is ours! Our verify phase passed on the build nodes. - -We are ready to run this through our Delivery pipeline. Simply run `delivery review` on the local system from the parent project, and it will open a browser window up to the change we just added. - -``` -cd ../.. -delivery review -``` - -## FAQ - -### Why don't I just run rspec and foodcritic/rubocop on my local system? - -An objection to the Test Kitchen approach is that it is much faster to run the unit, lint, and syntax commands for the project on the local system. That is totally true, and also totally valid. Do that for the really fast feedback loop. However, the dance we do with Test Kitchen brings a much higher degree of confidence in the changes we're making, that everything will run on the build nodes in Chef Delivery. We strongly encourage this approach before actually pushing the changes to Delivery. - -### Why do I have to make a commit every time? - -When running `delivery job`, it expects to merge the commit for the changeset against the clean master branch. If we don't save our progress by making a commit, our local changes aren't run through `delivery job` in the Test Kitchen build instances. We can always perform an interactive rebase, and modify the original changeset message in Delivery with `delivery review --edit`. The latter won't modify the git commits, only the changeset in Delivery. - -### What do I do next? - -Make changes in the cookbook project as required for organizational goals and needs. Modify the `build_cookbook` as necessary for the pipeline phases that the cookbook should go through. - -### What if I get stuck? - -Contact Chef Support, or your Chef Customer Success team and they will help you get unstuck. diff --git a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/chefignore b/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/chefignore deleted file mode 100644 index 4439807..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/chefignore +++ /dev/null @@ -1,104 +0,0 @@ -# Put files/directories that should be ignored in this file when uploading -# to a chef-server or supermarket. -# Lines that start with '# ' are comments. - -# OS generated files # -###################### -.DS_Store -Icon? -nohup.out -ehthumbs.db -Thumbs.db - -# SASS # -######## -.sass-cache - -# EDITORS # -########### -\#* -.#* -*~ -*.sw[a-z] -*.bak -REVISION -TAGS* -tmtags -*_flymake.* -*_flymake -*.tmproj -.project -.settings -mkmf.log - -## COMPILED ## -############## -a.out -*.o -*.pyc -*.so -*.com -*.class -*.dll -*.exe -*/rdoc/ - -# Testing # -########### -.watchr -.rspec -spec/* -spec/fixtures/* -test/* -features/* -examples/* -Guardfile -Procfile -.kitchen* -kitchen.yml* -.rubocop.yml -spec/* -Rakefile -.travis.yml -.foodcritic -.codeclimate.yml - -# SCM # -####### -.git -*/.git -.gitignore -.gitmodules -.gitconfig -.gitattributes -.svn -*/.bzr/* -*/.hg/* -*/.svn/* - -# Berkshelf # -############# -Berksfile -Berksfile.lock -cookbooks/* -tmp - -# Bundler # -########### -vendor/* - -# Policyfile # -############## -Policyfile.rb -Policyfile.lock.json - -# Cookbooks # -############# -CONTRIBUTING* -CHANGELOG* -TESTING* - -# Vagrant # -########### -.vagrant -Vagrantfile diff --git a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/data_bags/keys/delivery_builder_keys.json b/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/data_bags/keys/delivery_builder_keys.json deleted file mode 100644 index af375ea..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/data_bags/keys/delivery_builder_keys.json +++ /dev/null @@ -1 +0,0 @@ -{"id": "delivery_builder_keys"} \ No newline at end of file diff --git a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/metadata.rb b/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/metadata.rb deleted file mode 100644 index fc26412..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/metadata.rb +++ /dev/null @@ -1,8 +0,0 @@ -name 'build_cookbook' -maintainer 'The Authors' -maintainer_email 'you@example.com' -license 'all_rights' -version '0.1.0' -chef_version '>= 13.0' - -depends 'delivery-truck' diff --git a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/default.rb b/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/default.rb deleted file mode 100644 index 5bb9df3..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/default.rb +++ /dev/null @@ -1,6 +0,0 @@ -# -# Cookbook:: build_cookbook -# Recipe:: default -# -# Copyright:: 2019, The Authors, All Rights Reserved. -include_recipe 'delivery-truck::default' diff --git a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/deploy.rb b/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/deploy.rb deleted file mode 100644 index 43af83c..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/deploy.rb +++ /dev/null @@ -1,6 +0,0 @@ -# -# Cookbook:: build_cookbook -# Recipe:: deploy -# -# Copyright:: 2019, The Authors, All Rights Reserved. -include_recipe 'delivery-truck::deploy' diff --git a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/functional.rb b/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/functional.rb deleted file mode 100644 index 66001fe..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/functional.rb +++ /dev/null @@ -1,6 +0,0 @@ -# -# Cookbook:: build_cookbook -# Recipe:: functional -# -# Copyright:: 2019, The Authors, All Rights Reserved. -include_recipe 'delivery-truck::functional' diff --git a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/lint.rb b/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/lint.rb deleted file mode 100644 index 0188770..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/lint.rb +++ /dev/null @@ -1,6 +0,0 @@ -# -# Cookbook:: build_cookbook -# Recipe:: lint -# -# Copyright:: 2019, The Authors, All Rights Reserved. -include_recipe 'delivery-truck::lint' diff --git a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/provision.rb b/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/provision.rb deleted file mode 100644 index ac44c47..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/provision.rb +++ /dev/null @@ -1,6 +0,0 @@ -# -# Cookbook:: build_cookbook -# Recipe:: provision -# -# Copyright:: 2019, The Authors, All Rights Reserved. -include_recipe 'delivery-truck::provision' diff --git a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/publish.rb b/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/publish.rb deleted file mode 100644 index 618b3f4..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/publish.rb +++ /dev/null @@ -1,6 +0,0 @@ -# -# Cookbook:: build_cookbook -# Recipe:: publish -# -# Copyright:: 2019, The Authors, All Rights Reserved. -include_recipe 'delivery-truck::publish' diff --git a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/quality.rb b/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/quality.rb deleted file mode 100644 index 7b2ad5d..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/quality.rb +++ /dev/null @@ -1,6 +0,0 @@ -# -# Cookbook:: build_cookbook -# Recipe:: quality -# -# Copyright:: 2019, The Authors, All Rights Reserved. -include_recipe 'delivery-truck::quality' diff --git a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/security.rb b/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/security.rb deleted file mode 100644 index 00096dd..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/security.rb +++ /dev/null @@ -1,6 +0,0 @@ -# -# Cookbook:: build_cookbook -# Recipe:: security -# -# Copyright:: 2019, The Authors, All Rights Reserved. -include_recipe 'delivery-truck::security' diff --git a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/smoke.rb b/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/smoke.rb deleted file mode 100644 index 332646f..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/smoke.rb +++ /dev/null @@ -1,6 +0,0 @@ -# -# Cookbook:: build_cookbook -# Recipe:: smoke -# -# Copyright:: 2019, The Authors, All Rights Reserved. -include_recipe 'delivery-truck::smoke' diff --git a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/syntax.rb b/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/syntax.rb deleted file mode 100644 index 4052638..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/syntax.rb +++ /dev/null @@ -1,6 +0,0 @@ -# -# Cookbook:: build_cookbook -# Recipe:: syntax -# -# Copyright:: 2019, The Authors, All Rights Reserved. -include_recipe 'delivery-truck::syntax' diff --git a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/unit.rb b/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/unit.rb deleted file mode 100644 index fde68b8..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/recipes/unit.rb +++ /dev/null @@ -1,6 +0,0 @@ -# -# Cookbook:: build_cookbook -# Recipe:: unit -# -# Copyright:: 2019, The Authors, All Rights Reserved. -include_recipe 'delivery-truck::unit' diff --git a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/secrets/fakey-mcfakerton b/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/secrets/fakey-mcfakerton deleted file mode 100644 index e69de29..0000000 diff --git a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/test/fixtures/cookbooks/test/metadata.rb b/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/test/fixtures/cookbooks/test/metadata.rb deleted file mode 100644 index 1725039..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/test/fixtures/cookbooks/test/metadata.rb +++ /dev/null @@ -1,2 +0,0 @@ -name 'test' -version '0.1.0' \ No newline at end of file diff --git a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/test/fixtures/cookbooks/test/recipes/default.rb b/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/test/fixtures/cookbooks/test/recipes/default.rb deleted file mode 100644 index 2fd58de..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/build_cookbook/test/fixtures/cookbooks/test/recipes/default.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true -%w(unit lint syntax).each do |phase| - # TODO: This works on Linux/Unix. Not Windows. - execute "HOME=/home/vagrant delivery job verify #{phase} --server localhost --ent test --org kitchen" do - cwd '/tmp/repo-data' - user 'vagrant' - environment('GIT_DISCOVERY_ACROSS_FILESYSTEM' => '1') - end -end diff --git a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/config.json b/cookbooks/hosting/berks-cookbooks/hosting/.delivery/config.json deleted file mode 100644 index 987952b..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/config.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "version": "2", - "build_cookbook": { - "name": "build_cookbook", - "path": ".delivery/build_cookbook" - }, - "delivery-truck": { - "lint": { - "enable_cookstyle": true - } - }, - "skip_phases": [], - "job_dispatch": { - "version": "v2" - }, - "dependencies": [] -} diff --git a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/project.toml b/cookbooks/hosting/berks-cookbooks/hosting/.delivery/project.toml deleted file mode 100644 index 9f54c5e..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/.delivery/project.toml +++ /dev/null @@ -1,36 +0,0 @@ -# Delivery Prototype for Local Phases Execution -# -# The purpose of this file is to prototype a new way to execute -# phases locally on your workstation. The delivery-cli will read -# this file and execute the command(s) that are configured for -# each phase. You can customize them by just modifying the phase -# key on this file. -# -# By default these phases are configured for Cookbook Workflow only -# -# As this is still a prototype we are not modifying the current -# config.json file and it will continue working as usual. - -[local_phases] -unit = "chef exec rspec spec/" -lint = "chef exec cookstyle" -# Foodcritic includes rules only appropriate for community cookbooks -# uploaded to Supermarket. We turn off any rules tagged "supermarket" -# by default. If you plan to share this cookbook you should remove -# '-t ~supermarket' below to enable supermarket rules. -syntax = "chef exec foodcritic . -t ~supermarket" -provision = "chef exec kitchen create" -deploy = "chef exec kitchen converge" -smoke = "chef exec kitchen verify" -# The functional phase is optional, you can define it by uncommenting -# the line below and running the command: `delivery local functional` -# functional = "" -cleanup = "chef exec kitchen destroy" - -# Remote project.toml file -# -# Specify a remote URI location for the `project.toml` file. -# This is useful for teams that wish to centrally manage the behavior -# of the `delivery local` command across many different projects. -# -# remote_file = "https://url/project.toml" diff --git a/cookbooks/hosting/berks-cookbooks/hosting/LICENSE b/cookbooks/hosting/berks-cookbooks/hosting/LICENSE deleted file mode 100644 index 10b5688..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/LICENSE +++ /dev/null @@ -1,3 +0,0 @@ -Copyright 2019 The Authors - -All rights reserved, do not redistribute. diff --git a/cookbooks/hosting/berks-cookbooks/hosting/README.md b/cookbooks/hosting/berks-cookbooks/hosting/README.md deleted file mode 100644 index b3fde69..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# hosting - -TODO: Enter the cookbook description here. - diff --git a/cookbooks/hosting/berks-cookbooks/hosting/chefignore b/cookbooks/hosting/berks-cookbooks/hosting/chefignore deleted file mode 100644 index 4439807..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/chefignore +++ /dev/null @@ -1,104 +0,0 @@ -# Put files/directories that should be ignored in this file when uploading -# to a chef-server or supermarket. -# Lines that start with '# ' are comments. - -# OS generated files # -###################### -.DS_Store -Icon? -nohup.out -ehthumbs.db -Thumbs.db - -# SASS # -######## -.sass-cache - -# EDITORS # -########### -\#* -.#* -*~ -*.sw[a-z] -*.bak -REVISION -TAGS* -tmtags -*_flymake.* -*_flymake -*.tmproj -.project -.settings -mkmf.log - -## COMPILED ## -############## -a.out -*.o -*.pyc -*.so -*.com -*.class -*.dll -*.exe -*/rdoc/ - -# Testing # -########### -.watchr -.rspec -spec/* -spec/fixtures/* -test/* -features/* -examples/* -Guardfile -Procfile -.kitchen* -kitchen.yml* -.rubocop.yml -spec/* -Rakefile -.travis.yml -.foodcritic -.codeclimate.yml - -# SCM # -####### -.git -*/.git -.gitignore -.gitmodules -.gitconfig -.gitattributes -.svn -*/.bzr/* -*/.hg/* -*/.svn/* - -# Berkshelf # -############# -Berksfile -Berksfile.lock -cookbooks/* -tmp - -# Bundler # -########### -vendor/* - -# Policyfile # -############## -Policyfile.rb -Policyfile.lock.json - -# Cookbooks # -############# -CONTRIBUTING* -CHANGELOG* -TESTING* - -# Vagrant # -########### -.vagrant -Vagrantfile diff --git a/cookbooks/hosting/berks-cookbooks/hosting/metadata.json b/cookbooks/hosting/berks-cookbooks/hosting/metadata.json deleted file mode 100644 index 9076585..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/metadata.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "hosting", - "description": "Installs/Configures hosting", - "long_description": "Installs/Configures hosting", - "maintainer": "The Authors", - "maintainer_email": "you@example.com", - "license": "All Rights Reserved", - "platforms": { - - }, - "dependencies": { - - }, - "providing": { - - }, - "recipes": { - - }, - "version": "0.1.0", - "source_url": "", - "issues_url": "", - "privacy": false, - "chef_versions": [ - [ - ">= 13.0" - ] - ], - "ohai_versions": [ - - ], - "gems": [ - - ] -} diff --git a/cookbooks/hosting/berks-cookbooks/hosting/metadata.rb b/cookbooks/hosting/berks-cookbooks/hosting/metadata.rb deleted file mode 100644 index 89cb791..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/metadata.rb +++ /dev/null @@ -1,20 +0,0 @@ -name 'hosting' -maintainer 'The Authors' -maintainer_email 'you@example.com' -license 'All Rights Reserved' -description 'Installs/Configures hosting' -long_description 'Installs/Configures hosting' -version '0.1.0' -chef_version '>= 13.0' - -# The `issues_url` points to the location where issues for this cookbook are -# tracked. A `View Issues` link will be displayed on this cookbook's page when -# uploaded to a Supermarket. -# -# issues_url 'https://github.com//hosting/issues' - -# The `source_url` points to the development repository for this cookbook. A -# `View Source` link will be displayed on this cookbook's page when uploaded to -# a Supermarket. -# -# source_url 'https://github.com//hosting' diff --git a/cookbooks/hosting/berks-cookbooks/hosting/recipes/default.rb b/cookbooks/hosting/berks-cookbooks/hosting/recipes/default.rb deleted file mode 100644 index f3e4426..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/recipes/default.rb +++ /dev/null @@ -1,5 +0,0 @@ -# -# Cookbook:: hosting -# Recipe:: default -# -# Copyright:: 2019, The Authors, All Rights Reserved. diff --git a/cookbooks/hosting/berks-cookbooks/hosting/recipes/mkdir.rb b/cookbooks/hosting/berks-cookbooks/hosting/recipes/mkdir.rb deleted file mode 100644 index 1a703dc..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/recipes/mkdir.rb +++ /dev/null @@ -1,20 +0,0 @@ -directory '/opt/theta42' do - owner 'root' - group 'root' - mode '0755' - action :create -end - -directory '/opt/theta42/bin' do - owner 'root' - group 'root' - mode '0755' - action :create -end - -directory '/opt/theta42/gitea' do - owner 'gitea' - group 'gitea' - mode '0755' - action :create -end diff --git a/cookbooks/hosting/berks-cookbooks/hosting/recipes/postgress.rb b/cookbooks/hosting/berks-cookbooks/hosting/recipes/postgress.rb deleted file mode 100644 index 7620268..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/recipes/postgress.rb +++ /dev/null @@ -1,17 +0,0 @@ -postgresql_server_install 'My PostgreSQL Server install' do - action :install -end - -postgresql_access 'local_postgres_superuser' do - comment 'Local postgres superuser access' - access_type 'local' - access_db 'all' - access_user 'postgres' - access_addr nil - access_method 'ident' -end - -postgresql_user 'gitea' do - password 'UserP4ssword' - createdb true -end diff --git a/cookbooks/hosting/berks-cookbooks/hosting/recipes/user.rb b/cookbooks/hosting/berks-cookbooks/hosting/recipes/user.rb deleted file mode 100644 index 7ed9f96..0000000 --- a/cookbooks/hosting/berks-cookbooks/hosting/recipes/user.rb +++ /dev/null @@ -1,10 +0,0 @@ -user 'gitea system user' do - comment 'gitea system user' - username 'gitea' - system true - shell '/bin/false' -end - -group 'gitea' do - members 'gitea' -end diff --git a/cookbooks/hosting/berks-cookbooks/postgresql/CHANGELOG.md b/cookbooks/hosting/berks-cookbooks/postgresql/CHANGELOG.md deleted file mode 100644 index 95af871..0000000 --- a/cookbooks/hosting/berks-cookbooks/postgresql/CHANGELOG.md +++ /dev/null @@ -1,153 +0,0 @@ -# postgresql Cookbook CHANGELOG - -This file is used to list changes made in the last 3 major versions of the postgresql cookbook. - -## Unreleased - -## v7.1.4 (28-03-2019) - -- Fix installation of extensions. - -## v7.1.3 (15-01-2019) - -- Added support for dash in database role name. - -## v7.1.2 (06-01-2019) - -- 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) - -- Rename slave to follower -- Use CircleCI for testing -- Simplyfy extension resource - -## v7.1.0 (22-06-2018) - -- 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) - -_Breaking Change_ Please see UPGRADING.md and the README.md for information how to use. - -- Add custom resources for: - - - `postgresql_client_install` - - `postgresql_server_install` - - `postgresql_repository` - - `postgresql_pg_gem` - -- Deprecate recipes: - - - `apt_pgdg_postgresql` - - `config_initdb` - - `config_pgtune` - - `contrib` - - `ruby` - - `yum_pgdg_postgresql` - -- Remove deprecated tests - -## v6.1.3 (2018-04-18) - -- Fix recipes referencing the old helpers - -## 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** - -- Deprecate all recipes - -## v6.1.1 (2017-03-08) - -- Fix pg gem installation on non-omnibus chef runs -- Resolve resource cloning deprecation warnings in the ruby recipe -- Fix issues resolving the timezone on CentOS 7 and probably other distros -- Test with Delivery local instead of Rake - -## v6.1.0 (2017-02-18) - -- Fix a method name conflict that caused errors if Chef Sugar was also being used on the run list -- Revert a previous PR that added support for Postgresql 9.6 as it introduced incorrect configuration values -- Added Fedora 25 support for pgdg packages -- Added RHEL 5 support for Postgresql 9.4 pgdg packages -- Removed testing for RHEL 5 and Ubuntu 12.04 as they are scheduled for EoL in the near future -- Improvements to Test Kitchen testing to allow more extensive testing in Travis CI -- Fixed the client recipe on Fedora -- Added Inspec tests for client installs - -## v6.0.1 (2017-01-04 - -- Fix systemd unit file template - -## v6.0.0 (2017-01-03) - -- This cookbook now requires Chef 12.1 or later -- Removed the dependency on the apt cookbook as this functionality is built into modern chef client releases -- Added a new custom resource for installing extensions. This acts as a replacement for the contrib recipe with minimal backwards compatibility. You can now install / remove extensions into any database. This adds the compat_resource cookbook dependency so we can continue to support Chef 12.1-12.4, which lack custom resource support. -- The unused get_result_orig helper has been removed. If you utilized this you'll want to move it to your own wrapper cookbook -- Updates for compatibility with Postgresql 9.5 and 9.6 -- Fixed client package installation on openSUSE Leap 42.2 -- ca-certificates recipe has been deprecated. If ca-certificates package needs to be upgraded the user should do so prior to including this recipe. Package upgrades in community cookbooks are generally a bad idea as this bring in updated packages to production systems. The recipe currently warns if used and will be removed with the next major cookbook release. -- Fixed RHEL platform detection in the Ruby recipe -- systemd fixes for RHEL systems -- Fix systemd service file include when using pgdg packages -- Package installation now uses multi-package installs to speed up converge times -- Added integration testing in Travis of the client recipe using a new test cookbook. This will be expanded in the future to cover server installation as well -- Expanded the specs to test converges on multiple platforms - -## v5.2.0 (2016-12-30) - -- Updated contacts and links to point to Sous Chefs now -- Added a Code of Conduct (the Chef CoC) -- Removed duplicate platforms in the metadata -- Fix Chef runs with local mode in the server recipe -- Fix the ruby recipe to not fail when you specify enabling both the apt and yum repos for mixed distro environments -- Set the postgresql data directory to 700 permissions -- Added node['postgresql']['pg_gem']['version'] to specify the version of the pg gem to install -- Cookstyle fixes for the latest cookstyle release -- Removed test deps from the Gemfile. Rely on ChefDK for base testing deps instead - -## v5.1.0 (2016-11-01) - -- Maintenance of this cookbook has been migrated from Heavy Water to Sous Chefs - -- Add support for Chef-Zero (local mode) -- Don't hardcode the UID / GID on RHEL/Amazon/Suse platforms -- Add PGDG yum RPMs for 9.5 / 9.6 - -## v5.0.0 (2016-10-25) - -### Breaking changes - -- Switched from Librarian to Berkshelf -- Remove support for the following platforms - - - SLES < 12 - - openSUSE < 13 - - Debian < 7 - - Ubuntu < 12.04 - - RHEL < 6 - - Amazon < 2013 - - Unsupported (EOL) Fedora releases - -### Other changes - -- Added support for Ubuntu 16.04 -- Loosened cookbook dependencies to not prevent pulling in the latest community cookbooks -- Added chef_version metadata -- Switched from rubocop to cookstyle and fix all warnings -- Removed minitests and the minitest handler -- Added support for opensuse / opensuseleap -- Added support for Fedora 23/24 -- Added a chefignore file to limit the files uploaded to the chef server -- Updated Test Kitchen config to test on modern platform releases -- Added a Rakefile and updated Travis to test with ChefDK and that rakefile -- Avoid installing packages included in build-essential twice in the ruby recipe -- Require at least build-essential 2.0 -- Don't cleanup the old PPA files in the apt_pgdg_postgresql recipe anymore. These should be long gone everywhere -- Remove logic in the apt_pgdg_postgresql recipe that made Chef fail when new distro releases came out -- Avoid node.set deprecation warnings -- Avoid managed_home deprecation warnings in server_redhat recipe diff --git a/cookbooks/hosting/berks-cookbooks/postgresql/CONTRIBUTING.md b/cookbooks/hosting/berks-cookbooks/postgresql/CONTRIBUTING.md deleted file mode 100644 index e28e2a6..0000000 --- a/cookbooks/hosting/berks-cookbooks/postgresql/CONTRIBUTING.md +++ /dev/null @@ -1,21 +0,0 @@ -# Contributing - -## Branches - -### `master` branch - -The master branch is the current committed changes. These changes may not yet be released although we try to release often. - -## Tags - -All releases are tagged in git. To see the releases available to you see the changelog or the tags directly. - -## Pull requests - -- - -## Issues - -Need to report an issue? Use the github issues: - -- diff --git a/cookbooks/hosting/berks-cookbooks/postgresql/README.md b/cookbooks/hosting/berks-cookbooks/postgresql/README.md deleted file mode 100644 index d25d75e..0000000 --- a/cookbooks/hosting/berks-cookbooks/postgresql/README.md +++ /dev/null @@ -1,433 +0,0 @@ -# PostgreSQL cookbook - -[![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) - -Installs and configures PostgreSQL as a client or a server. - -## 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. - -## Requirements - -### Platforms - -- Amazon Linux -- Debian 7+ -- Ubuntu 14.04+ -- Red Hat/CentOS/Scientific 6+ -- Fedora - -### PostgreSQL version - -We follow the currently supported versions listed on - -### Chef - -- Chef 13.8+ - -### Cookbook Dependencies - -None. - -## Resources - -### postgresql_client_install - -This resource installs PostgreSQL client packages. - -#### Actions - -- `install` - (default) Install client packages - -#### Properties - -Name | Types | Description | Default | Required? -------------------- | ----------------- | ------------------------------------------------------------- | ----------------------------------------- | --------- -`version` | String | Version of PostgreSQL to install | '9.6' | no -`setup_repo` | Boolean | Define if you want to add the PostgreSQL repo | true | no -`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 | | no - -#### Examples - -To install version 9.5: - -```ruby -postgresql_client_install 'My PostgreSQL Client install' do - version '9.5' -end -``` - -### postgresql_server_install - -This resource installs PostgreSQL client and server packages. - -#### Actions - -- `install` - (default) Install client and server packages -- `create` - Initialize the database - -#### Properties - -Name | Types | Description | Default | Required? -------------------- | --------------- | --------------------------------------------- | -------------------------------------------------- | --------- -`version` | String | Version of PostgreSQL to install | '9.6' | no -`setup_repo` | Boolean | Define if you want to add the PostgreSQL repo | true | no -`hba_file` | String | Path of pg_hba.conf file | `/pg_hba.conf'` | no -`ident_file` | String | Path of pg_ident.conf file | `/pg_ident.conf` | no -`external_pid_file` | String | Path of PID file | `/var/run/postgresql/-main.pid` | no -`password` | String, nil | Set PostgreSQL user password | 'generate' | no -`port` | Integer | Set listen port of PostgreSQL service | 5432 | no -`initdb_locale` | String | Locale to initialise the database with | 'C' | no - -#### Examples - -To install PostgreSQL server, set your own postgres password using non-default service port. - -```ruby -postgresql_server_install 'My PostgreSQL Server install' do - action :install -end - -postgresql_server_install 'Setup my PostgreSQL 9.6 server' do - password 'MyP4ssw0rd' - port 5433 - action :create -end -``` - -#### Known issues - -On some platforms (e.g. Ubuntu 18.04), your `initdb_locale` should be set to the -same as the template database [GH-555](https://github.com/sous-chefs/postgresql/issues/555). - -### postgresql_server_conf - -This resource manages postgresql.conf configuration file. - -#### Actions - -- `modify` - (default) Manager PostgreSQL configuration file (postgresql.conf) - -#### Properties - -Name | Types | Description | Default | Required? ----------------------- | ------- | --------------------------------------- | --------------------------------------------------- | --------- -`version` | String | Version of PostgreSQL to install | '9.6' | no -`data_directory` | String | Path of PostgreSQL data directory | `` | no -`hba_file` | String | Path of pg_hba.conf file | `/pg_hba.conf` | no -`ident_file` | String | Path of pg_ident.conf file | `/pg_ident.conf` | no -`external_pid_file` | String | Path of PID file | `/var/run/postgresql/-main.pid` | no -`stats_temp_directory` | String | Path of stats file | `/var/run/postgresql/version>-main.pg_stat_tmp` | no -`port` | Integer | Set listen port of PostgreSQL service | 5432 | no -`additional_config` | Hash | Extra configuration for the config file | {} | no - -#### Examples - -To setup your PostgreSQL configuration with a specific data directory. If you have installed a specific version of PostgreSQL (different from 9.6), you must specify version in this resource too. - -```ruby -postgresql_server_conf 'My PostgreSQL Config' do - version '9.5' - data_directory '/data/postgresql/9.5/main' - notifies :reload, 'service[postgresql]' -end -``` - -### postgresql_extension - -This resource manages PostgreSQL extensions for a given database. - -#### Actions - -- `create` - (default) Creates an extension in a given database -- `drop` - Drops an extension from the database - -#### Properties - -Name | Types | Description | Default | Required? -------------- | ------ | -------------------------------------------------------------------------------- | ---------------- | --------- -`database` | String | Name of the database to install the extension into | | yes -`extension` | String | Name of the extension to install the database | Name of resource | yes -`version` | String | Version of the extension to install | | no -`old_version` | String | Older module name for new extension replacement. Appends FROM to extension query | | no - -#### Examples - -To install the `adminpack` extension: - -```ruby -# Add the contrib package in Ubuntu/Debian -package 'postgresql-contrib-9.6' - -# Install adminpack extension -postgresql_extension 'postgres adminpack' do - database 'postgres' - extension 'adminpack' -end -``` - -### postgresql_access - -This resource uses the accumulator pattern to build up the `pg_hba.conf` file via chef resources instead of piling on a mountain of chef attributes to make this cookbook more reusable. It directly mirrors the configuration options of the postgres hba file in the resource and by default notifies the server with a reload to avoid a full restart, causing a potential outage of service. To revoke access, simply remove the resource and the access change won't be computed into the final `pg_hba.conf` - -#### Actions - -- `grant` - (default) Creates an access line inside of `pg_hba.conf` - -#### Properties - -Name | Types | Description | Default | Required? ---------------- | ------ | ----------------------------------------------------------------------------------------- | ----------------- | --------- -`name` | String | Name of the access resource, this is left as a comment inside the `pg_hba` config | Resource name | yes -`source` | String | The cookbook template filename if you want to use your own custom template | 'pg_hba.conf.erb' | yes -`cookbook` | String | The cookbook to look in for the template source | 'postgresql' | yes -`comment` | String | A comment to leave above the entry in `pg_hba` | nil | no -`access_type` | String | The type of access, e.g. local or host | 'local' | yes -`access_db` | String | The database to access. Can use 'all' for all databases | 'all' | yes -`access_user` | String | The user accessing the database. Can use 'all' for any user | 'all' | yes -`access_addr` | String | The address(es) allowed access. Can be nil if method ident is used since it is local then | nil | no -`access_method` | String | Authentication method to use | 'ident' | yes - -#### Examples - -To grant access to the PostgreSQL user with ident authentication: - -```ruby -postgresql_access 'local_postgres_superuser' do - comment 'Local postgres superuser access' - access_type 'local' - access_db 'all' - access_user 'postgres' - access_addr nil - access_method 'ident' -end -``` - -This generates the following line in the `pg_hba.conf`: - -``` -# 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: - -``` -# "local" is for Unix domain socket connections only -local all all peer -``` - -### postgresql_ident - -This resource generate `pg_ident.conf` configuration file to manage user mapping between system and PostgreSQL users. - -#### Actions - -- `create` - (default) Creates an mapping line inside of `pg_ident.conf` - -#### Properties - -Name | Types | Description | Default | Required? --------------- | ----------- | -------------------------------------------------------------------------- | ------------------- | --------- -`mapname` | String | Name of the user mapping | Resource name | yes -`source` | String | The cookbook template filename if you want to use your own custom template | 'pg_ident.conf.erb' | no -`cookbook` | String | The cookbook to look in for the template source | 'postgresql' | no -`comment` | String, nil | A comment to leave above the entry in `pg_ident` | nil | no -`system_user` | String | System user or regexp used for the mapping | None | yes -`pg_user` | String | Pg user or regexp used for the mapping | None | yes - -#### Examples - -Creates a `mymapping` mapping that map `john` system user to `user1` PostgreSQL user: - -```ruby -postgresql_ident 'Map john to user1' do - comment 'John Mapping' - mapname 'mymapping' - system_user 'john' - pg_user 'user1' -end -``` - -This generates the following line in the `pg_ident.conf`: - -``` -# MAPNAME SYSTEM-USERNAME PG-USERNAME - -# John Mapping -mymapping john user1 -``` - -To grant access to the foo user with password authentication: - -```ruby -postgresql_access 'local_foo_user' do - comment 'Foo user access' - access_type 'host' - access_db 'all' - access_user 'foo' - access_addr '127.0.0.1/32' - access_method 'md5' -end -``` - -This generates the following line in the `pg_hba.conf`: - -``` -# Local postgres superuser access -host all foo 127.0.0.1/32 ident -``` - -### postgresql_database - -This resource manages PostgreSQL databases. - -#### Actions - -- `create` - (default) Creates the given database. -- `drop` - Drops the given database. - -#### Properties - -Name | Types | Description | Default | Required? ----------- | ------- | ------------------------------------------------------------------- | ------------------- | --------- -`database` | String | Name of the database to create | Resource name | yes -`user` | String | User which run psql command | 'postgres' | no -`template` | String | Template used to create the new database | 'template1' | no -`host` | String | Define the host server where the database creation will be executed | Not set (localhost) | no -`port` | Integer | Define the port of PostgreSQL server | 5432 | no -`encoding` | String | Define database encoding | 'UTF-8' | no -`locale` | String | Define database locale | 'en_US.UTF-8' | no -`owner` | String | Define the owner of the database | Not set | no - -#### Examples - -To create database named 'my_app' with owner 'user1': - -```ruby -postgresql_database 'my_app' do - owner 'user1' -end -``` - -#### Known issues - -On some platforms (e.g. Ubuntu 18.04), your `initdb_locale` should be set to the -same as the template database [GH-555](https://github.com/sous-chefs/postgresql/issues/555). - -### postgresql_user - -This resource manage PostgreSQL users. - -#### Actions - -- `create` - (default) Creates the given user with default or given privileges. -- `update` - Update user privilieges. -- `drop` - Deletes the given user. - -#### Properties - -Name | Types | Description | Default | Required? --------------------- | ------- | ----------------------------------------------- | -------- | --------- -`create_user` | String | User to create (defaults to the resource name) | | Yes -`superuser` | Boolean | Define if user needs superuser role | false | no -`createdb` | Boolean | Define if user needs createdb role | false | no -`createrole` | Boolean | Define if user needs createrole role | false | no -`inherit` | Boolean | Define if user inherits the privileges of roles | true | no -`replication` | Boolean | Define if user needs replication role | false | no -`login` | Boolean | Define if user can login | true | no -`password` | String | Set user's password | | no -`encrypted_password` | String | Set user's password with an hashed password | | no -`valid_until` | String | Define an account expiration date | | no -`attributes` | Hash | Additional attributes for :update action | {} | no -`user` | String | User for command | postgres | no -`database` | String | Database for command | | no -`host` | String | Hostname for command | | no -`port` | Integer | Port number to connect to postgres | 5432 | no - -#### Examples - -Create a user `user1` with a password, with `createdb` role and set an expiration date to 2018, Dec 21. - -```ruby -postgresql_user 'user1' do - password 'UserP4ssword' - createdb true - valid_until '2018-12-31' -end -``` - -Create a user `user1` with a password, with `createdb` role and set an expiration date to 2018, Dec 21. - -```ruby -postgresql_user 'user1' do - password 'UserP4ssword' - createdb true - valid_until '2018-12-31' -end -``` - -## Usage - -To install and configure your PostgreSQL instance you need to create your own cookbook and call needed resources with your own parameters. - -More examples can be found in `test/cookbooks/test/recipes` - -## Example Usage - -```ruby -# cookbooks/my_postgresql/recipes/default.rb - -postgresql_client_install 'PostgreSQL Client' do - setup_repo false - version '10.6' -end - -postgresql_server_install 'PostgreSQL Server' do - version '10.6' - setup_repo false - password 'P0stgresP4ssword' -end - -postgresql_server_conf 'PostgreSQL Config' do - notifies :reload, 'service[postgresql]' -end -``` - -## Contributing - -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. - -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 - -NOTE: Be sure to merge the latest from "upstream" before making a pull request! - -[Contribution informations for this project](CONTRIBUTING.md) - -## License - -Copyright 2010-2017, Chef Software, Inc. - -```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. -``` diff --git a/cookbooks/hosting/berks-cookbooks/postgresql/libraries/helpers.rb b/cookbooks/hosting/berks-cookbooks/postgresql/libraries/helpers.rb deleted file mode 100644 index 431d5dd..0000000 --- a/cookbooks/hosting/berks-cookbooks/postgresql/libraries/helpers.rb +++ /dev/null @@ -1,247 +0,0 @@ -# -# Cookbook:: postgresql -# Library:: helpers -# -# 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. -# - -module PostgresqlCookbook - module Helpers - include Chef::Mixin::ShellOut - - require 'securerandom' - - def psql_command_string(new_resource, query, grep_for: nil, value_only: false) - 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 - cmd << " --port #{new_resource.port}" if new_resource.port - cmd << ' --tuples-only' if value_only - cmd << " | grep #{grep_for}" if grep_for - cmd - end - - 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' - - # 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) - - # Pass back cmd so we can decide what to do with it in the calling method. - cmd - end - - def database_exists?(new_resource) - sql = %(SELECT datname from pg_database WHERE datname='#{new_resource.database}') - - exists = psql_command_string(new_resource, sql, grep_for: new_resource.database) - - cmd = execute_sql(new_resource, exists) - cmd.exitstatus == 0 - end - - def user_exists?(new_resource) - sql = %(SELECT rolname FROM pg_roles WHERE rolname='#{new_resource.create_user}';) - - exists = psql_command_string(new_resource, sql, grep_for: new_resource.create_user) - - cmd = execute_sql(new_resource, exists) - cmd.exitstatus == 0 - end - - def extension_installed?(new_resource) - query = %(SELECT extversion FROM pg_extension WHERE extname='#{new_resource.extension}';) - check_extension_version = psql_command_string(new_resource, query, value_only: true) - version_result = execute_sql(new_resource, check_extension_version) - if new_resource.version - version_result.stdout == new_resource.version - else - !version_result.stdout.chomp.empty? - end - end - - def alter_role_sql(new_resource) - sql = %(ALTER ROLE postgres ENCRYPTED PASSWORD '#{postgres_password(new_resource)}';) - psql_command_string(new_resource, sql) - end - - def create_extension_sql(new_resource) - 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) - end - - def user_has_password?(new_resource) - sql = %(SELECT rolpassword from pg_authid WHERE rolname='postgres' AND rolpassword IS NOT NULL;) - cmd = psql_command_string(new_resource, sql) - - res = execute_sql(new_resource, cmd) - res.stdout =~ /1 row/ ? true : false - end - - def role_sql(new_resource) - sql = %(\\"#{new_resource.create_user}\\" WITH ) - - %w(superuser createdb createrole inherit replication login).each do |perm| - sql << "#{'NO' unless new_resource.send(perm)}#{perm.upcase} " - end - - sql << if new_resource.encrypted_password - "ENCRYPTED PASSWORD '#{new_resource.encrypted_password}'" - elsif new_resource.password - "PASSWORD '#{new_resource.password}'" - else - '' - end - - sql << if new_resource.valid_until - " VALID UNTIL '#{new_resource.valid_until}'" - else - '' - end - end - - def create_user_sql(new_resource) - sql = %(CREATE ROLE #{role_sql(new_resource)}) - psql_command_string(new_resource, sql) - end - - def update_user_sql(new_resource) - sql = %(ALTER ROLE #{role_sql(new_resource)}) - psql_command_string(new_resource, sql) - end - - def update_user_with_attributes_sql(new_resource, value) - sql = %(ALTER ROLE '#{new_resource.create_user}' SET #{attr} = #{value}) - psql_command_string(new_resource, sql) - end - - def drop_user_sql(new_resource) - sql = %(DROP ROLE IF EXISTS '#{new_resource.create_user}') - psql_command_string(new_resource, sql) - end - - def data_dir(version = node.run_state['postgresql']['version']) - case node['platform_family'] - when 'rhel', 'fedora' - "/var/lib/pgsql/#{version}/data" - when 'amazon' - if node['virtualization']['system'] == 'docker' - "/var/lib/pgsql#{version.delete('.')}/data" - else - "/var/lib/pgsql/#{version}/data" - end - when 'debian' - "/var/lib/postgresql/#{version}/main" - end - end - - def conf_dir(version = node.run_state['postgresql']['version']) - case node['platform_family'] - when 'rhel', 'fedora' - "/var/lib/pgsql/#{version}/data" - when 'amazon' - if node['virtualization']['system'] == 'docker' - "/var/lib/pgsql#{version.delete('.')}/data" - else - "/var/lib/pgsql/#{version}/data" - end - when 'debian' - "/etc/postgresql/#{version}/main" - end - end - - # determine the platform specific service name - def platform_service_name(version = node.run_state['postgresql']['version']) - case node['platform_family'] - when 'rhel', 'fedora' - "postgresql-#{version}" - when 'amazon' - if node['virtualization']['system'] == 'docker' - "postgresql#{version.delete('.')}" - else - "postgresql-#{version}" - end - else - 'postgresql' - end - end - - def follower? - ::File.exist? "#{data_dir}/recovery.conf" - end - - def initialized? - return true if ::File.exist?("#{conf_dir}/PG_VERSION") - false - end - - def secure_random - r = SecureRandom.hex - Chef::Log.debug "Generated password: #{r}" - r - end - - # determine the platform specific server package name - def server_pkg_name - platform_family?('debian') ? "postgresql-#{new_resource.version}" : "postgresql#{new_resource.version.delete('.')}-server" - end - - # determine the appropriate DB init command to run based on RHEL/Fedora/Amazon release - # initdb defaults to the execution environment. - # https://www.postgresql.org/docs/9.5/static/locale.html - def rhel_init_db_command(new_resource) - cmd = if platform_family?('amazon') - '/usr/bin/initdb' - else - "/usr/pgsql-#{new_resource.version}/bin/initdb" - end - cmd << " --locale '#{new_resource.initdb_locale}'" if new_resource.initdb_locale - cmd << " -D '#{data_dir(new_resource.version)}'" - end - - # Given the base URL build the complete URL string for a yum repo - def yum_repo_url(base_url) - "#{base_url}/#{new_resource.version}/#{yum_repo_platform_family_string}/#{yum_repo_platform_string}" - end - - # The postgresql yum repos URLs are organized into redhat and fedora directories.s - # route things to the right place based on platform_family - def yum_repo_platform_family_string - platform_family?('fedora') ? 'fedora' : 'redhat' - end - - # Build the platform string that makes up the final component of the yum repo URL - def yum_repo_platform_string - platform = platform?('fedora') ? 'fedora' : 'rhel' - release = platform?('amazon') ? '6' : '$releasever' - "#{platform}-#{release}-$basearch" - end - - # On Amazon use the RHEL 6 packages. Otherwise use the releasever yum variable - def yum_releasever - platform?('amazon') ? '6' : '$releasever' - 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 - end - end -end diff --git a/cookbooks/hosting/berks-cookbooks/postgresql/metadata.json b/cookbooks/hosting/berks-cookbooks/postgresql/metadata.json deleted file mode 100644 index 52a549a..0000000 --- a/cookbooks/hosting/berks-cookbooks/postgresql/metadata.json +++ /dev/null @@ -1 +0,0 @@ -{"name":"postgresql","version":"7.1.4","description":"Installs and configures postgresql for clients or servers","long_description":"# PostgreSQL cookbook\n\n[![Cookbook Version](https://img.shields.io/cookbook/v/postgresql.svg)](https://supermarket.chef.io/cookbooks/postgresql)\n[![Build Status](https://img.shields.io/circleci/project/github/sous-chefs/postgresql/master.svg)](https://circleci.com/gh/sous-chefs/postgresql)\n[![pullreminders](https://pullreminders.com/badge.svg)](https://pullreminders.com?ref=badge)\n\nInstalls and configures PostgreSQL as a client or a server.\n\n## Upgrading\n\nIf 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.\n\n## Requirements\n\n### Platforms\n\n- Amazon Linux\n- Debian 7+\n- Ubuntu 14.04+\n- Red Hat/CentOS/Scientific 6+\n- Fedora\n\n### PostgreSQL version\n\nWe follow the currently supported versions listed on \n\n### Chef\n\n- Chef 13.8+\n\n### Cookbook Dependencies\n\nNone.\n\n## Resources\n\n### postgresql_client_install\n\nThis resource installs PostgreSQL client packages.\n\n#### Actions\n\n- `install` - (default) Install client packages\n\n#### Properties\n\nName | Types | Description | Default | Required?\n------------------- | ----------------- | ------------------------------------------------------------- | ----------------------------------------- | ---------\n`version` | String | Version of PostgreSQL to install | '9.6' | no\n`setup_repo` | Boolean | Define if you want to add the PostgreSQL repo | true | no\n`hba_file` | String | | `#{conf_dir}/main/pg_hba.conf` | no\n`ident_file` | String | | `#{conf_dir}/main/pg_ident.conf` | no\n`external_pid_file` | String | | `/var/run/postgresql/#{version}-main.pid` | no\n`password` | String, nil | Pass in a password, or have the cookbook generate one for you | | no\n\n#### Examples\n\nTo install version 9.5:\n\n```ruby\npostgresql_client_install 'My PostgreSQL Client install' do\n version '9.5'\nend\n```\n\n### postgresql_server_install\n\nThis resource installs PostgreSQL client and server packages.\n\n#### Actions\n\n- `install` - (default) Install client and server packages\n- `create` - Initialize the database\n\n#### Properties\n\nName | Types | Description | Default | Required?\n------------------- | --------------- | --------------------------------------------- | -------------------------------------------------- | ---------\n`version` | String | Version of PostgreSQL to install | '9.6' | no\n`setup_repo` | Boolean | Define if you want to add the PostgreSQL repo | true | no\n`hba_file` | String | Path of pg_hba.conf file | `/pg_hba.conf'` | no\n`ident_file` | String | Path of pg_ident.conf file | `/pg_ident.conf` | no\n`external_pid_file` | String | Path of PID file | `/var/run/postgresql/-main.pid` | no\n`password` | String, nil | Set PostgreSQL user password | 'generate' | no\n`port` | Integer | Set listen port of PostgreSQL service | 5432 | no\n`initdb_locale` | String | Locale to initialise the database with | 'C' | no\n\n#### Examples\n\nTo install PostgreSQL server, set your own postgres password using non-default service port.\n\n```ruby\npostgresql_server_install 'My PostgreSQL Server install' do\n action :install\nend\n\npostgresql_server_install 'Setup my PostgreSQL 9.6 server' do\n password 'MyP4ssw0rd'\n port 5433\n action :create\nend\n```\n\n#### Known issues\n\nOn some platforms (e.g. Ubuntu 18.04), your `initdb_locale` should be set to the\nsame as the template database [GH-555](https://github.com/sous-chefs/postgresql/issues/555).\n\n### postgresql_server_conf\n\nThis resource manages postgresql.conf configuration file.\n\n#### Actions\n\n- `modify` - (default) Manager PostgreSQL configuration file (postgresql.conf)\n\n#### Properties\n\nName | Types | Description | Default | Required?\n---------------------- | ------- | --------------------------------------- | --------------------------------------------------- | ---------\n`version` | String | Version of PostgreSQL to install | '9.6' | no\n`data_directory` | String | Path of PostgreSQL data directory | `` | no\n`hba_file` | String | Path of pg_hba.conf file | `/pg_hba.conf` | no\n`ident_file` | String | Path of pg_ident.conf file | `/pg_ident.conf` | no\n`external_pid_file` | String | Path of PID file | `/var/run/postgresql/-main.pid` | no\n`stats_temp_directory` | String | Path of stats file | `/var/run/postgresql/version>-main.pg_stat_tmp` | no\n`port` | Integer | Set listen port of PostgreSQL service | 5432 | no\n`additional_config` | Hash | Extra configuration for the config file | {} | no\n\n#### Examples\n\nTo setup your PostgreSQL configuration with a specific data directory. If you have installed a specific version of PostgreSQL (different from 9.6), you must specify version in this resource too.\n\n```ruby\npostgresql_server_conf 'My PostgreSQL Config' do\n version '9.5'\n data_directory '/data/postgresql/9.5/main'\n notifies :reload, 'service[postgresql]'\nend\n```\n\n### postgresql_extension\n\nThis resource manages PostgreSQL extensions for a given database.\n\n#### Actions\n\n- `create` - (default) Creates an extension in a given database\n- `drop` - Drops an extension from the database\n\n#### Properties\n\nName | Types | Description | Default | Required?\n------------- | ------ | -------------------------------------------------------------------------------- | ---------------- | ---------\n`database` | String | Name of the database to install the extension into | | yes\n`extension` | String | Name of the extension to install the database | Name of resource | yes\n`version` | String | Version of the extension to install | | no\n`old_version` | String | Older module name for new extension replacement. Appends FROM to extension query | | no\n\n#### Examples\n\nTo install the `adminpack` extension:\n\n```ruby\n# Add the contrib package in Ubuntu/Debian\npackage 'postgresql-contrib-9.6'\n\n# Install adminpack extension\npostgresql_extension 'postgres adminpack' do\n database 'postgres'\n extension 'adminpack'\nend\n```\n\n### postgresql_access\n\nThis resource uses the accumulator pattern to build up the `pg_hba.conf` file via chef resources instead of piling on a mountain of chef attributes to make this cookbook more reusable. It directly mirrors the configuration options of the postgres hba file in the resource and by default notifies the server with a reload to avoid a full restart, causing a potential outage of service. To revoke access, simply remove the resource and the access change won't be computed into the final `pg_hba.conf`\n\n#### Actions\n\n- `grant` - (default) Creates an access line inside of `pg_hba.conf`\n\n#### Properties\n\nName | Types | Description | Default | Required?\n--------------- | ------ | ----------------------------------------------------------------------------------------- | ----------------- | ---------\n`name` | String | Name of the access resource, this is left as a comment inside the `pg_hba` config | Resource name | yes\n`source` | String | The cookbook template filename if you want to use your own custom template | 'pg_hba.conf.erb' | yes\n`cookbook` | String | The cookbook to look in for the template source | 'postgresql' | yes\n`comment` | String | A comment to leave above the entry in `pg_hba` | nil | no\n`access_type` | String | The type of access, e.g. local or host | 'local' | yes\n`access_db` | String | The database to access. Can use 'all' for all databases | 'all' | yes\n`access_user` | String | The user accessing the database. Can use 'all' for any user | 'all' | yes\n`access_addr` | String | The address(es) allowed access. Can be nil if method ident is used since it is local then | nil | no\n`access_method` | String | Authentication method to use | 'ident' | yes\n\n#### Examples\n\nTo grant access to the PostgreSQL user with ident authentication:\n\n```ruby\npostgresql_access 'local_postgres_superuser' do\n comment 'Local postgres superuser access'\n access_type 'local'\n access_db 'all'\n access_user 'postgres'\n access_addr nil\n access_method 'ident'\nend\n```\n\nThis generates the following line in the `pg_hba.conf`:\n\n```\n# Local postgres superuser access\nlocal all postgres ident\n```\n\n**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:\n\n```\n# \"local\" is for Unix domain socket connections only\nlocal all all peer\n```\n\n### postgresql_ident\n\nThis resource generate `pg_ident.conf` configuration file to manage user mapping between system and PostgreSQL users.\n\n#### Actions\n\n- `create` - (default) Creates an mapping line inside of `pg_ident.conf`\n\n#### Properties\n\nName | Types | Description | Default | Required?\n-------------- | ----------- | -------------------------------------------------------------------------- | ------------------- | ---------\n`mapname` | String | Name of the user mapping | Resource name | yes\n`source` | String | The cookbook template filename if you want to use your own custom template | 'pg_ident.conf.erb' | no\n`cookbook` | String | The cookbook to look in for the template source | 'postgresql' | no\n`comment` | String, nil | A comment to leave above the entry in `pg_ident` | nil | no\n`system_user` | String | System user or regexp used for the mapping | None | yes\n`pg_user` | String | Pg user or regexp used for the mapping | None | yes\n\n#### Examples\n\nCreates a `mymapping` mapping that map `john` system user to `user1` PostgreSQL user:\n\n```ruby\npostgresql_ident 'Map john to user1' do\n comment 'John Mapping'\n mapname 'mymapping'\n system_user 'john'\n pg_user 'user1'\nend\n```\n\nThis generates the following line in the `pg_ident.conf`:\n\n```\n# MAPNAME SYSTEM-USERNAME PG-USERNAME\n\n# John Mapping\nmymapping john user1\n```\n\nTo grant access to the foo user with password authentication:\n\n```ruby\npostgresql_access 'local_foo_user' do\n comment 'Foo user access'\n access_type 'host'\n access_db 'all'\n access_user 'foo'\n access_addr '127.0.0.1/32'\n access_method 'md5'\nend\n```\n\nThis generates the following line in the `pg_hba.conf`:\n\n```\n# Local postgres superuser access\nhost all foo 127.0.0.1/32 ident\n```\n\n### postgresql_database\n\nThis resource manages PostgreSQL databases.\n\n#### Actions\n\n- `create` - (default) Creates the given database.\n- `drop` - Drops the given database.\n\n#### Properties\n\nName | Types | Description | Default | Required?\n---------- | ------- | ------------------------------------------------------------------- | ------------------- | ---------\n`database` | String | Name of the database to create | Resource name | yes\n`user` | String | User which run psql command | 'postgres' | no\n`template` | String | Template used to create the new database | 'template1' | no\n`host` | String | Define the host server where the database creation will be executed | Not set (localhost) | no\n`port` | Integer | Define the port of PostgreSQL server | 5432 | no\n`encoding` | String | Define database encoding | 'UTF-8' | no\n`locale` | String | Define database locale | 'en_US.UTF-8' | no\n`owner` | String | Define the owner of the database | Not set | no\n\n#### Examples\n\nTo create database named 'my_app' with owner 'user1':\n\n```ruby\npostgresql_database 'my_app' do\n owner 'user1'\nend\n```\n\n#### Known issues\n\nOn some platforms (e.g. Ubuntu 18.04), your `initdb_locale` should be set to the\nsame as the template database [GH-555](https://github.com/sous-chefs/postgresql/issues/555).\n\n### postgresql_user\n\nThis resource manage PostgreSQL users.\n\n#### Actions\n\n- `create` - (default) Creates the given user with default or given privileges.\n- `update` - Update user privilieges.\n- `drop` - Deletes the given user.\n\n#### Properties\n\nName | Types | Description | Default | Required?\n-------------------- | ------- | ----------------------------------------------- | -------- | ---------\n`create_user` | String | User to create (defaults to the resource name) | | Yes\n`superuser` | Boolean | Define if user needs superuser role | false | no\n`createdb` | Boolean | Define if user needs createdb role | false | no\n`createrole` | Boolean | Define if user needs createrole role | false | no\n`inherit` | Boolean | Define if user inherits the privileges of roles | true | no\n`replication` | Boolean | Define if user needs replication role | false | no\n`login` | Boolean | Define if user can login | true | no\n`password` | String | Set user's password | | no\n`encrypted_password` | String | Set user's password with an hashed password | | no\n`valid_until` | String | Define an account expiration date | | no\n`attributes` | Hash | Additional attributes for :update action | {} | no\n`user` | String | User for command | postgres | no\n`database` | String | Database for command | | no\n`host` | String | Hostname for command | | no\n`port` | Integer | Port number to connect to postgres | 5432 | no\n\n#### Examples\n\nCreate a user `user1` with a password, with `createdb` role and set an expiration date to 2018, Dec 21.\n\n```ruby\npostgresql_user 'user1' do\n password 'UserP4ssword'\n createdb true\n valid_until '2018-12-31'\nend\n```\n\nCreate a user `user1` with a password, with `createdb` role and set an expiration date to 2018, Dec 21.\n\n```ruby\npostgresql_user 'user1' do\n password 'UserP4ssword'\n createdb true\n valid_until '2018-12-31'\nend\n```\n\n## Usage\n\nTo install and configure your PostgreSQL instance you need to create your own cookbook and call needed resources with your own parameters.\n\nMore examples can be found in `test/cookbooks/test/recipes`\n\n## Example Usage\n\n```ruby\n# cookbooks/my_postgresql/recipes/default.rb\n\npostgresql_client_install 'PostgreSQL Client' do\n setup_repo false\n version '10.6'\nend\n\npostgresql_server_install 'PostgreSQL Server' do\n version '10.6'\n setup_repo false\n password 'P0stgresP4ssword'\nend\n\npostgresql_server_conf 'PostgreSQL Config' do\n notifies :reload, 'service[postgresql]'\nend\n```\n\n## Contributing\n\nPlease refer to each project's style guidelines and guidelines for submitting patches and additions. In general, we follow the \"fork-and-pull\" Git workflow.\n\n1. **Fork** the repo on GitHub\n2. **Clone** the project to your own machine\n3. **Commit** changes to your own branch\n4. **Push** your work back up to your fork\n5. Submit a **Pull request** so that we can review your changes\n\nNOTE: Be sure to merge the latest from \"upstream\" before making a pull request!\n\n[Contribution informations for this project](CONTRIBUTING.md)\n\n## License\n\nCopyright 2010-2017, Chef Software, Inc.\n\n```text\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","maintainer":"Sous Chefs","maintainer_email":"help@sous-chefs.org","license":"Apache-2.0","platforms":{"ubuntu":">= 0.0.0","debian":">= 0.0.0","fedora":">= 0.0.0","amazon":">= 0.0.0","redhat":">= 0.0.0","centos":">= 0.0.0","scientific":">= 0.0.0","oracle":">= 0.0.0"},"dependencies":{},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{},"source_url":"https://github.com/sous-chefs/postgresql","issues_url":"https://github.com/sous-chefs/postgresql/issues","chef_version":[[">= 13.8"]],"ohai_version":[]} \ No newline at end of file diff --git a/cookbooks/hosting/berks-cookbooks/postgresql/metadata.rb b/cookbooks/hosting/berks-cookbooks/postgresql/metadata.rb deleted file mode 100644 index 9fb54ac..0000000 --- a/cookbooks/hosting/berks-cookbooks/postgresql/metadata.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true -name 'postgresql' -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' -source_url 'https://github.com/sous-chefs/postgresql' -issues_url 'https://github.com/sous-chefs/postgresql/issues' -chef_version '>= 13.8' - -%w(ubuntu debian fedora amazon redhat centos scientific oracle).each do |os| - supports os -end diff --git a/cookbooks/hosting/berks-cookbooks/postgresql/resources/access.rb b/cookbooks/hosting/berks-cookbooks/postgresql/resources/access.rb deleted file mode 100644 index 56d69cc..0000000 --- a/cookbooks/hosting/berks-cookbooks/postgresql/resources/access.rb +++ /dev/null @@ -1,59 +0,0 @@ -# frozen_string_literal: true -# -# Cookbook:: postgresql -# Resource:: access -# -# 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. -# - -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_addr, String -property :comment, String - -action :grant do - config_resource = new_resource - with_run_context :root do # ~FC037 - edit_resource(:template, "#{conf_dir}/pg_hba.conf") do |new_resource| - source new_resource.source - cookbook new_resource.cookbook - owner 'postgres' - group 'postgres' - mode '0600' - variables[:pg_hba] ||= {} - variables[:pg_hba][new_resource.name] = { - comment: new_resource.comment, - type: new_resource.access_type, - db: new_resource.access_db, - user: new_resource.access_user, - addr: new_resource.access_addr, - method: new_resource.access_method, - } - action :nothing - delayed_action :create - notifies :trigger, config_resource, :immediately - end - end -end - -action :trigger do - new_resource.updated_by_last_action(true) # ~FC085 -end - -action_class do - include PostgresqlCookbook::Helpers -end diff --git a/cookbooks/hosting/berks-cookbooks/postgresql/resources/client_install.rb b/cookbooks/hosting/berks-cookbooks/postgresql/resources/client_install.rb deleted file mode 100644 index 2698d00..0000000 --- a/cookbooks/hosting/berks-cookbooks/postgresql/resources/client_install.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true -# -# Cookbook:: postgresql -# Resource:: client_install -# -# 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. -# - -property :version, String, default: '9.6' -property :setup_repo, [true, false], default: true - -action :install do - postgresql_repository 'Add downloads.postgresql.org repository' do - version new_resource.version - only_if { new_resource.setup_repo } - end - - case node['platform_family'] - when 'debian' - package "postgresql-client-#{new_resource.version}" - when 'rhel', 'fedora', 'amazon' - ver = new_resource.version.delete('.') - package "postgresql#{ver}" - end -end diff --git a/cookbooks/hosting/berks-cookbooks/postgresql/resources/database.rb b/cookbooks/hosting/berks-cookbooks/postgresql/resources/database.rb deleted file mode 100644 index be2a813..0000000 --- a/cookbooks/hosting/berks-cookbooks/postgresql/resources/database.rb +++ /dev/null @@ -1,67 +0,0 @@ -# -# Cookbook:: postgresql -# Resource:: database -# -# 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. -# - -property :template, String, default: 'template1' -property :encoding, String, default: 'UTF-8' -property :locale, String, default: 'en_US.UTF-8' -property :owner, String - -# Connection prefernces -property :user, String, default: 'postgres' -property :database, String, name_property: true -property :host, [String, nil], default: nil -property :port, Integer, default: 5432 - -action :create do - createdb = 'createdb' - createdb << " -E #{new_resource.encoding}" if new_resource.encoding - createdb << " -l #{new_resource.locale}" if new_resource.locale - createdb << " -T #{new_resource.template}" unless new_resource.template.empty? - createdb << " -O #{new_resource.owner}" if new_resource.owner - createdb << " -U #{new_resource.user}" if new_resource.user - createdb << " -h #{new_resource.host}" if new_resource.host - createdb << " -p #{new_resource.port}" if new_resource.port - createdb << " #{new_resource.database}" - - bash "Create Database #{new_resource.database}" do - code createdb - user new_resource.user - not_if { follower? } - not_if { database_exists?(new_resource) } - end -end - -action :drop do - converge_by "Drop PostgreSQL Database #{new_resource.database}" do - dropdb = 'dropdb' - dropdb << " -U #{new_resource.user}" if new_resource.user - dropdb << " --host #{new_resource.host}" if new_resource.host - dropdb << " --port #{new_resource.port}" if new_resource.port - dropdb << " #{new_resource.database}" - - bash "drop postgresql database #{new_resource.database})" do - user 'postgres' - code dropdb - not_if { follower? } - only_if { database_exists?(new_resource) } - end - end -end - -action_class do - include PostgresqlCookbook::Helpers -end diff --git a/cookbooks/hosting/berks-cookbooks/postgresql/resources/extension.rb b/cookbooks/hosting/berks-cookbooks/postgresql/resources/extension.rb deleted file mode 100644 index fb104dd..0000000 --- a/cookbooks/hosting/berks-cookbooks/postgresql/resources/extension.rb +++ /dev/null @@ -1,49 +0,0 @@ -# -# Cookbook:: postgresql -# Resource:: extension -# -# 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. -# - -property :extension, String, name_property: true -property :old_version, String -property :version, String - -# Connection prefernces -property :user, String, default: 'postgres' -property :database, String, required: true -property :host, [String, nil] -property :port, Integer, default: 5432 - -action :create do - bash "CREATE EXTENSION #{new_resource.name}" do - code create_extension_sql(new_resource) - user 'postgres' - action :run - not_if { follower? || extension_installed?(new_resource) } - end -end - -action :drop do - bash "DROP EXTENSION #{new_resource.name}" do - code psql_command_string(new_resource, "DROP EXTENSION IF EXISTS \"#{new_resource.extension}\"") - user 'postgres' - action :run - not_if { follower? } - only_if { extension_installed?(new_resource) } - end -end - -action_class do - include PostgresqlCookbook::Helpers -end diff --git a/cookbooks/hosting/berks-cookbooks/postgresql/resources/ident.rb b/cookbooks/hosting/berks-cookbooks/postgresql/resources/ident.rb deleted file mode 100644 index ba677f0..0000000 --- a/cookbooks/hosting/berks-cookbooks/postgresql/resources/ident.rb +++ /dev/null @@ -1,55 +0,0 @@ -# frozen_string_literal: true -# -# Cookbook:: postgresql -# Resource:: access -# -# 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. -# - -property :mapname, String, required: true -property :source, String, default: 'pg_ident.conf.erb' -property :cookbook, String, default: 'postgresql' -property :system_user, String, required: true -property :pg_user, String, required: true -property :comment, [String, nil], default: nil - -action :create do - ident_resource = new_resource - with_run_context :root do # ~FC037 - edit_resource(:template, "#{conf_dir}/pg_ident.conf") do |new_resource| - source new_resource.source - cookbook new_resource.cookbook - owner 'postgres' - group 'postgres' - mode '0640' - variables[:pg_ident] ||= {} - variables[:pg_ident][new_resource.name] = { - comment: new_resource.comment, - mapname: new_resource.mapname, - system_user: new_resource.system_user, - pg_user: new_resource.pg_user, - } - action :nothing - delayed_action :create - notifies :trigger, ident_resource, :immediately - end - end -end - -action :trigger do - new_resource.updated_by_last_action(true) # ~FC085 -end - -action_class do - include PostgresqlCookbook::Helpers -end diff --git a/cookbooks/hosting/berks-cookbooks/postgresql/resources/repository.rb b/cookbooks/hosting/berks-cookbooks/postgresql/resources/repository.rb deleted file mode 100644 index 7040c6b..0000000 --- a/cookbooks/hosting/berks-cookbooks/postgresql/resources/repository.rb +++ /dev/null @@ -1,90 +0,0 @@ -# frozen_string_literal: true -# -# Cookbook:: postgresql -# Resource:: repository -# -# 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. -# - -property :version, String, default: '9.6' -property :enable_pgdg, [true, false], default: true -property :enable_pgdg_source, [true, false], default: false -property :enable_pgdg_updates_testing, [true, false], default: false -property :enable_pgdg_source_updates_testing, [true, false], default: false -property :yum_gpg_key_uri, String, default: 'https://download.postgresql.org/pub/repos/yum/RPM-GPG-KEY-PGDG' -property :apt_gpg_key_uri, String, default: 'https://download.postgresql.org/pub/repos/apt/ACCC4CF8.asc' - -action :add do - case node['platform_family'] - - when 'rhel', 'fedora', 'amazon' - remote_file "/etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-#{new_resource.version}" do - source new_resource.yum_gpg_key_uri - end - - yum_repository "PostgreSQL #{new_resource.version}" do # ~FC005 - repositoryid "pgdg#{new_resource.version}" - description "PostgreSQL.org #{new_resource.version}" - baseurl yum_repo_url('https://download.postgresql.org/pub/repos/yum') - enabled new_resource.enable_pgdg - gpgcheck true - gpgkey "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-#{new_resource.version}" - end - - yum_repository "PostgreSQL #{new_resource.version} - source " do - repositoryid "pgdg#{new_resource.version}-source" - description "PostgreSQL.org #{new_resource.version} Source" - baseurl yum_repo_url('https://download.postgresql.org/pub/repos/yum/srpms') - enabled new_resource.enable_pgdg_source - gpgcheck true - gpgkey "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-#{new_resource.version}" - end - - yum_repository "PostgreSQL #{new_resource.version} - updates testing" do - repositoryid "pgdg#{new_resource.version}-updates-testing" - description "PostgreSQL.org #{new_resource.version} Updates Testing" - baseurl yum_repo_url('https://download.postgresql.org/pub/repos/yum/testing') - enabled new_resource.enable_pgdg_updates_testing - gpgcheck true - gpgkey "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-#{new_resource.version}" - end - - yum_repository "PostgreSQL #{new_resource.version} - source - updates testing" do - repositoryid "pgdg#{new_resource.version}-source-updates-testing" - description "PostgreSQL.org #{new_resource.version} Source Updates Testing" - baseurl yum_repo_url('https://download.postgresql.org/pub/repos/yum/srpms/testing') - enabled new_resource.enable_pgdg_source_updates_testing - gpgcheck true - gpgkey "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-#{new_resource.version}" - end - - when 'debian' - apt_update - - package 'apt-transport-https' - - apt_repository 'postgresql_org_repository' do - uri 'https://download.postgresql.org/pub/repos/apt/' - components ['main', new_resource.version.to_s] - distribution "#{node['lsb']['codename']}-pgdg" - key new_resource.apt_gpg_key_uri - cache_rebuild true - end - else - raise "The platform_family '#{node['platform_family']}' or platform '#{node['platform']}' is not supported by the postgresql_repository resource. If you believe this platform can/should be supported by this resource please file and issue or open a pull request at https://github.com/sous-chefs/postgresql" - end -end - -action_class do - include PostgresqlCookbook::Helpers -end diff --git a/cookbooks/hosting/berks-cookbooks/postgresql/resources/server_conf.rb b/cookbooks/hosting/berks-cookbooks/postgresql/resources/server_conf.rb deleted file mode 100644 index 3c44c22..0000000 --- a/cookbooks/hosting/berks-cookbooks/postgresql/resources/server_conf.rb +++ /dev/null @@ -1,52 +0,0 @@ -# frozen_string_literal: true -# -# Cookbook:: postgresql -# Resource:: server_conf -# -# 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. -# - -include PostgresqlCookbook::Helpers - -property :version, String, default: '9.6' -property :data_directory, String, default: lazy { data_dir } -property :hba_file, String, default: lazy { "#{conf_dir}/pg_hba.conf" } -property :ident_file, String, default: lazy { "#{conf_dir}/pg_ident.conf" } -property :external_pid_file, String, default: lazy { "/var/run/postgresql/#{version}-main.pid" } -property :stats_temp_directory, String, default: lazy { "/var/run/postgresql/#{version}-main.pg_stat_tmp" } -property :port, Integer, default: 5432 -property :additional_config, Hash, default: {} -property :cookbook, String, default: 'postgresql' - -action :modify do - template "#{conf_dir}/postgresql.conf" do - cookbook new_resource.cookbook - source 'postgresql.conf.erb' - owner 'postgres' - group 'postgres' - mode '0644' - variables( - data_dir: new_resource.data_directory, - hba_file: new_resource.hba_file, - ident_file: new_resource.ident_file, - external_pid_file: new_resource.external_pid_file, - stats_temp_directory: new_resource.stats_temp_directory, - port: new_resource.port, - additional_config: new_resource.additional_config - ) - end -end - -action_class do - include PostgresqlCookbook::Helpers -end diff --git a/cookbooks/hosting/berks-cookbooks/postgresql/resources/server_install.rb b/cookbooks/hosting/berks-cookbooks/postgresql/resources/server_install.rb deleted file mode 100644 index 3c66c67..0000000 --- a/cookbooks/hosting/berks-cookbooks/postgresql/resources/server_install.rb +++ /dev/null @@ -1,76 +0,0 @@ -# frozen_string_literal: true -# -# Cookbook:: postgresql -# Resource:: server_install -# -# 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. -# - -include PostgresqlCookbook::Helpers - -property :version, String, default: '9.6' -property :setup_repo, [true, false], default: true -property :hba_file, String, default: lazy { "#{conf_dir}/main/pg_hba.conf" } -property :ident_file, String, default: lazy { "#{conf_dir}/main/pg_ident.conf" } -property :external_pid_file, String, default: lazy { "/var/run/postgresql/#{version}-main.pid" } -property :password, [String, nil], default: 'generate' # Set to nil if we do not want to set a password -property :port, Integer, default: 5432 -property :initdb_locale, String - -# Connection preferences -property :user, String, default: 'postgres' -property :database, String -property :host, [String, nil] - -action :install do - node.run_state['postgresql'] ||= {} - node.run_state['postgresql']['version'] = new_resource.version - - postgresql_client_install 'Install PostgreSQL Client' do - version new_resource.version - setup_repo new_resource.setup_repo - end - - package server_pkg_name -end - -action :create do - execute 'init_db' do - command rhel_init_db_command(new_resource) - user new_resource.user - not_if { initialized? } - only_if { platform_family?('rhel', 'fedora', 'amazon') } - end - - # We use to use find_resource here. - # But that required the user to do the same in their recipe. - # This also seemed to never trigger notifications, therefore requiring a log resource - # to notify the enable/start on the service, which always fires (Check v7.0 tag for more) - service 'postgresql' do - service_name platform_service_name - supports restart: true, status: true, reload: true - action [:enable, :start] - end - - # Generate a random password or set it as per new_resource.password. - bash 'generate-postgres-password' do - user 'postgres' - code alter_role_sql(new_resource) - not_if { user_has_password?(new_resource) } - not_if { new_resource.password.nil? } - end -end - -action_class do - include PostgresqlCookbook::Helpers -end diff --git a/cookbooks/hosting/berks-cookbooks/postgresql/resources/user.rb b/cookbooks/hosting/berks-cookbooks/postgresql/resources/user.rb deleted file mode 100644 index 05da73b..0000000 --- a/cookbooks/hosting/berks-cookbooks/postgresql/resources/user.rb +++ /dev/null @@ -1,87 +0,0 @@ -# -# Cookbook:: postgresql -# Resource:: user -# -# 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. -# - -property :create_user, String, name_property: true -property :superuser, [true, false], default: false -property :createdb, [true, false], default: false -property :createrole, [true, false], default: false -property :inherit, [true, false], default: true -property :replication, [true, false], default: false -property :login, [true, false], default: true -property :password, String -property :encrypted_password, String -property :valid_until, String -property :attributes, Hash, default: {} - -# Connection prefernces -property :user, String, default: 'postgres' -property :database, String -property :host, String -property :port, Integer, default: 5432 - -action :create do - Chef::Log.warn('You cannot use "attributes" property with create action.') unless new_resource.attributes.empty? - - execute "create postgresql user #{new_resource.create_user}" do # ~FC009 - user 'postgres' - command create_user_sql(new_resource) - sensitive new_resource.sensitive - not_if { follower? || user_exists?(new_resource) } - end -end - -action :update do - if new_resource.attributes.empty? - execute "update postgresql user #{new_resource.create_user}" do - user 'postgres' - command update_user_sql(new_resource) - sensitive true - not_if { follower? } - only_if { user_exists?(new_resource) } - end - else - new_resource.attributes.each do |attr, value| - v = if value.is_a?(TrueClass) || value.is_a?(FalseClass) - value.to_s - else - "'#{value}'" - end - - execute "Update postgresql user #{new_resource.create_user} to set #{attr}" do - user 'postgres' - command update_user_with_attributes_sql(new_resource, v) - sensitive true - not_if { follower? } - only_if { user_exists?(new_resource) } - end - end - end -end - -action :drop do - execute "drop postgresql user #{new_resource.create_user}" do - user 'postgres' - command drop_user_sql(new_resource) - sensitive true - not_if { follower? } - only_if { user_exists?(new_resource) } - end -end - -action_class do - include PostgresqlCookbook::Helpers -end diff --git a/cookbooks/hosting/berks-cookbooks/postgresql/templates/pg_hba.conf.erb b/cookbooks/hosting/berks-cookbooks/postgresql/templates/pg_hba.conf.erb deleted file mode 100644 index 9eab8a9..0000000 --- a/cookbooks/hosting/berks-cookbooks/postgresql/templates/pg_hba.conf.erb +++ /dev/null @@ -1,33 +0,0 @@ -# This file was automatically generated and dropped off by Chef! - -# PostgreSQL Client Authentication Configuration File -# =================================================== -# -# Refer to the "Client Authentication" section in the PostgreSQL -# documentation for a complete description of this file. - -local all postgres peer - -# TYPE DATABASE USER ADDRESS METHOD - -# "local" is for Unix domain socket connections only -local all all peer -# IPv4 local connections: -host all all 127.0.0.1/32 md5 -# IPv6 local connections: -host all all ::1/128 md5 - -########### -# From the postgresql_access resources -########### -<% @pg_hba.each do |k,v| -%> -# <%= k %> -<% if v[:comment] -%> -# <%= v[:comment] %> -<% end -%> -<% if v[:addr] %> -<%= v[:type].ljust(7) %> <%= v[:db].ljust(15) %> <%= v[:user].ljust(15) %> <%= v[:addr].ljust(23) %> <%= v[:method] %> -<% else %> -<%= v[:type].ljust(7) %> <%= v[:db].ljust(15) %> <%= v[:user].ljust(15) %> <%= v[:method] %> -<% end %> -<% end %> diff --git a/cookbooks/hosting/berks-cookbooks/postgresql/templates/pg_ident.conf.erb b/cookbooks/hosting/berks-cookbooks/postgresql/templates/pg_ident.conf.erb deleted file mode 100644 index f3ba499..0000000 --- a/cookbooks/hosting/berks-cookbooks/postgresql/templates/pg_ident.conf.erb +++ /dev/null @@ -1,49 +0,0 @@ -# PostgreSQL User Name Maps -# ========================= -# -# Refer to the PostgreSQL documentation, chapter "Client -# Authentication" for a complete description. A short synopsis -# follows. -# -# This file controls PostgreSQL user name mapping. It maps external -# user names to their corresponding PostgreSQL user names. Records -# are of the form: -# -# MAPNAME SYSTEM-USERNAME PG-USERNAME -# -# (The uppercase quantities must be replaced by actual values.) -# -# MAPNAME is the (otherwise freely chosen) map name that was used in -# pg_hba.conf. SYSTEM-USERNAME is the detected user name of the -# client. PG-USERNAME is the requested PostgreSQL user name. The -# existence of a record specifies that SYSTEM-USERNAME may connect as -# PG-USERNAME. -# -# If SYSTEM-USERNAME starts with a slash (/), it will be treated as a -# regular expression. Optionally this can contain a capture (a -# parenthesized subexpression). The substring matching the capture -# will be substituted for \1 (backslash-one) if present in -# PG-USERNAME. -# -# Multiple maps may be specified in this file and used by pg_hba.conf. -# -# No map names are defined in the default configuration. If all -# system user names and PostgreSQL user names are the same, you don't -# need anything in this file. -# -# This file is read on server startup and when the postmaster receives -# a SIGHUP signal. If you edit the file on a running system, you have -# to SIGHUP the postmaster for the changes to take effect. You can -# use "pg_ctl reload" to do that. - -# Put your actual configuration here -# ---------------------------------- - -# MAPNAME SYSTEM-USERNAME PG-USERNAME -<% @pg_ident.each do |k,v| -%> - <% if v[:comment] -%> - -# <%= v[:comment] %> - <% end -%> -<%= v[:mapname].ljust(15) %> <%= v[:system_user].ljust(23) %> <%= v[:pg_user].ljust(15) %> -<% end %> diff --git a/cookbooks/hosting/berks-cookbooks/postgresql/templates/pgsql.sysconfig.erb b/cookbooks/hosting/berks-cookbooks/postgresql/templates/pgsql.sysconfig.erb deleted file mode 100644 index 2740356..0000000 --- a/cookbooks/hosting/berks-cookbooks/postgresql/templates/pgsql.sysconfig.erb +++ /dev/null @@ -1,2 +0,0 @@ -PGDATA=<%= @postgresql_dir %> -PGPORT=<%= @port %> diff --git a/cookbooks/hosting/berks-cookbooks/postgresql/templates/postgresql.conf.erb b/cookbooks/hosting/berks-cookbooks/postgresql/templates/postgresql.conf.erb deleted file mode 100644 index 7656770..0000000 --- a/cookbooks/hosting/berks-cookbooks/postgresql/templates/postgresql.conf.erb +++ /dev/null @@ -1,26 +0,0 @@ -# PostgreSQL configuration file -# This file was automatically generated and dropped off by chef! -# Please refer to the PostgreSQL documentation for details on -# configuration settings. - -data_directory = '<%= @data_dir %>' -hba_file = '<%= @hba_file %>' -ident_file = '<%= @ident_file %>' -external_pid_file = '<%= @external_pid_file %>' -stats_temp_directory = '<%= @stats_temp_directory %>' -port = <%= @port %> -<% @additional_config.sort.each do |key, value| %> -<% next if value.nil? -%> -<%= key %> = <%= - case value - when String - "'#{value}'" - when TrueClass - 'on' - when FalseClass - 'off' - else - value - end -%> -<% end %> diff --git a/cookbooks/hosting/berks-cookbooks/postgresql/templates/postgresql.service.erb b/cookbooks/hosting/berks-cookbooks/postgresql/templates/postgresql.service.erb deleted file mode 100644 index 688e7d5..0000000 --- a/cookbooks/hosting/berks-cookbooks/postgresql/templates/postgresql.service.erb +++ /dev/null @@ -1,6 +0,0 @@ -[Service] -.include /usr/lib/systemd/system/<%= @svc_name %>.service - -Environment= -Environment=PGPORT=<%= @port %> -Environment=PGDATA=<%= @data_dir %>