Skip to content

avsh/owncloud-cookbook

 
 

Repository files navigation

Description

Cookbook Version

Installs and configures ownCloud, an open source personal cloud for data and file sync, share and view.

Requirements

Platform:

  • CentOS
  • Debian
  • Ubuntu

Cookbooks:

  • apache2
  • apt
  • database
  • mysql
  • nginx
  • openssl
  • php
  • php-fpm
  • postfix
  • postgresql

Attributes

Attribute Description Default
node['owncloud']['version'] Version of ownCloud to install "latest"
node['owncloud']['download_url'] Url from where ownCloud will be downloaded calculated
node['owncloud']['deploy_from_git'] Whether ownCloud should be deployed from the git repository false
node['owncloud']['git_repo'] Url of the ownCloud git repository "https://github.com/owncloud/core.git"
node['owncloud']['git_ref'] Git reference to deploy nil
node['owncloud']['www_dir'] Root directory defined in Apache where web documents are stored calculated
node['owncloud']['dir'] Directory where ownCloud will be installed calculated
node['owncloud']['data_dir'] Directory where ownCloud data will be stored calculated
node['owncloud']['server_name'] Sets the server name for the ownCloud virtual host calculated
node['owncloud']['server_aliases'] Sets the server name aliases for the ownCloud virtual host []
node['owncloud']['install_postfix'] Whether to install Postfix when a local MTA is needed true
node['owncloud']['web_server'] Web server to use: "apache" or "nginx" "apache"
node['owncloud']['php-fpm']['pool'] PHP-FPM pool name to use with ownCloud. "owncloud"
node['owncloud']['max_upload_size'] Maximum allowed size for uploaded files. "512M"
node['owncloud']['sendfile'] Whether to enable Sendfile on web server. You should set to false if you use NFS or SMB mounts. calculated
node['owncloud']['ssl'] Whether ownCloud should accept requests through SSL true
node['owncloud']['ssl_key']['source'] Source type to get the SSL key from. Can be self-signed, attribute, data-bag, chef-vault or file "self-signed"
node['owncloud']['ssl_key']['bag'] Name of the Data Bag where the SSL key is stored nil
node['owncloud']['ssl_key']['item'] Name of the Data Bag Item where the SSL key is stored nil
node['owncloud']['ssl_key']['item_key'] Key of the Data Bag Item where the SSL key is stored nil
node['owncloud']['ssl_key']['encrypted'] Whether the Data Bag where the SSL key is stored is encrypted false
node['owncloud']['ssl_key']['secret_file'] Secret file used to decrypt the Data Bag where the SSL key is stored nil
node['owncloud']['ssl_key']['path'] Path to the file where the SSL key is stored nil
node['owncloud']['ssl_key']['content'] String containing the raw SSL key nil
node['owncloud']['ssl_cert']['source'] Source type to get the SSL cert from. Can be self-signed, attribute, data-bag, chef-vault or file "self-signed"
node['owncloud']['ssl_cert']['bag'] Name of the Data Bag where the SSL cert is stored nil
node['owncloud']['ssl_cert']['item'] Name of the Data Bag Item where the SSL cert is stored nil
node['owncloud']['ssl_cert']['item_key'] Key of the Data Bag Item where the SSL cert is stored nil
node['owncloud']['ssl_cert']['encrypted'] Whether the Data Bag where the SSL cert is stored is encrypted false
node['owncloud']['ssl_cert']['secret_file'] Secret file used to decrypt the Data Bag where the SSL cert is stored nil
node['owncloud']['ssl_cert']['path'] Path to the file where the SSL cert is stored nil
node['owncloud']['ssl_cert']['content'] String containing the raw SSL cert nil
node['owncloud']['admin']['user'] Administrator username "admin"
node['owncloud']['admin']['pass'] Administrator password calculated
node['owncloud']['config']['dbtype'] Type of database, can be sqlite, mysql or pgsql "mysql"
node['owncloud']['config']['dbname'] Name of the ownCloud database "owncloud"
node['owncloud']['config']['dbuser'] User to access the ownCloud database "owncloud"
node['owncloud']['config']['dbpassword'] Password to access the ownCloud database calculated
node['owncloud']['config']['dbhost'] Host running the ownCloud database "localhost"
node['owncloud']['config']['dbtableprefix'] Prefix for the ownCloud tables in the database ""
node['owncloud']['config']['mail_smtpmode'] Mode to use for sending mail, can be sendmail, smtp, qmail or php "sendmail"
node['owncloud']['config']['mail_smtphost'] Host to use for sending mail, depends on mail_smtpmode if this is used "127.0.0.1"
node['owncloud']['config']['mail_smtpport'] Port to use for sending mail, depends on mail_smtpmode if this is used 25
node['owncloud']['config']['mail_smtptimeout'] SMTP server timeout in seconds for sending mail, depends on mail_smtpmode if this is used 10
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'] Whether authentication is needed to send mail, depends on mail_smtpmode if this is used false
node['owncloud']['config']['mail_smtpauthtype'] authentication type needed to send mail, depends on mail_smtpmode if this is used. Can be LOGIN, PLAIN or NTLM "LOGIN"
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'] Whether to enable ownCloud cron true
node['owncloud']['cron']['min'] Minute to run ownCloud cron at "*/15"
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'] Whether to skip settings the permissions of the ownCloud directory. Set this to true when using NFS synced folders. false

Recipes

owncloud::default

Installs and configures ownCloud.

Usage

Add recipe[owncloud] to your node's run list or role, or include it in another cookbook.

The back-end database will be MySQL by default, but PostgreSQL and SQLite databases can aslo be used. Database type can be set on node['owncloud']['config']['dbtype'], supported values are mysql, pgsql and sqlite.

On the first run, several passwords will be automatically generated and stored in the node:

  • node['owncloud']['admin']['pass']
  • node['owncloud']['config']['dbpassword'] (Only when using MySQL or PostgreSQL)
  • node['mysql']['server_root_password'] (Only when using MySQL)
  • node['mysql']['server_repl_password'] (Only when using MySQL)
  • node['mysql']['server_debian_password'] (Only when using MySQL)
  • node['postgresql']['password']['postgres'] (Only when using PosgreSQL)

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

The attribute node['owncloud']['server_name'] should be set to the domain name used by the ownCloud installation. If not set, node['fqdn'] will be used instead.

By default ownCloud cookbook relies on a local Postfix installation to send emails. But a remote SMTP server can be used changing node['owncloud']['config']['mail_smtpmode'] to smtp and setting up the rest of the mail configuration attributes (see example below).

Examples

Basic owncloud role

name "owncloud"
description "Install ownCloud"
default_attributes(
  "owncloud" => {
    "server_name" => "cloud.mysite.com"
  }
)
run_list(
  "recipe[owncloud]"
)

Using remote SMTP server

In this example an Amazon Simple Email Service account is used to send emails.

name "owncloud_ses"
description "Install ownCloud and use an AWS SES account to send emails"
default_attributes(
  "owncloud" => {
    "server_name" => "cloud.mysite.com",
    "config" => {
      "mail_smtpmode" => "smtp",
      "mail_smtphost" => "email-smtp.us-east-1.amazonaws.com",
      "mail_smtpport" => 465,
      "mail_smtpsecure" => "tls",
      "mail_smtpauth" => true,
      "mail_smtpauthtype" => "LOGIN",
      "mail_smtpname" => "amazon-ses-username",
      "mail_smtppassword" => "amazon-ses-password",
    }
  }
)
run_list(
  "recipe[owncloud]"
)

Deploying from Git

The ownCloud code can be deployed from the Git repository. Git recipe must be included on the run_list.

name "owncloud_git"
description "Install ownCloud from Git"
default_attributes(
  "owncloud" => {
    "server_name" => "cloud.mysite.com",
    "deploy_from_git" => true,
    "git_ref" => "master"
  }
)
run_list(
  "recipe[git::default]",
  "recipe[owncloud]"
)

Custom SSL Certificate

OwnCloud will accept SSL requests when node['owncloud']['ssl'] is set to true. By default the cookbook will create a self-signed certificate, but a custom one can also be used.

The custom certificate can be read from several sources:

  • Attribute
  • Data Bag
  • Encrypted Data Bag
  • Chef Vault
  • File

Custom SSL certificate from an Attribute

name "owncloud_ssl_attribute"
description "Install ownCloud with a custom SSL certificate from an Attribute"
default_attributes(
  "owncloud" => {
    "server_name" => "cloud.mysite.com",
    "ssl" => true,
    "ssl_key" => {
      "source" => "attribute",
      "content" => "-----BEGIN PRIVATE KEY-----[...]"
    },
    "ssl_cert" => {
      "source" => "attribute",
      "content" => "-----BEGIN CERTIFICATE-----[...]"
    }
  }
)
run_list(
  "recipe[owncloud]"
)

Custom SSL certificate from a Data Bag

name "owncloud_ssl_data_bag"
description "Install ownCloud with a custom SSL certificate from a Data Bag"
default_attributes(
  "owncloud" => {
    "server_name" => "cloud.mysite.com",
    "ssl" => true,
    "ssl_key" => {
      "source" => "data-bag",
      "bag" => "ssl",
      "item" => "key",
      "item_key" => "content",
      "encrypted" => true,
      "secret_file" => "/path/to/secret/file" # optional
    },
    "ssl_cert" => {
      "source" => "data-bag",
      "bag" => "ssl",
      "item" => "cert",
      "item_key" => "content",
      "encrypted" => false
    }
  }
)
run_list(
  "recipe[owncloud]"
)

Custom SSL certificate from Chef Vault

name "owncloud_ssl_chef_vault"
description "Install ownCloud with a custom SSL certificate from Chef Vault"
default_attributes(
  "owncloud" => {
    "server_name" => "cloud.mysite.com",
    "ssl" => true,
    "ssl_key" => {
      "source" => "chef-vault",
      "bag" => "owncloud",
      "item" => "ssl",
      "item_key" => "key"
    },
    "ssl_cert" => {
      "source" => "chef-vault",
      "bag" => "owncloud",
      "item" => "ssl",
      "item_key" => "cert"
    }
  }
)
run_list(
  "recipe[owncloud]"
)

Custom SSL certificate from file

This is usefull if you create the certificate on another cookbook.

name "owncloud_ssl_file"
description "Install ownCloud with a custom SSL certificate from file"
default_attributes(
  "owncloud" => {
    "server_name" => "cloud.mysite.com",
    "ssl" => true,
    "ssl_key" => {
      "source" => "file",
      "path" => "/path/to/ssl/key"
    },
    "ssl_cert" => {
      "source" => "file",
      "path" => "/path/to/ssl/cert"
    }
  }
)
run_list(
  "recipe[owncloud]"
)

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.

Testing

Requirements

You must have VirtualBox(https://www.virtualbox.org/) and Vagrant(http://www.vagrantup.com/) installed.

Install gem dependencies with bundler:

$ gem install bundler
$ bundle install

Running the tests

$ bundle exec kitchen test

Running the tests in the cloud

You can run the tests in the cloud instead of using vagrant. First, you must set the following environment variables:

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • AWS_KEYPAIR_NAME: EC2 SSH public key name. This is the name used in Amazon EC2 Console's Key Pairs section.
  • EC2_SSH_KEY_PATH: EC2 SSH private key local full path. Only when you are not using an SSH Agent.
  • DIGITAL_OCEAN_CLIENT_ID
  • DIGITAL_OCEAN_API_KEY
  • DIGITAL_OCEAN_SSH_KEY_IDS: DigitalOcean SSH numeric key IDs.
  • DIGITAL_OCEAN_SSH_KEY_PATH: DigitalOcean SSH private key local full path. Only when you are not using an SSH Agent.

Then, you must configure test-kitchen to use .kitchen.cloud.yml configuration file:

$ export KITCHEN_LOCAL_YAML=".kitchen.cloud.yml"
$ bundle exec kitchen test

Contributing

  1. Fork the repository on Github
  2. Create a named feature branch (like add_component_x)
  3. Write you change
  4. Write tests for your change (if applicable)
  5. Run the tests, ensuring they all pass
  6. Submit a Pull Request using Github

License and Author

Author: Raúl Rodríguez (raul@onddo.com)
Author: Xabier de Zuazo (xabier@onddo.com)
Contributor: @laradji
Contributor: @cvl-skubriev
Copyright: Copyright (c) 2013 Onddo Labs, SL. (www.onddo.com)
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.

About

Chef cookbook to install and configure ownCloud.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 84.9%
  • HTML 8.9%
  • Shell 6.2%