Skip to content

Commit

Permalink
Improve PostgreSQL documentation and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zuazo committed Sep 19, 2015
1 parent 491d5c0 commit e6b050b
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 1 deletion.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,36 @@ run_list(
```

Upgrading application
=======
=====================

If new owncloud version is released and you has notified in web user interface about update available, then you must re-run chef-client on owncloud server.

Cookbook recipes will download latest release version and install it to server.

Then you must proceed with update in web interface and system will be updated.

PostgreSQL Support
==================

PostfixAdmin with PostgreSQL may not work properly on some platforms: See for example [`postgresql` cookbook issue #249](https://github.com/hw-cookbooks/postgresql/issues/249). [Any feedback you can provide regarding the PostgreSQL support](https://github.com/zuazo/owncloud-cookbook/issues/new?title=PostgreSQL%20Support) will be greatly appreciated.

## PostgreSQL Support on Debian and Ubuntu

Due to [`postgresql` cookbook issue #108](https://github.com/hw-cookbooks/postgresql/issues/108), you should configure your system locale correctly for PostgreSQL to work. You can use the `locale` cookbook to fix this. For example:

```ruby
ENV['LANGUAGE'] = ENV['LANG'] = node['locale']['lang']
ENV['LC_ALL'] = node['locale']['lang']
include_recipe 'locale'
# ...
node.default['owncloud']['config']['dbtype'] = 'pgsql'
include_recipe 'owncloud'
```

## PostgreSQL Versions `< 9.3`

If you are using PostgreSQL version `< 9.3`, you may need to adjust the `shmmax` and `shmall` kernel parameters to configure the shared memory. You can see [the example used for the integration tests](https://github.com/zuazo/owncloud-cookbook/tree/master/test/cookbooks/owncloud_test/recipes/postgresql_memory.rb).

Testing
=======

Expand Down
2 changes: 2 additions & 0 deletions test/cookbooks/owncloud_test/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.0'

depends 'locale', '~> 1.0'
depends 'nokogiri', '~> 0.1.4'
depends 'owncloud'
13 changes: 13 additions & 0 deletions test/cookbooks/owncloud_test/recipes/postgresql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,22 @@
# limitations under the License.
#

if node['platform_family'] == 'debian'
# Debian/Ubuntu requires locale cookbook:
# https://github.com/hw-cookbooks/postgresql/issues/108
ENV['LANGUAGE'] = ENV['LANG'] = node['locale']['lang']
ENV['LC_ALL'] = node['locale']['lang']
include_recipe 'locale'
end

node.default['owncloud']['database']['rootpassword'] = 'vagrant_postgres'

node.default['owncloud']['config']['dbpassword'] = 'database_pass'
node.default['owncloud']['config']['dbtype'] = 'pgsql'

include_recipe 'owncloud_test::postgresql_memory'

include_recipe 'owncloud_test::common'

# Required for integration tests:
include_recipe 'nokogiri'
51 changes: 51 additions & 0 deletions test/cookbooks/owncloud_test/recipes/postgresql_memory.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# encoding: UTF-8
#
# Cookbook Name:: owncloud_test
# Recipe:: postgresql_memory
# Author:: Xabier de Zuazo (<xabier@zuazo.org>)
# Copyright:: Copyright (c) 2015 Xabier de Zuazo
# License:: Apache License, Version 2.0
#
# 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.
#

def getconf(var)
cmd = Mixlib::ShellOut.new("getconf #{var}").run_command
cmd.error!
cmd.stdout.split("\n")[-1]
end

if node['postgresql']['version'].to_f <= 9.3
page_size = getconf('PAGE_SIZE').to_i
phys_pages = getconf('_PHYS_PAGES').to_i

shmall = phys_pages / 2
shmmax = shmall * page_size

execute 'sysctl -p /etc/sysctl.d/postgresql.conf' do
action :nothing
end

template '/etc/sysctl.d/postgresql.conf' do
source 'sysctl.conf.erb'
variables(
values: {
'kernel.shmall' => shmall,
'kernel.shmmax' => shmmax
}
)
only_if { ::File.exist?('/etc/sysctl.d') }
notifies :run, 'execute[sysctl -p /etc/sysctl.d/postgresql.conf]',
:immediately
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Generated by Chef
<% @values.each do |k, v| -%>
<%= k %>=<%= v %>
<% end -%>

0 comments on commit e6b050b

Please sign in to comment.