Skip to content

Commit

Permalink
Move some database attributes to the [mysql] node namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
zuazo committed Sep 20, 2015
1 parent 0665b0f commit 778211d
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 90 deletions.
98 changes: 50 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,53 +45,55 @@ On RedHat based platforms, you need to disable or configure SELinux correctly. Y
Attributes
==========

| Attribute | Default | Description |
|:--------------------------------------------------|:--------------|:-------------------------------|
| `node['owncloud']['version']` | `'latest'` | Version of ownCloud to install.
| `node['owncloud']['download_url']` | *calculated* | URL from where ownCloud will be downloaded.
| `node['owncloud']['deploy_from_git']` | `false` | Whether ownCloud should be deployed from the git repository.
| `node['owncloud']['git_repo']` | *calculated* | URL of the ownCloud git repository.
| `node['owncloud']['git_ref']` | `nil` | Git reference to deploy.
| `node['owncloud']['www_dir']` | *calculated* | Root directory defined in the web server where web documents are stored.
| `node['owncloud']['dir']` | *calculated* | Directory where ownCloud will be installed.
| `node['owncloud']['data_dir']` | *calculated* | Directory where ownCloud data will be stored.
| `node['owncloud']['server_name']` | *calculated* | Sets the server name for the ownCloud virtual host.
| `node['owncloud']['server_aliases']` | `[]` | Sets the server name aliases for the ownCloud virtual host.
| `node['owncloud']['install_postfix']` | `true` | Whether to install Postfix when a local MTA is needed.
| `node['owncloud']['web_server']` | `'apache'` | Web server to use: `'apache'` or `'nginx'`.
| `node['owncloud']['php-fpm']['pool']` | `'owncloud'` | PHP-FPM pool name to use with ownCloud.
| `node['owncloud']['max_upload_size']` | `'512M'` | Maximum allowed size for uploaded files.
| `node['owncloud']['sendfile']` | *calculated* | Whether to enable *sendfile* on web server. You should set to `'false'` if you use NFS or SMB mounts.
| `node['owncloud']['ssl']` | `true` | Whether ownCloud should accept requests through TLS.
| `node['owncloud']['admin']['user']` | `'admin'` | Administrator username.
| `node['owncloud']['admin']['pass']` | *calculated* | Administrator password.
| `node['owncloud']['config']['dbtype']` | `'mysql'` | Type of database, can be `'sqlite'`, `'mysql'` or `'pgsql'`.
| `node['owncloud']['config']['dbname']` | `'owncloud'` | Name of the ownCloud database.
| `node['owncloud']['config']['dbuser']` | `'owncloud'` | User to access the ownCloud database.
| `node['owncloud']['config']['dbpassword']` | *calculated* | Password to access the ownCloud database.
| `node['owncloud']['config']['dbhost']` | `'127.0.0.1'` | Host running the ownCloud database.
| `node['owncloud']['config']['dbport']` | *calculated* | Port the ownCloud database is running at.
| `node['owncloud']['config']['dbtableprefix']` | `''` | Prefix for the ownCloud tables in the database.
| `node['owncloud']['config']['mail_smtpmode']` | `'sendmail'` | Mode to use for sending mail, can be `'sendmail'`, `'smtp'`, `'qmail'` or `'php'`.
| `node['owncloud']['config']['mail_smtphost']` | `'127.0.0.1'` | Host to use for sending mail, depends on *mail_smtpmode* if this is used.
| `node['owncloud']['config']['mail_smtpport']` | `25` | Port to use for sending mail, depends on *mail_smtpmode* if this is used.
| `node['owncloud']['config']['mail_smtptimeout']` | `10` | SMTP server timeout in seconds for sending mail, depends on *mail_smtpmode* if this is used.
| `node['owncloud']['config']['mail_smtpsecure']` | `''` | SMTP connection prefix or sending mail, depends on *mail_smtpmode* if this is used. Can be `''`, `'ssl'` or `'tls'`.
| `node['owncloud']['config']['mail_smtpauth']` | `false` | Whether authentication is needed to send mail, depends on *mail_smtpmode* if this is used.
| `node['owncloud']['config']['mail_smtpauthtype']` | `'LOGIN'` | Authentication type needed to send mail, depends on *mail_smtpmode* if this is used. Can be `'LOGIN'`, `'PLAIN'` or `'NTLM'`.
| `node['owncloud']['config']['mail_smtpname']` | `''` | Username to use for sendmail mail, depends on *mail_smtpauth* if this is used.
| `node['owncloud']['config']['mail_smtppassword']` | `''` | Password to use for sendmail mail, depends on *mail_smtpauth* if this is used.
| `node['owncloud']['cron']['enabled']` | `true` | Whether to enable ownCloud cron job.
| `node['owncloud']['cron']['min']` | `'*/15'` | Minute to run ownCloud cron at.
| `node['owncloud']['cron']['hour']` | `'*'` | Hour to run ownCloud cron at.
| `node['owncloud']['cron']['day']` | `'*'` | Day of month to run ownCloud cron at.
| `node['owncloud']['cron']['month']` | `'*'` | Month to run ownCloud cron at.
| `node['owncloud']['cron']['weekday']` | `'*'` | Weekday to run ownCloud cron at.
| `node['owncloud']['skip_permissions']` | `false` | Whether to skip settings the permissions of the ownCloud directory. Set this to `true` when using NFS synced folders.
| `node['owncloud']['database']['rootpassword']` | *calculated* | Database admin password to access a database instance.
| `node['owncloud']['database']['instance']` | `'default'` | MySQL database instance name to run by the `mysql_service` LWRP from the [mysql](https://supermarket.chef.io/cookbooks/mysql) cookbook.
| `node['owncloud']['database']['version']` | `nil` | MySQL version to install by the `mysql_service` LWRP. Refer to [`mysql` cookbook platform support section](https://github.com/chef-cookbooks/mysql#platform-support).
| `node['owncloud']['database']['data_dir']` | *calculated* | MySQL data files path.
| Attribute | Default | Description |
|:----------------------------------------------------|:--------------|:-------------------------------|
| `node['owncloud']['version']` | `'latest'` | Version of ownCloud to install.
| `node['owncloud']['download_url']` | *calculated* | URL from where ownCloud will be downloaded.
| `node['owncloud']['deploy_from_git']` | `false` | Whether ownCloud should be deployed from the git repository.
| `node['owncloud']['git_repo']` | *calculated* | URL of the ownCloud git repository.
| `node['owncloud']['git_ref']` | `nil` | Git reference to deploy.
| `node['owncloud']['www_dir']` | *calculated* | Root directory defined in the web server where web documents are stored.
| `node['owncloud']['dir']` | *calculated* | Directory where ownCloud will be installed.
| `node['owncloud']['data_dir']` | *calculated* | Directory where ownCloud data will be stored.
| `node['owncloud']['server_name']` | *calculated* | Sets the server name for the ownCloud virtual host.
| `node['owncloud']['server_aliases']` | `[]` | Sets the server name aliases for the ownCloud virtual host.
| `node['owncloud']['install_postfix']` | `true` | Whether to install Postfix when a local MTA is needed.
| `node['owncloud']['web_server']` | `'apache'` | Web server to use: `'apache'` or `'nginx'`.
| `node['owncloud']['php-fpm']['pool']` | `'owncloud'` | PHP-FPM pool name to use with ownCloud.
| `node['owncloud']['max_upload_size']` | `'512M'` | Maximum allowed size for uploaded files.
| `node['owncloud']['sendfile']` | *calculated* | Whether to enable *sendfile* on web server. You should set to `'false'` if you use NFS or SMB mounts.
| `node['owncloud']['ssl']` | `true` | Whether ownCloud should accept requests through TLS.
| `node['owncloud']['admin']['user']` | `'admin'` | Administrator username.
| `node['owncloud']['admin']['pass']` | *calculated* | Administrator password.
| `node['owncloud']['config']['dbtype']` | `'mysql'` | Type of database, can be `'sqlite'`, `'mysql'` or `'pgsql'`.
| `node['owncloud']['config']['dbname']` | `'owncloud'` | Name of the ownCloud database.
| `node['owncloud']['config']['dbuser']` | `'owncloud'` | User to access the ownCloud database.
| `node['owncloud']['config']['dbpassword']` | *calculated* | Password to access the ownCloud database.
| `node['owncloud']['config']['dbhost']` | `'127.0.0.1'` | Host running the ownCloud database.
| `node['owncloud']['config']['dbport']` | *calculated* | Port the ownCloud database is running at.
| `node['owncloud']['config']['dbtableprefix']` | `''` | Prefix for the ownCloud tables in the database.
| `node['owncloud']['config']['mail_smtpmode']` | `'sendmail'` | Mode to use for sending mail, can be `'sendmail'`, `'smtp'`, `'qmail'` or `'php'`.
| `node['owncloud']['config']['mail_smtphost']` | `'127.0.0.1'` | Host to use for sending mail, depends on *mail_smtpmode* if this is used.
| `node['owncloud']['config']['mail_smtpport']` | `25` | Port to use for sending mail, depends on *mail_smtpmode* if this is used.
| `node['owncloud']['config']['mail_smtptimeout']` | `10` | SMTP server timeout in seconds for sending mail, depends on *mail_smtpmode* if this is used.
| `node['owncloud']['config']['mail_smtpsecure']` | `''` | SMTP connection prefix or sending mail, depends on *mail_smtpmode* if this is used. Can be `''`, `'ssl'` or `'tls'`.
| `node['owncloud']['config']['mail_smtpauth']` | `false` | Whether authentication is needed to send mail, depends on *mail_smtpmode* if this is used.
| `node['owncloud']['config']['mail_smtpauthtype']` | `'LOGIN'` | Authentication type needed to send mail, depends on *mail_smtpmode* if this is used. Can be `'LOGIN'`, `'PLAIN'` or `'NTLM'`.
| `node['owncloud']['config']['mail_smtpname']` | `''` | Username to use for sendmail mail, depends on *mail_smtpauth* if this is used.
| `node['owncloud']['config']['mail_smtppassword']` | `''` | Password to use for sendmail mail, depends on *mail_smtpauth* if this is used.
| `node['owncloud']['cron']['enabled']` | `true` | Whether to enable ownCloud cron job.
| `node['owncloud']['cron']['min']` | `'*/15'` | Minute to run ownCloud cron at.
| `node['owncloud']['cron']['hour']` | `'*'` | Hour to run ownCloud cron at.
| `node['owncloud']['cron']['day']` | `'*'` | Day of month to run ownCloud cron at.
| `node['owncloud']['cron']['month']` | `'*'` | Month to run ownCloud cron at.
| `node['owncloud']['cron']['weekday']` | `'*'` | Weekday to run ownCloud cron at.
| `node['owncloud']['skip_permissions']` | `false` | Whether to skip settings the permissions of the ownCloud directory. Set this to `true` when using NFS synced folders.
| `node['owncloud']['mysql']['instance']` | `'default'` | MySQL database instance name to run by the `mysql_service` LWRP from the [mysql](https://supermarket.chef.io/cookbooks/mysql) cookbook.
| `node['owncloud']['mysql']['data_dir']` | *calculated* | MySQL data files path.
| `node['owncloud']['mysql']['run_group']` | *calculated* | MySQL system group.
| `node['owncloud']['mysql']['run_user']` | *calculated* | MySQL system user.
| `node['owncloud']['mysql']['version']` | `nil` | MySQL version to install by the `mysql_service` LWRP. Refer to [`mysql` cookbook platform support section](https://github.com/chef-cookbooks/mysql#platform-support).
| `node['owncloud']['mysql']['server_root_password']` | *calculated* | MySQL root password to access a database instance.

Recipes
=======
Expand All @@ -111,7 +113,7 @@ On the first run, several passwords will be automatically generated and stored i

* `node['owncloud']['admin']['pass']`
* `node['owncloud']['config']['dbpassword']` (Only when using *MySQL* or *PostgreSQL*)
* `node['owncloud']['database']['rootpassword']` (Only when using *MySQL* or *PostgreSQL*)
* `node['owncloud']['mysql']['server_root_password']` (Only when using *MySQL*)

When using Chef Solo, these passwords need to be set manually.

Expand Down
10 changes: 6 additions & 4 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@
default['owncloud']['cron']['month'] = '*'
default['owncloud']['cron']['weekday'] = '*'

default['owncloud']['database']['data_dir'] = nil
default['owncloud']['database']['instance'] = 'default'
default['owncloud']['database']['rootpassword'] = nil
default['owncloud']['database']['version'] = nil
default['owncloud']['mysql']['instance'] = 'default'
default['owncloud']['mysql']['data_dir'] = nil
default['owncloud']['mysql']['run_group'] = nil
default['owncloud']['mysql']['run_user'] = nil
default['owncloud']['mysql']['version'] = nil
default['owncloud']['mysql']['server_root_password'] = nil
42 changes: 28 additions & 14 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -356,22 +356,36 @@
type: 'string',
required: 'optional'
attribute 'owncloud/databse/rootpassword',
display_name: 'Database Root Password',
description: 'Database admin password to access a database instance',
calculated: true,
type: 'string',
required: 'optional'
attribute 'owncloud/database/instance',
attribute 'owncloud/mysql/instance',
display_name: 'MySQL database instance name',
description:
'MySQL database instance name to run by the mysql_service lwrp '\
'from the mysql cookbook',
'from the mysql cookbook.',
type: 'string',
required: 'optional',
default: 'default'
attribute 'owncloud/database/data_dir',
display_name: 'MySQL server data dir',
description: 'MySQL data files path.',
type: 'string',
required: 'optional',
calculated: true
attribute 'owncloud/database/run_group',
display_name: 'MySQL run group',
description: 'MySQL system group.',
type: 'string',
required: 'optional',
calculated: true
attribute 'owncloud/database/run_user',
display_name: 'MySQL run user',
description: 'MySQL system user.',
type: 'string',
required: 'optional',
calculated: true
attribute 'owncloud/database/version',
display_name: 'MySQL server version',
description:
Expand All @@ -381,9 +395,9 @@
required: 'optional',
default: 'nil'

attribute 'owncloud/database/data_dir',
display_name: 'MySQL server data dir',
description: 'MySQL data files path',
attribute 'owncloud/mysql/server_root_password',
display_name: 'Database Root Password',
description: 'Database admin password to access a database instance.',
calculated: true,
type: 'string',
required: 'optional',
calculated: true
required: 'optional'
34 changes: 22 additions & 12 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,14 @@
node['owncloud']['config']['dbtype'] != 'sqlite'
fail 'You must set ownCloud\'s database password in chef-solo mode.'
end
if node['owncloud']['database']['rootpassword'].nil? &&
node['owncloud']['config']['dbtype'] != 'sqlite'
fail 'You must set the database admin password in chef-solo mode.'
end
if node['owncloud']['admin']['pass'].nil?
fail 'You must set ownCloud\'s admin password in chef-solo mode.'
end
else
unless node['owncloud']['config']['dbtype'] == 'sqlite'
node.set_unless['owncloud']['config']['dbpassword'] = secure_password
node.set_unless['owncloud']['database']['rootpassword'] = secure_password
node.set_unless['owncloud']['mysql']['server_root_password'] =
secure_password
end
node.set_unless['owncloud']['admin']['pass'] = secure_password
node.save
Expand Down Expand Up @@ -132,26 +129,33 @@
end
if %w(localhost 127.0.0.1).include?(node['owncloud']['config']['dbhost'])
# Install MySQL
dbinstance = node['owncloud']['database']['instance']
if Chef::Config[:solo] &&
node['owncloud']['mysql']['server_root_password'].nil?
fail 'You must set the database admin password in chef-solo mode.'
end

dbinstance = node['owncloud']['mysql']['instance']

mysql2_chef_gem dbinstance do
action :install
end

mysql_service dbinstance do
data_dir node['owncloud']['database']['data_dir']
version node['owncloud']['database']['version']
data_dir node['owncloud']['mysql']['data_dir']
initial_root_password node['owncloud']['mysql']['server_root_password']
bind_address '127.0.0.1'
port node['owncloud']['config']['dbport'].to_s
initial_root_password node['owncloud']['database']['rootpassword']
run_group node['owncloud']['mysql']['run_group']
run_user node['owncloud']['mysql']['run_user']
version node['owncloud']['mysql']['version']
action [:create, :start]
end

mysql_connection_info = {
host: '127.0.0.1',
port: node['owncloud']['config']['dbport'],
username: 'root',
password: node['owncloud']['database']['rootpassword']
password: node['owncloud']['mysql']['server_root_password']
}

mysql_database node['owncloud']['config']['dbname'] do
Expand Down Expand Up @@ -179,8 +183,14 @@

if %w(localhost 127.0.0.1).include?(node['owncloud']['config']['dbhost'])
# Install PostgreSQL
node.set_unless['postgresql']['password']['postgres'] =
node['owncloud']['database']['rootpassword']
if node['postgresql']['password']['postgres'].nil? && Chef::Config[:solo]
fail 'You must set node["postgresql"]["password"]["postgres"] in '\
'chef-solo mode.'
elsif node['postgresql']['password']['postgres'].nil? &&
!Chef::Config[:solo]
node.set['postgresql']['password']['postgres'] = secure_password
node.save
end

include_recipe 'postgresql::server'
include_recipe 'database::postgresql'
Expand Down
3 changes: 3 additions & 0 deletions test/cookbooks/owncloud_test/recipes/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@
source 'emailtest.php.erb'
mode 00644
end

# Required for integration tests:
include_recipe 'nokogiri'
2 changes: 1 addition & 1 deletion test/cookbooks/owncloud_test/recipes/mysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# limitations under the License.
#

node.default['owncloud']['database']['rootpassword'] = 'vagrant_root'
node.default['owncloud']['mysql']['server_root_password'] = 'vagrant_root'
node.default['owncloud']['config']['dbpassword'] = 'database_pass'

include_recipe 'owncloud_test::common'
6 changes: 1 addition & 5 deletions test/cookbooks/owncloud_test/recipes/nginx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,4 @@

node.default['owncloud']['web_server'] = 'nginx'

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

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

include_recipe 'owncloud_test::common'
include_recipe 'owncloud_test::mysql'
5 changes: 1 addition & 4 deletions test/cookbooks/owncloud_test/recipes/postgresql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,11 @@
include_recipe 'locale'
end

node.default['owncloud']['database']['rootpassword'] = 'vagrant_postgres'
node.default['postgresql']['password']['postgres'] = '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'
Loading

0 comments on commit 778211d

Please sign in to comment.