diff --git a/.kitchen.yml b/.kitchen.yml index 9171e8f..fbf70d4 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -4,37 +4,42 @@ driver: provisioner: name: chef_zero - require_chef_omnibus: latest + require_chef_omnibus: 12.9.41 platforms: - name: debian-7.8 - - - name: ubuntu-12.04 run_list: - recipe[apt] - - name: ubuntu-14.04 run_list: - recipe[apt] - - name: centos-6.7 + run_list: + - recipe[yum-epel] + - name: centos-7.2 + run_list: + - recipe[yum-epel] - - name: centos-7.0 - -data_bags_path: test/integration/data_bags/ -roles_path: test/integration/roles/ -environments_path: test/integration/environments +roles_path: test/integration/roles/ suites: - - name: aio-server - run_list: - - role[bareos_server] - attributes: - - - name: aio-server-pools + - name: bareos-aio-server run_list: - - role[bareos_server] + - role[bareos_director] attributes: bareos: - host_pools: true - custom_host_pools: true + test_mode: true + director: + conf: + help: + test: '# Some String' + config_change_notify: 'reload' + server: + jobs: + unmanaged-host-job: + Description: '"Unmanaged Host Test Job"' + Client: 'unmanaged-client-fd' + JobDefs: 'default-def' + Type: 'Backup' + storage: + autochanger_enabled: true diff --git a/test/integration/aio-server-pools/serverspec/.rspec b/.rspec similarity index 100% rename from test/integration/aio-server-pools/serverspec/.rspec rename to .rspec diff --git a/.rubocop.yml b/.rubocop.yml index 9258859..ad89575 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -14,7 +14,7 @@ MethodLength: Max: 30 NumericLiterals: Enabled: false -SingleSpaceBeforeFirstArg: +SpaceBeforeFirstArg: + Enabled: false +FileName: Enabled: false -Metrics/LineLength: - Max: 180 diff --git a/.tailor b/.tailor deleted file mode 100644 index 75f326a..0000000 --- a/.tailor +++ /dev/null @@ -1,138 +0,0 @@ -#------------------------------------------------------------------------------ -# Horizontal Whitespace -#------------------------------------------------------------------------------ -# allow_hard_tabs True to let hard tabs be considered a single space. -# Default: false -# -# allow_trailing_line_spaces -# True to skip detecting extra spaces at the ends of -# lines. -# Default: false -# -# indentation_spaces The number of spaces to consider a proper indent. -# Default: 2 -# -# Option: line_continuations -# Indicates that a statement that spans multiple lines -# should indent the second and subsequent lines. Ex.: -# style.indentation_spaces 2, level: :error, line_continuations: true -# -# Option: argument_align -# Allowing you to specify that method declarations and -# calls should indent to the first argument on -# subsequent lines. Ex.: -# style.indentation_spaces 2, level: :error, argument_alignment: true -# -# max_line_length The maximum number of characters in a line before -# tailor complains. -# Default: 80 -# spaces_after_comma Number of spaces to expect after a comma. -# Default: 1 -# -# spaces_before_comma Number of spaces to expect before a comma. -# Default: 0 -# -# spaces_after_lbrace The number of spaces to expect after an lbrace ('{'). -# Default: 1 -# -# spaces_before_lbrace The number of spaces to expect before an lbrace ('{'). -# Default: 1 -# -# spaces_before_rbrace The number of spaces to expect before an rbrace ('}'). -# Default: 1 -# -# spaces_in_empty_braces The number of spaces to expect between braces when -# there's nothing in the braces (i.e. {}). -# Default: 0 -# -# spaces_after_lbracket The number of spaces to expect after an -# lbracket ('['). -# Default: 0 -# -# spaces_before_rbracket The number of spaces to expect before an -# rbracket (']'). -# Default: 0 -# -# spaces_after_lparen The number of spaces to expect after an -# lparen ('('). -# Default: 0 -# -# spaces_before_rparen The number of spaces to expect before an -# rbracket (')'). -# Default: 0 -# -#------------------------------------------------------------------------------ -# Naming -#------------------------------------------------------------------------------ -# allow_camel_case_methods -# Setting to true skips detection of camel-case method -# names (i.e. def myMethod). -# Default: false -# -# allow_screaming_snake_case_classes -# Setting to true skips detection of screaming -# snake-case class names (i.e. My_Class). -# Default: false -# -#------------------------------------------------------------------------------ -# Vertical Whitespace -#------------------------------------------------------------------------------ -# max_code_lines_in_class The number of lines of code in a class to allow before -# tailor will warn you. -# Default: 300 -# -# max_code_lines_in_method -# The number of lines of code in a method to allow -# before tailor will warn you. -# Default: 30 -# -# trailing_newlines The number of newlines that should be at the end of -# the file. -# Default: 1 -# -#------------------------------------------------------------------------------ -# Common Syntax -#------------------------------------------------------------------------------ -# allow_conditional_parentheses -# Checks to see if a conditional is unnecessarily -# wrapped in parentheses. -# Default: true -# -# allow_unnecessary_double_quotes -# Checks for use of double-quotes when no interpolation -# is used. -# Default: false -# -# allow_unnecessary_interpolation -# Checks for unnecessary interpolation in strings. -# Default: false -# -Tailor.config do |config| - config.formatters "text" - config.file_set '**/*.rb' do |style| - style.allow_camel_case_methods false, level: :error - style.allow_conditional_parentheses false, level: :warn - style.allow_hard_tabs false, level: :error - style.allow_screaming_snake_case_classes false, level: :error - style.allow_trailing_line_spaces false, level: :error - style.allow_unnecessary_interpolation false, level: :warn - style.allow_unnecessary_double_quotes false, level: :warn - style.allow_invalid_ruby false, level: :warn - style.indentation_spaces 2, level: :error - style.max_code_lines_in_class 300, level: :error - style.max_code_lines_in_method 30, level: :error - style.max_line_length 135, level: :error - style.spaces_after_comma 1, level: :error - style.spaces_after_conditional 1, level: :error - style.spaces_after_lbrace 1, level: :error - style.spaces_after_lbracket 0, level: :error - style.spaces_after_lparen 0, level: :error - style.spaces_before_comma 0, level: :error - style.spaces_before_lbrace 1, level: :error - style.spaces_before_rbrace 1, level: :error - style.spaces_before_rbracket 0, level: :error - style.spaces_before_rparen 0, level: :error - style.spaces_in_empty_braces 0, level: :error - style.trailing_newlines 1, level: :error - end -end diff --git a/.travis.yml b/.travis.yml index d75923d..3435915 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,12 @@ language: ruby rvm: - - 2.0.0 - - 2.1.5 - - 2.2.0 + - 2.1.9 + - 2.2.5 + - 2.3.1 script: - - bundle exec rspec --color --format progress - - bundle exec foodcritic -f any --tags ~FC003 --tags ~FC015 --tags ~FC023 . + - bundle exec rspec --default-path spec + - bundle exec foodcritic -f any . - bundle exec rubocop notifications: diff --git a/CHANGELOG.md b/CHANGELOG.md index 914eaea..1f58c95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,54 @@ -Bareos Cookbook CHANGELOG -========================== +CHANGELOG +========= +Chef-Bareos Cookbook +-------------------- -This file is used to list changes made in each version of the bareos cookbook. +3.0.2 +----- +- Ian Smith + + - Complete re-work of cookbook, which includes the rework bits from version 2.0 + - Adding various features including: + * Templates populated from hash tables + * Up to date README + * Graphite plugin deployment recipe + * Migrate to postgresql cookbook version 4+ + * Better testing (rspec), testing against current ruby, need some more rspec tests but no time + * Various other updates and enhancements, see README for details + * Supermarket Release...finally + - ***NOTE*** This release adds functionality that is not backwards compatible. Version lock until you have time to test the migration to version 3.0+ + +2.2.13 +------ +- Ian Smith + + - Near complete refactoring of how the cookbook works + * Adding various ways to add configs based on hashes. Examples in attributes/default.rb + - Updating README for usage details + - If you are not prepared to use this cookbook version, please lock cookbook version to < 2.0.0 + - TODO: Refactor main bareos-dir/sd/fd configs to be fully based on hashes like other configs + * Remaining attributes support primary bareos-dir/sd/fd configs mostly, used elsewhere but not much + +1.0.4 +----- +- Ian Smith + + - Updating and validating Kitchen testing with new methods + - Adding ability to use custom Storage Daemon Configs via wrapper recipe + - Fixed a race condition that was likely to come up both in testing and production + * Was missing client config on fresh install so restart of dir would fail + - Limiting cookbook support for debian to ~>7.0 until we can test on 8+ + - Refined storage recipe to correctly create client configs based on BOTH role search and solo instances, may need a bit more tuning but should work in most cases + - Creating basic Full, Inc, and Diff pools even if not used, just as a place holder (default) + - Minor fixes + - Larger version bump for version clarity + - Updated Docs + - Adding support for Fedora and RHEL 6/7 + - Reworked the available repos to some better logic 0.1.4 ----- -- Ian smith +- Ian Smith - Updating README - Revamping server.rb recipe to better utilize the bareos-dir.d directory @@ -22,7 +65,7 @@ This file is used to list changes made in each version of the bareos cookbook. 0.1.3 ----- -- Ian smith +- Ian Smith - Updating README - Updating CHANGELOG @@ -30,7 +73,7 @@ This file is used to list changes made in each version of the bareos cookbook. 0.1.2 ----- -- Léonard TAVAE +- Leonard TAVAE - The License has changed (Apache 2.0) - The cookbook now passed foodcritic, rubocop and tailor with success @@ -50,10 +93,10 @@ This file is used to list changes made in each version of the bareos cookbook. 0.1.1 ----- -- Léonard TAVAE - Major release +- Leonard TAVAE - Major release 0.1.0 ----- -- Léonard TAVAE - Initial release of bareos +- Leonard TAVAE - Initial release of bareos - - - diff --git a/Gemfile b/Gemfile index 35a481d..a57eeda 100644 --- a/Gemfile +++ b/Gemfile @@ -1,21 +1,10 @@ source 'https://rubygems.org' gem 'berkshelf' - -# Uncomment these lines if you want to live on the Edge: -# -# group :development do -# gem "berkshelf", github: "berkshelf/berkshelf" -# gem "vagrant", github: "mitchellh/vagrant", tag: "v1.6.3" -# end -# -# group :plugins do -# gem "vagrant-berkshelf", github: "berkshelf/vagrant-berkshelf" -# gem "vagrant-omnibus", github: "schisamo/vagrant-omnibus" -# end - gem 'test-kitchen' gem 'kitchen-vagrant' gem 'rubocop' gem 'foodcritic' -gem 'rspec' +gem 'chefspec' +gem 'rspec', '>= 3.4' +gem 'rake' diff --git a/LICENSE b/LICENSE index 2747fa8..93f28f3 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright 2014 Léonard TAVAE +Copyright (C) 2016 Leonard TAVAE Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -10,4 +10,4 @@ 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. \ No newline at end of file +limitations under the License. diff --git a/README.md b/README.md index e03fe83..a715124 100644 --- a/README.md +++ b/README.md @@ -1,77 +1,190 @@ Chef-Bareos Cookbook ==================== -[![Build Status](https://travis-ci.org/sitle/chef-bareos.svg?branch=master)](https://travis-ci.org/sitle/chef-bareos) - -This cookbook installs and configures backups based on [Bareos](https://www.bareos.org/en/). - -# Requirements - -This cookbook has been tested with RHEL, Debian, Ubuntu systems. It should work with Chef 11 and Chef 12 configurations, if not please file a bug report and it will be addressed. The chef-bareos cookbook is still undergoing some feature additions so it is recommended to watch for changes to the README. - -# Attributes - -## Database - -Attribute | Description |Type | Default ------------------|-------------|-----|-------- -["bareos"]["database_type"] | Specify the database type | string | 'postgresql' -["bareos"]["dbdriver"] | Specify the database driver | string | 'postgresql' -["bareos"]["dbname"] | Specify the database default name | string | 'bareos' -["bareos"]["dbuser"] | Specify the db user name | string | 'bareos' -["bareos"]["dbpassword"] | Specify the db password | string | '' -["bareos"]["dbaddress"] | Specify the db address | string | - -## General - -Attribute | Description |Type | Default ------------------|-------------|-----|-------- -['bareos']['url'] | Base URL for Bareos Repository | string | 'http://download.bareos.org/bareos/release' -['bareos']['version'] | Software Version | string | 'latest' - -## Storage Daemon -Attribute | Description |Type | Default ------------------|-------------|-----|-------- -['bareos']['tape'] | Enable Tape Features | boolean | false - -## Clients/Hosts - -Attribute | Description |Type | Default ------------------|-------------|-----|-------- -['bareos']['clients'] | Monitor Clients | array | [] -['bareos']['enable_vfulls'] | Activate basic Virtual Full Backups | boolean | false -['bareos']['host_pools'] | Seperate Host Pools | boolean | false -['bareos']['custom_host_pools'] | Custom Host Pools | boolean | nil -['bareos']['host_full_pool'] | Custom Full Pool | string | 'test-pool-Full' -['bareos']['host_incremental_pool'] | Custom Incremental Pool | string | 'test-pool-Inc' -['bareos']['host_differential_pool'] | Custom Differential Pool | string | 'test-pool-Diff' - -## Director - -Attribute | Description |Type | Default ------------------|-------------|-----|-------- -['bareos']['dir_port'] | Network Port for Director | number | 9101 -['bareos']['dir_max_concurrent_jobs'] | Max concurrent jobs for director | number | 20 - -## Subscription Management (Director) - -Attribute | Description |Type | Default ------------------|-------------|-----|-------- -['bareos']['dir_subscription'] | Support Subscription Status | boolean | nil/False -['bareos']['dir_subs'] | Subscription Level/Count | number | nil - -# Basic Usage - -## Roles - -### bareos_base role (install the bareos client backup by default) - -You need to create a base role called ``bareos_base`` like this: +[![BuildStatus](https://travis-ci.org/sitle/chef-bareos.svg?branch=master)](https://travis-ci.org/sitle/chef-bareos) +[![Join the chat at https://gitter.im/EMSL-MSC/chef-bareos](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/EMSL-MSC/chef-bareos?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + +This cookbook installs and configures backups based on [BAREOS](https://www.bareos.org/en/). + +[Official BAREOS Documentation](http://doc.bareos.org/master/html/bareos-manual-main-reference.html). + +## Supported Platforms: + * Ubuntu 14.04 (plan to add 16.04 as soon as binary is released) + * Debian 7 (8+ may or may not work, you'll need a repo basically) + * CentOS 6+ + * RHEL 6+ (Assumed to work just as well as on CentOS) + +## Supported Chef Versions: + + * Chef 11+ + +## Important Notable Attributes + +### Repository +Assists with adding necessary sources for installing Bareos + +| Attribute | Default Value | Description +|------------------|---------------|------------ +| ['bareos']['url'] | 'http://download.bareos.org/bareos/release' | Main installation URL +| ['bareos']['contrib_url'] | 'http://download.bareos.org/bareos/contrib' | Main contrib installation URL +| ['bareos']['version'] | '15.2' | Default Bareos Version + +For other platform specific attributes please see default attributes file for more detail. + +### Messages +Defines default admin e-mail address for service notifications and what messages to care about + +| Attribute | Default Value | Description +|------------------|---------------|------------ +| ['bareos']['messages']['mail_to'] | "bareos@#{node['domain']}" | Default messages e-mail destination +| ['bareos']['messages']['default_messages'] | 'Standard' | Default client message capture level +| ['bareos']['messages']['default_admin_messages'] | 'all, !skipped, !restored' | Default server message capture level +### Database +Populates the Catalog resource in the main Director configuration + +| Attribute | Default Value | Description +|------------------|---------------|------------ +| ['bareos']['database']['catalog_name'] | 'MyCatalog' | Default catalog name +| ['bareos']['database']['database_type'] | 'postgresql' | Default database installment indicator +| ['bareos']['database']['dbdriver'] | 'postgresql' | Config entry for type of database +| ['bareos']['database']['dbname'] | 'bareos' | Default database name +| ['bareos']['database']['dbuser'] | 'bareos' | Default database user +| ['bareos']['database']['dbpassword'] | *blank string* | Default gets generated by postgresql cookbook, unless specified here +| ['bareos']['database']['dbaddress'] | nil | This is often just the localhost, so this is only needed in certain cases + +### Clients +Provides resources for the Catalog (Director configuration) and Filedaemon configurations/templates + +| Attribute | Default Value | Description +|------------------|---------------|------------ +| ['bareos']['clients']['name'] | node['fqdn'] | Uses the node FQDN by default as prefix for filedaemon name +| ['bareos']['clients']['net_name'] | node['fqdn'] | DNS Network name used to resolve client +| ['bareos']['clients']['fd_port'] | 9102 | Default filedaemon port +| ['bareos']['clients']['max_concurrent_jobs'] | 20 | Default number of concurrent jobs +| ['bareos']['clients']['heartbeat_interval'] | 600 | Proven a useful default value, change as needed +| ['bareos']['clients']['client_search_query'] | 'roles:bareos_client' | Default search query to find Bareos clients +| ['bareos']['clients']['client_list'] | %w(node) | Useful if you need a list of hosts if running in solo mode +| ['bareos']['clients']['bootstrap_file'] | '/var/lib/bareos/%c.bsr' | Default bootstrap file structure/location +| ['bareos']['clients']['jobdef_default_messages'] | 'Standard' | Default value for setting the message level in a job definition to override the messages section +| ['bareos']['clients']['jobdef_default_fileset'] | "#{node['fqdn']}-Fileset" | Default naming convention for filesets +| ['bareos']['clients']['storage'] | 'File' | Default storage for new clients when added via search + +### Storage Daemon +Provides for a baseline Storage Daemon Config with configurable options + +| Attribute | Default Value | Description +|------------------|---------------|------------ +| default['bareos']['storage']['name'] | node['fqdn'] | Uses FQDN for naming storages found via search +| default['bareos']['storage']['storage_search_query'] | 'roles:bareos_storage' | Default search query string for finding storage servers +| default['bareos']['storage']['sd_port'] | 9103 | Default Storage communication port +| default['bareos']['storage']['servers'] | %w(node) | List of storage servers you can use if using solo mode +| default['bareos']['storage']['max_concurrent_jobs'] | 20 | Default max number of concurrent storage daemon jobs +| default['bareos']['storage']['autochanger_enabled'] | false | Used to control autochanger support + +### Director +Provides standard variables for a typical Director configuration + +| Attribute | Default Value | Description +|------------------|---------------|------------ +| default['bareos']['director']['name'] | node['fqdn'] | Uses FQDN for director naming +| default['bareos']['director']['net_name'] | node['fqdn'] | Uses FQDN for DNS resolution +| default['bareos']['director']['dir_search_query'] | 'roles:bareos_director' | Default search string to find bareos directors +| default['bareos']['director']['dir_port'] | 9101 | Default director communication port +| default['bareos']['director']['dir_max_concurrent_jobs'] | 20 | Default max allowable jobs running +| default['bareos']['director']['servers'] | %w(node) | List of directors if running in solo mode +| default['bareos']['director']['console_commandacl'] | 'status, .status' | Default ACL for console commands +| default['bareos']['director']['heartbeat_interval'] | 600 | Proven useful as a default network timeout for communication to director +| default['bareos']['director']['catalog_jobdef'] | 'default-catalog-def' | Default name for the Catalog Backup Jobdef name +| default['bareos']['director']['conf']['help']['Example Block'] | '# You can put extra configs here.' | Area where you can add any number of possible things to expand your configs +| default['bareos']['director']['config_change_notify'] | 'restart' | Default action when director config changes (restart/reload) + +### Subscription Management (Director) +Provides a system counter method if you have a paid service subscription + +| Attribute | Default Value | Description +|------------------|---------------|------------ +| ['bareos']['director']['dir_subscription'] | nil | Required if you have a support contract/licensed installation (activates if not nil) +| ['bareos']['director']['dir_subs'] | nil | Max number of subs you have signed up for + +### Workstation +Determines if you want to use FQDN or some other way of defining hosts in your management workstation deployment + +| Attribute | Default Value | Description +|------------------|---------------|------------ +| ['bareos']['workstation']['name'] | node['fqdn'] | Used to determine header information for bconsole/bat configs + +### Graphite Plugin +A new plugin that will send statistics to a graphite server which can then be used in various ways. + +| Attribute | Default Value | Description +|------------------|---------------|------------ +| ['bareos']['plugins']['graphite']['packages'] | varies on platform | Default packages needed to get the plugin to work +| ['bareos']['plugins']['graphite']['plugin_path'] | '/usr/sbin' | Default location for the plugin that runs in a defined cron job +| ['bareos']['plugins']['graphite']['config_path'] | '/etc/bareos' | Default directory for the plugin config +| ['bareos']['plugins']['graphite']['search_query'] | 'roles:bareos_director' | Default search string to populate the director name +| ['bareos']['plugins']['graphite']['server'] | 'graphite' | Placeholder string for the graphite server DNS name +| ['bareos']['plugins']['graphite']['graphite_port'] | '2003' | Default graphite communication port +| ['bareos']['plugins']['graphite']['graphite_data_prefix'] | 'bareos.' | Default prefix for graphite data +| ['bareos']['plugins']['graphite']['graphite_plugin_src_url'] | 'https://raw.githubusercontent.com/bareos/bareos-contrib/master/misc/performance/graphite/bareos-graphite-poller.py' | Default URL to the plugin + +## Recipes + +### default +Installs the Bareos repos (via the repo recipe) and the client filedaemon (via the client recipe). Please NOTE, although it will install these parts, the director will not pick up on the client unless you (by default) create and attach a bareos_client role to hosts you wish to configure automatically. You can also add the host to the director in the unmanaged-host key value hashes. + +### client +Installs the Bareos filedaemon and creates a config file that is linked to available directors on chef server. +You may also feed directors to the config via attributes if running in solo mode. + +### repo +Installs base Bareos repo as well as the Bareos Contrib repo. + +### database +Installs whichever database is desired per attributes (PostgreSQL/MySQL), installs Bareos database packages and creates the bareos database and user for you. Should also set the database password by default. You may need to recover this from the attributes or set a new one via vault via wrapper recipe. + +### server +Installs necessary Bareos server packages and sets up base configs necessary for server to start. Also creates the config directory (bareos-dir.d) so you can drop whatever outside config files into place and have them get automatically included in your setup. + +### storage +Installs necessary Bareos storage packages and sets up a default file storage for you to start backing stuff up to right away (configured for ~250GB of volumes by default). + +### autochanger +This bit will setup an autochanger based on a pretty straight forward has table. Tested with IBM TS3500 Tape Library with 10 Frames and 16 Tape drives. + +### workstation +Installs bconsole essentially. I plan to create another recipe for bat (Bareos Administration Tool) and the Bareos Web UI but I haven't gotten around to it yet. + +### graphite_plugin +This was an exciting recent addition to the Bareos contrib GitHub repo. This addition in its current form will be dependent on a pending merge request getting accepted but if it isn't merged it can be easily worked around. Should work out of the gate here pretty soon given you adjust the graphite server string in the attributes for a graphite server location. + +## Searchable Roles (Used by default) + +### bareos\_client +This example shows how the ```bareos_client``` role can both install the Bareos client side software and when searched against via the server recipe, will add itself to the bareos-dir (Bareos director) configuration and setup a default set of jobs for a client. +``` +{ + "name": "bareos_client", + "description": "Example Role for Bareos clients using the chef-bareos Cookbook, used in searches, throws down sources for installs", + "json_class": "Chef::Role", + "default_attributes": { + }, + "override_attributes": { + }, + "chef_type": "role", + "run_list": [ + "recipe[chef-bareos]" + ], + "env_run_lists": { + } +} +``` +### bareos\_storage +This example shows a ```bareos_storage``` role which will create a Bareos storage-daemon host. It will install the necessary packages and lay down configuration files you can populate with any number of key value hash tables. You should be able to install this independent of the director(s), please file a ticket if this doesn't work as expected. ``` { - "name": "bareos_base", - "description": "Base Role for chef-bareos Cookbook, used in searches, throws down sources for installs", + "name": "bareos_storage", + "description": "Example Role for a Bareos storage", "json_class": "Chef::Role", "default_attributes": { }, @@ -79,22 +192,25 @@ You need to create a base role called ``bareos_base`` like this: }, "chef_type": "role", "run_list": [ - "recipe[bareos]" + "recipe[chef-bareos::storage]" ], "env_run_lists": { } } ``` -This role has to be applied to all your clients so they can be backed up by this cookbook. -### bareos_server role (install the bareos server for backups) +### bareos\_director +This role example will install an all-in-one Bareos director server. This includes a "first" client, bareos database, bareos storage, and deploy bconsole to interact with the director. -For the server, you need a role named ``bareos_server``, for example : +This will also allow clients to populate their filedaemon config via defined search string. +You'll need to run ```chef-client``` on the director after a client gets configured so the director can add and generate the appropriate client related configs. + +You can populate the ```['bareos']['clients']['unmanaged']``` hash table space with any number of client related configuration lines if you have hosts you either don't plan to search for or want to do custom configurations for. ``` { - "name": "bareos_server", - "description": "Bareos Server Role", + "name": "bareos_director", + "description": "Example Role for a Bareos director", "json_class": "Chef::Role", "default_attributes": { }, @@ -102,34 +218,221 @@ For the server, you need a role named ``bareos_server``, for example : }, "chef_type": "role", "run_list": [ - "role[bareos_base]", - "recipe[bareos::server]", - "recipe[bareos::database]", - "recipe[bareos::storage]", - "recipe[bareos::workstation]" + "role[bareos_client]", + "recipe[chef-bareos::database]", + "recipe[chef-bareos::server]", + "recipe[chef-bareos::workstation]" ], "env_run_lists": { } } ``` -You need to run chef-client on the backup server every time you add a new node. All job will be automatically create for you. +## Example customizable key value hash template configurations +These are the preset default hashes to get a baseline configuration on a new bareos server. You can manipulate these as you see fit via recipe logic or searches or whatever you want. These will at least get you going. +### clients +``` +# Default Client Config when populated via search +default['bareos']['clients']['conf'] = { + 'FDPort' => '9102', + 'File Retention' => '30 days', + 'Job Retention' => '6 months', + 'AutoPrune' => 'yes', + 'Maximum Concurrent Jobs' => '20' +} +``` +``` +# Example Unmanaged client if client is unmanaged or custom +default['bareos']['clients']['unmanaged']['unmanaged-client-fd'] = { + 'Address' => 'unmanaged-client', + 'Password' => 'onefbofnerwob', + 'Catalog' => 'MyCatalog', + 'FDPort' => '9102' +} +``` +#### autochanger (if using tape storage) +``` +# Example/Test Tape Autochanger Configurations +if node['bareos']['storage']['autochanger_enabled'] == true + default['bareos']['storage']['autochangers']['autochanger-0'] = { + 'Device' => [ + 'tapedrive-0', + 'tapedrive-1' + ], + 'Changer Device' => ['/dev/tape/by-id/scsi-1TANDBERGStorageLoader_SOMEAUTOCHANGER'], + 'Changer Command' => ['"/usr/lib/bareos/scripts/mtx-changer %c %o %S %a %d"'] + } + + default['bareos']['storage']['autochangers']['autochanger-1'] = { + 'Device' => [ + 'tapedrive-0' + ], + 'Changer Device' => ['/dev/tape/by-id/scsi-1TANDBERGStorageLoader_SOMEAUTOCHANGER'], + 'Changer Command' => ['"/usr/lib/bareos/scripts/mtx-changer %c %o %S %a %d"'] + } + + default['bareos']['storage']['devices']['tapedrive-0'] = { + 'DeviceType' => 'tape', + 'DriveIndex' => '0', + 'ArchiveDevice' => 'dev/nst0', + 'MediaType' => 'lto', + 'Autochanger' => 'no', + 'AutomaticMount' => 'no', + 'MaximumFileSize' => '10GB' + } + + default['bareos']['storage']['devices']['tapedrive-1'] = { + 'DeviceType' => 'tape', + 'DriveIndex' => '0', + 'ArchiveDevice' => 'dev/nst0', + 'MediaType' => 'lto', + 'Autochanger' => 'no', + 'AutomaticMount' => 'no', + 'MaximumFileSize' => '10GB' + } +``` +#### dir\_helper +``` +default['bareos']['director']['conf']['help']['Example Block'] = '# You can put extra configs here.' +``` +#### filesets +``` +# Default Filesets +default['bareos']['clients']['filesets']['default'] = { + 'options' => { + 'signature' => 'MD5' + }, + 'include' => { + 'File' => ['/', '/home'], + 'Exclude Dir Containing' => ['.bareos_ignore'] + }, + 'exclude' => { + 'File' => [ + '/var/lib/bareos', + '/var/lib/bareos/storage', + '/var/lib/pgsql', + '/var/lib/mysql', + '/proc', + 'tmp', + '/.journal', + '/.fsck', + '/spool' + ] + } +} +``` +#### job\_definitions (jobdefs) +``` +# Default Job Definitions +default['bareos']['clients']['job_definitions']['default-def'] = { + 'Level' => 'Incremental', + 'Fileset' => 'default-fileset', + 'Schedule' => 'monthly', + 'Storage' => 'default-file-storage', + 'Messages' => 'Standard', + 'Pool' => 'default-file-pool', + 'Priority' => '10', + 'Write Bootstrap' => '"/var/lib/bareos/%c.bsr"', + 'SpoolData' => 'no' +} + +default['bareos']['clients']['job_definitions']['default-catalog-def'] = { + 'Level' => 'Full', + 'Fileset' => 'Catalog', + 'Schedule' => 'WeeklyCycleAfterBackup', + 'Storage' => 'default-file-storage', + 'Messages' => 'Standard', + 'Pool' => 'default-file-pool', + 'Allow Duplicate Jobs' => 'no' +} + +default['bareos']['clients']['job_definitions']['default-restore-def'] = { + 'Fileset' => 'default-fileset', + 'Storage' => 'default-file-storage', + 'Messages' => 'Standard', + 'Pool' => 'default-file-pool', + 'Priority' => '7', + 'Where' => '/tmp/bareos-restores' +} +``` +#### jobs +Director Jobs: +``` +default['bareos']['director']['jobs'] = nil +``` +Client Jobs: +``` +# Example Jobs +default['bareos']['clients']['jobs']["#{node.default['bareos']['clients']['name']}-job"] = { + 'Client' => "#{node['bareos']['clients']['name']}-fd", + 'Type' => 'Backup', + 'JobDefs' => 'default-def' +} + +default['bareos']['clients']['jobs']["#{node.default['bareos']['clients']['name']}-restore-job"] = { + 'Client' => "#{node['bareos']['clients']['name']}-fd", + 'Type' => 'Restore', + 'JobDefs' => 'default-restore-def' +} +``` + +#### pools +``` +# Default Pools +default['bareos']['clients']['pools']['default-file-pool'] = { + 'Pool Type' => 'Backup', + 'Recycle' => 'yes', + 'Volume Retention' => '30 days', + 'Maximum Volume Bytes' => '10G', + 'Maximum Volumes' => '25', + 'LabelFormat' => 'FileVolume-' +} +``` +#### schedules +``` +# Default Schedules +default['bareos']['clients']['schedules']['monthly'] = { + 'Description' => [ + 'Default Monthly Schedule' + ], + 'Run' => [ + 'Full 1st sun at 23:05', + 'Differential 2nd-5th sun at 23:05', + 'Incremental mon-sat at 23:05' + ], + 'Enabled' => [ + 'yes' + ] +} +``` +#### sd\_helper +``` +default['bareos']['storage']['conf']['help']['Example Block'] = '# You can put extra configs here.' +``` +#### storages +``` +# Default Storages +default['bareos']['clients']['storages']['default-file-storage'] = { + 'Address' => node['bareos']['storage']['name'], # N.B. Use a fully qualified name here + 'Device' => 'FileStorage', + 'Media Type' => 'File' +} +``` # Contributing 1. Fork the repository on Github -2. Create a named feature branch (like `add_component_x`) +2. Create a named feature branch (like ```add_component_x```) 3. Write your change -4. Write tests for your change (if applicable) -5. Run the tests, ensuring they all pass -6. Submit a Pull Request using Github +4. Write kitchen and/or chefspec (rspec) tests for your change (if possible) +5. Run the tests, ensuring they all pass or travis-ci will do it for you +6. Submit a Pull Request using GitHub ## License and Authors -### License +### License -``` -Copyright 2014 Léonard TAVAE +Copyright (C) 2016 Leonard TAVAE Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -142,10 +445,9 @@ 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. -``` -### Authors +### Authors -* Léonard TAVAE +* Leonard TAVAE * Ian Smith * Gerhard Sulzberger diff --git a/Thorfile b/Thorfile deleted file mode 100644 index 19aaaf2..0000000 --- a/Thorfile +++ /dev/null @@ -1,12 +0,0 @@ -# encoding: utf-8 - -require 'bundler' -require 'bundler/setup' -require 'berkshelf/thor' - -begin - require 'kitchen/thor_tasks' - Kitchen::ThorTasks.new -rescue LoadError - puts '>>>>> Kitchen gem not loaded, omitting tasks' unless ENV['CI'] -end diff --git a/Vagrantfile b/Vagrantfile index 3cec5f1..55560bc 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -2,7 +2,7 @@ # vi: set ft=ruby : # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! -VAGRANTFILE_API_VERSION = '2' +VAGRANTFILE_API_VERSION = '2'.freeze Vagrant.require_version '>= 1.5.0' diff --git a/attributes/default.rb b/attributes/default.rb index 134aef4..a452e96 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,49 +1,291 @@ # Repository - default['bareos']['url'] = 'http://download.bareos.org/bareos/release' +default['bareos']['contrib_url'] = 'http://download.bareos.org/bareos/contrib' -# Used to have 'latest' as default, had potential update dangers -# default['bareos']['version'] = 'latest' <--- Could be dangerous, ***CAUTION*** -default['bareos']['version'] = '14.2' # <--- Latest version as of 6-26-15 +default['bareos']['version'] = '15.2' # <--- Latest Stable version as of 06-Dec-2015 -if platform_family?('rhel') - default['bareos']['yum_repository'] = 'bareos' - default['bareos']['description'] = 'Backup Archiving Recovery Open Sourced Current stable' +if platform_family?('rhel', 'fedora') + default['bareos']['repository_name'] = 'bareos' + default['bareos']['description'] = "Backup Archiving REcovery Open Sourced Current #{node['bareos']['version']}" + default['bareos']['contrib_repository_name'] = 'bareos_contrib' + default['bareos']['contrib_description'] = "Backup Archiving REcovery Open Sourced Current #{node['bareos']['version']} contrib" end -case node['platform'] -when 'ubuntu' - default['bareos']['baseurl'] = "#{node['bareos']['url']}/#{node['bareos']['version']}/xUbuntu_#{node['platform_version']}/" - default['bareos']['gpgkey'] = "#{node['bareos']['url']}/#{node['bareos']['version']}/xUbuntu_#{node['platform_version']}/Release.key" -when 'centos' - default['bareos']['baseurl'] = "#{node['bareos']['url']}/#{node['bareos']['version']}/CentOS_6/" - default['bareos']['gpgkey'] = "#{node['bareos']['url']}/#{node['bareos']['version']}/CentOS_6/repodata/repomd.xml.key" +case node['platform_family'] when 'debian' - default['bareos']['baseurl'] = "#{node['bareos']['url']}/#{node['bareos']['version']}/Debian_7.0/" - default['bareos']['gpgkey'] = "#{node['bareos']['url']}/#{node['bareos']['version']}/Debian_7.0/Release.key" + case node['platform'] + when 'debian' + default['bareos']['baseurl'] = "#{node['bareos']['url']}/#{node['bareos']['version']}/Debian_#{node['platform_version'].to_i}.0/" + default['bareos']['gpgkey'] = "#{node['bareos']['url']}/#{node['bareos']['version']}/Debian_#{node['platform_version'].to_i}.0/Release.key" + default['bareos']['contrib_baseurl'] = "#{node['bareos']['contrib_url']}/Debian_#{node['platform_version'].to_i}.0/" + default['bareos']['contrib_gpgkey'] = "#{node['bareos']['contrib_url']}/Debian_#{node['platform_version'].to_i}.0/Release.key" + when 'ubuntu' + default['bareos']['baseurl'] = "#{node['bareos']['url']}/#{node['bareos']['version']}/xUbuntu_#{node['platform_version']}/" + default['bareos']['gpgkey'] = "#{node['bareos']['url']}/#{node['bareos']['version']}/xUbuntu_#{node['platform_version']}/Release.key" + default['bareos']['contrib_baseurl'] = "#{node['bareos']['contrib_url']}/xUbuntu_#{node['platform_version']}/" + default['bareos']['contrib_gpgkey'] = "#{node['bareos']['contrib_url']}/xUbuntu_#{node['platform_version']}/Release.key" + end +when 'rhel' + case node['platform'] + when 'centos' + default['bareos']['baseurl'] = "#{node['bareos']['url']}/#{node['bareos']['version']}/CentOS_#{node['platform_version'].to_i}/" + default['bareos']['gpgkey'] = "#{node['bareos']['url']}/#{node['bareos']['version']}/CentOS_#{node['platform_version'].to_i}/repodata/repomd.xml.key" + default['bareos']['contrib_baseurl'] = "#{node['bareos']['contrib_url']}/CentOS_#{node['platform_version'].to_i}/" + default['bareos']['contrib_gpgkey'] = "#{node['bareos']['contrib_url']}/CentOS_#{node['platform_version'].to_i}/repodata/repomd.xml.key" + when 'scientific' + default['bareos']['baseurl'] = "#{node['bareos']['url']}/#{node['bareos']['version']}/CentOS_#{node['platform_version'].to_i}/" + default['bareos']['gpgkey'] = "#{node['bareos']['url']}/#{node['bareos']['version']}/CentOS_#{node['platform_version'].to_i}/repodata/repomd.xml.key" + default['bareos']['contrib_baseurl'] = "#{node['bareos']['contrib_url']}/CentOS_#{node['platform_version'].to_i}/" + default['bareos']['contrib_gpgkey'] = "#{node['bareos']['contrib_url']}/CentOS_#{node['platform_version'].to_i}/repodata/repomd.xml.key" + when 'redhat' + default['bareos']['baseurl'] = "#{node['bareos']['url']}/#{node['bareos']['version']}/#{node['platform_family'].upcase}_#{node['platform_version'].to_i}/" + default['bareos']['gpgkey'] = "#{node['bareos']['url']}/#{node['bareos']['version']}/#{node['platform_family'].upcase}_#{node['platform_version'].to_i}/repodata/repomd.xml.key" + default['bareos']['contrib_baseurl'] = "#{node['bareos']['contrib_url']}/#{node['platform_family'].upcase}_#{node['platform_version'].to_i}/" + default['bareos']['contrib_gpgkey'] = "#{node['bareos']['contrib_url']}/#{node['platform_family'].upcase}_#{node['platform_version'].to_i}/repodata/repomd.xml.key" + end +when 'fedora' + default['bareos']['baseurl'] = "#{node['bareos']['url']}/#{node['bareos']['version']}/#{node['platform'].capitalize}_#{node['platform_version']}/" + default['bareos']['gpgkey'] = "#{node['bareos']['url']}/#{node['bareos']['version']}/#{node['platform'].capitalize}_#{node['platform_version']}/repodata/repomd.xml.key" + default['bareos']['contrib_baseurl'] = "#{node['bareos']['contrib_url']}/#{node['platform'].capitalize}_#{node['platform_version']}/" + default['bareos']['contrib_gpgkey'] = "#{node['bareos']['contrib_url']}/#{node['platform'].capitalize}_#{node['platform_version']}/repodata/repomd.xml.key" +else + default['bareos']['baseurl'] = nil + default['bareos']['gpgkey'] = nil + default['bareos']['contrib_baseurl'] = nil + default['bareos']['contrib_gpgkey'] = nil end +# Messages +default['bareos']['messages']['mail_to'] = "bareos@#{node['domain']}" +default['bareos']['messages']['default_messages'] = 'Standard' +default['bareos']['messages']['default_admin_messages'] = 'all, !skipped, !restored' + # Database -default['bareos']['database_type'] = 'postgresql' # postgresql/mysql -default['bareos']['dbdriver'] = 'postgresql' -default['bareos']['dbname'] = 'bareos' -default['bareos']['dbuser'] = 'bareos' -default['bareos']['dbpassword'] = '' - -# Clients list -default['bareos']['clients'] = [] -default['bareos']['enable_vfulls'] = false # Needs more work within host template -default['bareos']['host_pools'] = false -default['bareos']['custom_host_pools'] = false -default['bareos']['host_full_pool'] = 'test-pool-Full' -default['bareos']['host_incremental_pool'] = 'test-pool-Inc' -default['bareos']['host_differential_pool'] = 'test-pool-Diff' +default['bareos']['database']['catalog_name'] = 'MyCatalog' +default['bareos']['database']['database_type'] = 'postgresql' # postgresql/mysql +default['bareos']['database']['dbdriver'] = 'postgresql' # postgresql/mysql +default['bareos']['database']['dbname'] = 'bareos' +default['bareos']['database']['dbuser'] = 'bareos' +default['bareos']['database']['dbpassword'] = '' +default['bareos']['database']['dbaddress'] = nil + +# Clients +default['bareos']['clients']['name'] = node['fqdn'] +default['bareos']['clients']['net_name'] = node['fqdn'] +default['bareos']['clients']['fd_port'] = 9102 +default['bareos']['clients']['max_concurrent_jobs'] = 20 +default['bareos']['clients']['heartbeat_interval'] = 600 +default['bareos']['clients']['client_search_query'] = 'roles:bareos_client' +default['bareos']['clients']['client_list'] = %w(node) +default['bareos']['clients']['bootstrap_file'] = '/var/lib/bareos/%c.bsr' +default['bareos']['clients']['jobdef_default_messages'] = 'Standard' +default['bareos']['clients']['jobdef_default_fileset'] = "#{node['fqdn']}-Fileset" +default['bareos']['clients']['storage'] = 'File' # Storage Daemon -default['bareos']['tape'] = false +default['bareos']['storage']['name'] = node['fqdn'] +default['bareos']['storage']['storage_search_query'] = 'roles:bareos_storage' +default['bareos']['storage']['sd_port'] = 9103 +default['bareos']['storage']['servers'] = %w(node) +default['bareos']['storage']['max_concurrent_jobs'] = 20 +default['bareos']['storage']['sd_mon_enable'] = 'yes' +default['bareos']['storage']['autochanger_enabled'] = false +default['bareos']['storage']['conf']['help']['Example Block'] = '# You can put extra configs here.' # Director -default['bareos']['dir_port'] = 9101 -default['bareos']['dir_max_concurrent_jobs'] = 20 -default['bareos']['dir_subscription'] = nil -default['bareos']['dir_subs'] = nil +default['bareos']['director']['name'] = node['fqdn'] +default['bareos']['director']['net_name'] = node['fqdn'] +default['bareos']['director']['dir_search_query'] = 'roles:bareos_director' +default['bareos']['director']['dir_port'] = 9101 +default['bareos']['director']['dir_max_concurrent_jobs'] = 20 +default['bareos']['director']['servers'] = %w(node) +default['bareos']['director']['console_commandacl'] = 'status, .status' +default['bareos']['director']['heartbeat_interval'] = 600 +default['bareos']['director']['catalog_jobdef'] = 'default-catalog-def' +default['bareos']['director']['conf']['help']['Example Block'] = '# You can put extra configs here.' +default['bareos']['director']['config_change_notify'] = 'restart' + +# Subscription Management (Director) +default['bareos']['director']['dir_subscription'] = nil +default['bareos']['director']['dir_subs'] = nil + +# Workstation +default['bareos']['workstation']['name'] = node['fqdn'] + +# Graphite Plugin Default Attributes +default['bareos']['plugins']['graphite']['packages'] = if platform_family?('rhel') && node['platform_version'].to_i == 6 + %w(python python-bareos python-requests python-fedora-django) + else + %w(python python-bareos python-requests python-django) + end + +default['bareos']['plugins']['graphite']['plugin_path'] = '/usr/sbin' +default['bareos']['plugins']['graphite']['config_path'] = '/etc/bareos' +default['bareos']['plugins']['graphite']['search_query'] = 'roles:bareos_director' +default['bareos']['plugins']['graphite']['server'] = 'graphite' +default['bareos']['plugins']['graphite']['graphite_port'] = '2003' +default['bareos']['plugins']['graphite']['graphite_data_prefix'] = 'bareos.' +default['bareos']['plugins']['graphite']['graphite_plugin_src_url'] = 'https://raw.githubusercontent.com/bareos/bareos-contrib/master/misc/performance/graphite/bareos-graphite-poller.py' + +############################## +# Examples - Default Hashes # +############################## + +# Default Client Config +default['bareos']['clients']['conf'] = { + 'FDPort' => '9102', + 'File Retention' => '30 days', + 'Job Retention' => '6 months', + 'AutoPrune' => 'yes', + 'Maximum Concurrent Jobs' => '20' +} + +default['bareos']['director']['jobs'] = nil + +# Default Job Definitions +default['bareos']['clients']['job_definitions']['default-def'] = { + 'Level' => 'Incremental', + 'Fileset' => 'default-fileset', + 'Schedule' => 'monthly', + 'Storage' => 'default-file-storage', + 'Messages' => 'Standard', + 'Pool' => 'default-file-pool', + 'Priority' => '10', + 'Write Bootstrap' => '"/var/lib/bareos/%c.bsr"', + 'SpoolData' => 'no' +} + +default['bareos']['clients']['job_definitions']['default-catalog-def'] = { + 'Level' => 'Full', + 'Fileset' => 'Catalog', + 'Schedule' => 'WeeklyCycleAfterBackup', + 'Storage' => 'default-file-storage', + 'Messages' => 'Standard', + 'Pool' => 'default-file-pool', + 'Allow Duplicate Jobs' => 'no' +} + +default['bareos']['clients']['job_definitions']['default-restore-def'] = { + 'Fileset' => 'default-fileset', + 'Storage' => 'default-file-storage', + 'Messages' => 'Standard', + 'Pool' => 'default-file-pool', + 'Priority' => '7', + 'Where' => '/tmp/bareos-restores' +} + +# Default Filesets +default['bareos']['clients']['filesets']['default'] = { + 'options' => { + 'signature' => 'MD5' + }, + 'include' => { + 'File' => ['/', '/home'], + 'Exclude Dir Containing' => ['.bareos_ignore'] + }, + 'exclude' => { + 'File' => [ + '/var/lib/bareos', + '/var/lib/bareos/storage', + '/var/lib/pgsql', + '/var/lib/mysql', + '/proc', + 'tmp', + '/.journal', + '/.fsck', + '/spool' + ] + } +} + +# Default Pools +default['bareos']['clients']['pools']['default-file-pool'] = { + 'Pool Type' => 'Backup', + 'Recycle' => 'yes', + 'Volume Retention' => '30 days', + 'Maximum Volume Bytes' => '10G', + 'Maximum Volumes' => '25', + 'LabelFormat' => 'FileVolume-' +} + +# Default Schedules +default['bareos']['clients']['schedules']['monthly'] = { + 'Description' => [ + 'Default Monthly Schedule' + ], + 'Run' => [ + 'Full 1st sun at 23:05', + 'Differential 2nd-5th sun at 23:05', + 'Incremental mon-sat at 23:05' + ], + 'Enabled' => [ + 'yes' + ] +} + +# Default Storages +default['bareos']['clients']['storages']['default-file-storage'] = { + 'Address' => node['bareos']['storage']['name'], # N.B. Use a fully qualified name here + 'Device' => 'FileStorage', + 'Media Type' => 'File' +} + +# Example/Test Tape Autochanger Configurations +if node['bareos']['test_mode'] == true && node['bareos']['storage']['autochanger_enabled'] == true + default['bareos']['storage']['autochangers']['autochanger-0'] = { + 'Device' => [ + 'tapedrive-0', + 'tapedrive-1' + ], + 'Changer Device' => ['/dev/tape/by-id/scsi-1TANDBERGStorageLoader_SOMEAUTOCHANGER'], + 'Changer Command' => ['"/usr/lib/bareos/scripts/mtx-changer %c %o %S %a %d"'] + } + + default['bareos']['storage']['autochangers']['autochanger-1'] = { + 'Device' => [ + 'tapedrive-0' + ], + 'Changer Device' => ['/dev/tape/by-id/scsi-1TANDBERGStorageLoader_SOMEAUTOCHANGER'], + 'Changer Command' => ['"/usr/lib/bareos/scripts/mtx-changer %c %o %S %a %d"'] + } + + default['bareos']['storage']['devices']['tapedrive-0'] = { + 'DeviceType' => 'tape', + 'DriveIndex' => '0', + 'ArchiveDevice' => 'dev/nst0', + 'MediaType' => 'lto', + 'Autochanger' => 'no', + 'AutomaticMount' => 'no', + 'MaximumFileSize' => '10GB' + } + + default['bareos']['storage']['devices']['tapedrive-1'] = { + 'DeviceType' => 'tape', + 'DriveIndex' => '0', + 'ArchiveDevice' => 'dev/nst0', + 'MediaType' => 'lto', + 'Autochanger' => 'no', + 'AutomaticMount' => 'no', + 'MaximumFileSize' => '10GB' + } + + # Example Unmanaged client for testing + default['bareos']['clients']['unmanaged']['unmanaged-client-fd'] = { + 'Address' => 'unmanaged-client', + 'Password' => 'onefbofnerwob', + 'Catalog' => 'MyCatalog', + 'FDPort' => '9102' + } + # Example Jobs + default['bareos']['clients']['jobs']["#{node.default['bareos']['clients']['name']}-job"] = { + 'Client' => "#{node['bareos']['clients']['name']}-fd", + 'Type' => 'Backup', + 'JobDefs' => 'default-def' + } + + default['bareos']['clients']['jobs']["#{node.default['bareos']['clients']['name']}-restore-job"] = { + 'Client' => "#{node['bareos']['clients']['name']}-fd", + 'Type' => 'Restore', + 'JobDefs' => 'default-restore-def' + } +end diff --git a/metadata.rb b/metadata.rb index c1a0e27..78a7075 100644 --- a/metadata.rb +++ b/metadata.rb @@ -1,16 +1,22 @@ -name 'chef-bareos' -maintainer 'dsi' -maintainer_email 'leonard.tavae@informatique.gov.pf' -license 'Apache 2.0' -description 'Installs/Configures bareos' -long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '0.1.4' +name 'chef-bareos' +maintainer 'dsi' +maintainer_email 'leonard.tavae@informatique.gov.pf' +license 'Apache 2.0' +description 'Installs/Configures BAREOS - Backup Archiving REcovery Open Sourced' +long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) +issues_url 'https://github.com/sitle/chef-bareos/issues' +source_url 'https://github.com/sitle/chef-bareos.git' +version '3.0.2' -supports 'debian', '>= 7.0' -supports 'ubuntu', '>= 12.04' -supports 'centos', '>= 6.0' +%w( centos redhat ).each do |os| + supports os, '>= 6.0' +end -depends 'apt' -depends 'openssl' -depends 'postgresql' -depends 'yum' +%w( debian ubuntu ).each do |os| + supports os +end + +depends 'apt', '>= 2.0' +depends 'openssl', '>= 4.0' +depends 'postgresql', '~> 4.0' +depends 'yum-epel', '>= 0.6' diff --git a/recipes/autochanger.rb b/recipes/autochanger.rb new file mode 100644 index 0000000..f9e9b09 --- /dev/null +++ b/recipes/autochanger.rb @@ -0,0 +1,41 @@ +# encoding: UTF-8 +# +# Copyright (C) 2016 Leonard TAVAE +# +# Cookbook Name:: chef-bareos +# Recipe:: autochanger +# +# 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. + +# Experimental Tape Autochanger Support +package 'bareos-storage-tape' + +execute 'mtx-changer' do + command '/usr/bin/bareos/scripts/mtx-changer' + creates '/etc/bareos/mtx-changer.conf' + action :run +end + +template '/etc/bareos/bareos-sd.d/device-tape-with-autoloader.conf' do + source 'device-tape-with-autoloader.conf.erb' + owner 'bareos' + group 'bareos' + mode '0640' + variables( + autochangers: node['bareos']['storage']['autochangers'], + devices: node['bareos']['storage']['devices'] + ) + only_if { File.exist?('/etc/bareos/mtx-changer.conf') } + notifies :restart, 'service[bareos-sd]', :delayed + action :create +end diff --git a/recipes/client.rb b/recipes/client.rb index fac9eec..b599ab2 100644 --- a/recipes/client.rb +++ b/recipes/client.rb @@ -1,8 +1,9 @@ # encoding: UTF-8 -# Cookbook Name:: bareos -# Recipe:: client # -# Copyright (C) 2014 Leonard TAVAE +# Copyright (C) 2016 Leonard TAVAE +# +# Cookbook Name:: chef-bareos +# Recipe:: client # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,41 +16,46 @@ # 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 the OpenSSL library for generating random passwords +::Chef::Recipe.send(:include, OpenSSLCookbook::RandomPassword) node.set_unless['bareos']['fd_password'] = random_password(length: 30, mode: :base64) node.set_unless['bareos']['mon_password'] = random_password(length: 30, mode: :base64) node.save unless Chef::Config[:solo] -# Installation du File daemon BAREOS +# Installation of the BAREOS File Daemon +include_recipe 'chef-bareos::repo' +package 'bareos-filedaemon' -package 'bareos-filedaemon' do - action :install -end - -if Chef::Config[:solo] - bareos_server = node['bareos']['server'] -else - bareos_server = search(:node, 'role:bareos_server') -end +# Determine the list of BAREOS directors +dir_search_query = node.default['bareos']['director']['dir_search_query'] +bareos_dir = if Chef::Config[:solo] + node['bareos']['director']['servers'] + else + search(:node, dir_search_query) + end +# Setup the configs for any local/remote File Daemons clients template '/etc/bareos/bareos-fd.conf' do source 'bareos-fd.conf.erb' owner 'root' group 'bareos' mode '0640' variables( - bareos_server: bareos_server + bareos_dir: bareos_dir ) - notifies :run, 'execute[restart-fd]', :immediately + sensitive true end +# Allow the restart of the File Daemon with tests upfront, if called execute 'restart-fd' do command 'bareos-fd -t -c /etc/bareos/bareos-fd.conf' action :nothing + subscribes :run, 'template[/etc/bareos/bareos-fd.conf]', :immediately notifies :restart, 'service[bareos-fd]', :delayed end +# Start and enable the BAREOS File Daemon service 'bareos-fd' do supports status: true, restart: true, reload: false action [:enable, :start] diff --git a/recipes/database.rb b/recipes/database.rb index fcdeca9..c6c83c0 100644 --- a/recipes/database.rb +++ b/recipes/database.rb @@ -1,8 +1,9 @@ # encoding: UTF-8 -# Cookbook Name:: bareos -# Recipe:: database # -# Copyright (C) 2014 Leonard TAVAE +# Copyright (C) 2016 Leonard TAVAE +# +# Cookbook Name:: chef-bareos +# Recipe:: database # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,22 +16,19 @@ # 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. -# -package 'bareos-database-tools' do - action :install -end +# Define the type of database desired, mysql still needs some cookbook work +database = node['bareos']['database']['database_type'] -database = node['bareos']['database_type'] +# Install the BAREOS database packages +include_recipe 'chef-bareos::repo' +package 'bareos-database-tools' +package "bareos-database-#{database}" +# Determine DB resources to install (psql/mysql) case database when 'postgresql' include_recipe 'postgresql::server' - - package "bareos-database-#{database}" do - action :install - end - else if platform_family?('rhel') database_client_name = database.to_s @@ -39,36 +37,25 @@ database_client_name = "#{database}-client" database_server_name = database.to_s end - - package database_client_name.to_s do - action :install - end - - package database_server_name.to_s do - action :install - end - - package "bareos-database-#{database}" do - action :install - end + package database_client_name.to_s + package database_server_name.to_s end -if database == 'postgresql' - +# Need to add some mysql logic here to do the database setup for bareos, psql only right now, mysql is manual +case database +when 'postgresql' execute 'create_database' do - command 'su postgres -c "/usr/lib/bareos/scripts/create_bareos_database" && touch /usr/lib/bareos/.dbcreated' + command 'su postgres -c /usr/lib/bareos/scripts/create_bareos_database && touch /usr/lib/bareos/.dbcreated' creates '/usr/lib/bareos/.dbcreated' action :run end - execute 'create_tables' do - command 'su postgres -s /bin/bash -c "/usr/lib/bareos/scripts/make_bareos_tables" && touch /usr/lib/bareos/.dbtablescreated' + command 'su postgres -s /bin/bash -c /usr/lib/bareos/scripts/make_bareos_tables && touch /usr/lib/bareos/.dbtablescreated' creates '/usr/lib/bareos/.dbtablescreated' action :run end - execute 'grant_privileges' do - command 'su postgres -s /bin/bash -c "/usr/lib/bareos/scripts/grant_bareos_privileges" && touch /usr/lib/bareos/.dbprivgranted' + command 'su postgres -s /bin/bash -c /usr/lib/bareos/scripts/grant_bareos_privileges && touch /usr/lib/bareos/.dbprivgranted' creates '/usr/lib/bareos/.dbprivgranted' action :run end diff --git a/recipes/default.rb b/recipes/default.rb index 0ecb2ca..1976bb2 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -1,8 +1,9 @@ # encoding: UTF-8 -# Cookbook Name:: bareos -# Recipe:: default # -# Copyright (C) 2014 Leonard TAVAE +# Copyright (C) 2016 Leonard TAVAE +# +# Cookbook Name:: chef-bareos +# Recipe:: default # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,10 +16,7 @@ # 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. -# - -# Randomly generate ssh passwords for Bareos Daemons -::Chef::Recipe.send(:include, OpenSSLCookbook::RandomPassword) +# Include both the repo and client recipes for most cases include_recipe 'chef-bareos::repo' include_recipe 'chef-bareos::client' diff --git a/recipes/graphite_plugin.rb b/recipes/graphite_plugin.rb new file mode 100644 index 0000000..8959673 --- /dev/null +++ b/recipes/graphite_plugin.rb @@ -0,0 +1,48 @@ +# encoding: UTF-8 +# +# Cookbook Name:: chef-bareos +# Recipe:: graphite_plugin +# +# 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_recipe 'chef-bareos::repo' + +node['bareos']['plugins']['graphite']['packages'].each do |py_pkg| + package py_pkg +end + +directory node['bareos']['plugins']['graphite']['config_path'] + +template "#{node['bareos']['plugins']['graphite']['config_path']}/graphite-poller.conf" do + owner 'root' + group 'root' + mode '0740' + sensitive true +end + +remote_file "#{node['bareos']['plugins']['graphite']['plugin_path']}/bareos-graphite-poller.py" do + source node['bareos']['plugins']['graphite']['graphite_plugin_src_url'] + owner 'root' + group 'root' + mode '0740' + use_last_modified true + use_conditional_get true + sensitive true +end + +cron 'bareos_graphite_poller' do + command <<-EOH + #{node['bareos']['plugins']['graphite']['plugin_path']}/bareos-graphite-poller.py\ + -c #{node['bareos']['plugins']['graphite']['config_path']}/graphite-poller.conf + EOH +end diff --git a/recipes/repo.rb b/recipes/repo.rb index 19483b9..c6b9d22 100644 --- a/recipes/repo.rb +++ b/recipes/repo.rb @@ -1,8 +1,9 @@ # encoding: UTF-8 -# Cookbook Name:: bareos -# Recipe:: repo # -# Copyright (C) 2014 Leonard TAVAE +# Copyright (C) 2016 Leonard TAVAE +# +# Cookbook Name:: chef-bareos +# Recipe:: repo # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,19 +16,35 @@ # 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. -# -if platform_family?('rhel') - yum_repository node['bareos']['yum_repository'] do +# Add repos for supported OS platforms, otherwise return fatal notice +case node['platform_family'] +when 'rhel', 'fedora' + yum_repository node['bareos']['repository_name'] do description node['bareos']['description'] baseurl node['bareos']['baseurl'] gpgkey node['bareos']['gpgkey'] action :create end -else + yum_repository node['bareos']['contrib_repository_name'] do + description node['bareos']['contrib_description'] + baseurl node['bareos']['contrib_baseurl'] + gpgkey node['bareos']['contrib_gpgkey'] + action :create + end +when 'debian' apt_repository 'bareos' do uri node['bareos']['baseurl'] components ['/'] + distribution '' key node['bareos']['gpgkey'] end + apt_repository 'bareos_contrib' do + uri node['bareos']['contrib_baseurl'] + components ['/'] + distribution '' + key node['bareos']['contrib_gpgkey'] + end +else + Chef::Log.fatal('OS is not currently supported by this cookbook, submit enhancement request or PR') end diff --git a/recipes/server.rb b/recipes/server.rb index babd212..c62c072 100644 --- a/recipes/server.rb +++ b/recipes/server.rb @@ -1,8 +1,9 @@ # encoding: UTF-8 -# Cookbook Name:: bareos -# Recipe:: server # -# Copyright (C) 2014 Leonard TAVAE +# Copyright (C) 2016 Leonard TAVAE +# +# Cookbook Name:: chef-bareos +# Recipe:: server # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,76 +16,174 @@ # 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. -# +# By default here including both the repo and client recipes +# This is just so Bareos has SOMETHING to backup (i.e. Catalog) +include_recipe 'chef-bareos::client' + +# Preparing Random Password for the director and mon, including OpenSSL library from client.rb node.set_unless['bareos']['dir_password'] = random_password(length: 30, mode: :base64) node.set_unless['bareos']['mon_password'] = random_password(length: 30, mode: :base64) node.save unless Chef::Config[:solo] -# Installation des services BAREOS - -package 'bareos-director' do - action :install +# Install BAREOS Server Packages +%w( bareos-director bareos-tools ).each do |server_pkgs| + package server_pkgs do + action :install + end end -package 'bareos-tools' do - action :install +# Create the custom config directory and placeholder file +directory '/etc/bareos/bareos-dir.d' do + owner 'root' + group 'root' + mode '0755' + action :create end -if Chef::Config[:solo] - bareos_clients = node['bareos']['clients'] -else - bareos_clients = search(:node, 'roles:bareos_base') +template '/etc/bareos/bareos-dir.d/dir_helper.conf' do + source 'dir_helper.conf.erb' + owner 'bareos' + group 'bareos' + mode '0644' + variables( + dir_help: node['bareos']['director']['conf']['help'] + ) + sensitive true + action :create end +# Director Config template '/etc/bareos/bareos-dir.conf' do source 'bareos-dir.conf.erb' - mode 0640 owner 'bareos' group 'bareos' + mode '0640' variables( - db_driver: node['bareos']['dbdriver'], - db_name: node['bareos']['dbname'], - db_user: node['bareos']['dbuser'], - db_password: node['bareos']['dbpassword'], - db_address: node['bareos']['dbaddress'] + db_driver: node['bareos']['database']['dbdriver'], + db_name: node['bareos']['database']['dbname'], + db_user: node['bareos']['database']['dbuser'], + db_password: node['bareos']['database']['dbpassword'], + db_address: node['bareos']['database']['dbaddress'], + dir_name: node['bareos']['director']['name'] ) - notifies :run, 'execute[reload-dir]', :delayed + sensitive true + only_if { File.exist?('/etc/bareos/bareos-dir.d/dir_helper.conf') } end -# Handle seperate host config files -unless Chef::Config[:solo] +# Create clients config based on sets of hashes, see attributes file for default example(s) +client_search_query = node['bareos']['clients']['client_search_query'] - # Create hosts direcotry for host configs - directory '/etc/bareos/bareos-dir.d/hosts/' do - owner 'root' - group 'root' - mode '0755' - action :create - end +bareos_clients = if Chef::Config[:solo] + node['bareos']['clients']['client_list'] + else + search(:node, client_search_query) + end - # Populate host config files based on hosts with bareos_base role in runlist - bareos_clients.each do - template "/etc/bareos/bareos-dir.d/hosts/#{node['hostname']}.conf" do - source 'host.conf.erb' - owner 'bareos' - group 'bareos' - mode '0640' - variables( - bareos_clients: bareos_clients - ) - notifies :run, 'execute[reload-dir]', :delayed - end - end +template '/etc/bareos/bareos-dir.d/clients.conf' do + source 'clients.conf.erb' + owner 'bareos' + group 'bareos' + mode '0640' + variables( + unmanaged_clients: node['bareos']['clients']['unmanaged'], + bareos_clients: bareos_clients, + client_conf: node['bareos']['clients']['conf'] + ) + sensitive true +end + +# Create other various configs based on sets of hashes +template '/etc/bareos/bareos-dir.d/jobs.conf' do + source 'jobs.conf.erb' + owner 'bareos' + group 'bareos' + mode '0640' + variables( + jobs: node['bareos']['clients']['jobs'] + ) + sensitive true +end +template '/etc/bareos/bareos-dir.d/job_definitions.conf' do + source 'job_definitions.conf.erb' + owner 'bareos' + group 'bareos' + mode '0640' + variables( + job_definitions: node['bareos']['clients']['job_definitions'] + ) + sensitive true +end +template '/etc/bareos/bareos-dir.d/filesets.conf' do + source 'filesets.conf.erb' + owner 'bareos' + group 'bareos' + mode '0640' + variables( + fileset_config: node['bareos']['clients']['filesets'] + ) + sensitive true +end +template '/etc/bareos/bareos-dir.d/pools.conf' do + source 'pools.conf.erb' + owner 'bareos' + group 'bareos' + mode '0640' + variables( + client_pools: node['bareos']['clients']['pools'] + ) + sensitive true +end +template '/etc/bareos/bareos-dir.d/schedules.conf' do + source 'schedules.conf.erb' + owner 'bareos' + group 'bareos' + mode '0640' + variables( + client_schedules: node['bareos']['clients']['schedules'] + ) + sensitive true +end +template '/etc/bareos/bareos-dir.d/storages.conf' do + source 'storages.conf.erb' + owner 'bareos' + group 'bareos' + mode '0640' + variables( + client_storages: node['bareos']['clients']['storages'] + ) + sensitive true end +# Allow a reload of the director daemon configs if called with tests up front execute 'reload-dir' do command 'su - bareos -s /bin/sh -c "/usr/sbin/bareos-dir -t -c /etc/bareos/bareos-dir.conf"' action :nothing - notifies :reload, 'service[bareos-dir]', :delayed + subscribes :run, 'template[/etc/bareos/bareos-dir.d/storages.conf]', :delayed + subscribes :run, 'template[/etc/bareos/bareos-dir.d/schedules.conf]', :delayed + subscribes :run, 'template[/etc/bareos/bareos-dir.d/pools.conf]', :delayed + subscribes :run, 'template[/etc/bareos/bareos-dir.d/filesets.conf]', :delayed + subscribes :run, 'template[/etc/bareos/bareos-dir.d/job_definitions.conf]', :delayed + subscribes :run, 'template[/etc/bareos/bareos-dir.d/jobs.conf]', :delayed + subscribes :run, 'template[/etc/bareos/bareos-dir.d/clients.conf]', :delayed + subscribes :run, 'template[/etc/bareos/bareos-dir.conf]', :delayed + if node['bareos']['director']['config_change_notify'] == 'restart' + notifies :restart, 'service[bareos-dir]', :delayed + else + notifies :start, 'service[bareos-dir]', :immediate + notifies :run, 'execute[bareos-dir_reload]', :delayed + end end +# Enable and start the bareos-dir service service 'bareos-dir' do supports status: true, restart: true, reload: false action [:enable, :start] + subscribes :restart, 'service[postgresql]', :delayed +end + +# Optional reload of the director config via execute +execute 'bareos-dir_reload' do + command 'echo reload | bconsole' + action :nothing end diff --git a/recipes/storage.rb b/recipes/storage.rb index 6af3d37..b41f572 100644 --- a/recipes/storage.rb +++ b/recipes/storage.rb @@ -1,8 +1,9 @@ # encoding: UTF-8 -# Cookbook Name:: bareos -# Recipe:: storage # -# Copyright (C) 2014 Leonard TAVAE +# Copyright (C) 2016 Leonard TAVAE +# +# Cookbook Name:: chef-bareos +# Recipe:: storage # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,46 +16,76 @@ # 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 the OpenSSL cookbook library +# Setup Storage Daemon Random Passwords +::Chef::Recipe.send(:include, OpenSSLCookbook::RandomPassword) node.set_unless['bareos']['sd_password'] = random_password(length: 30, mode: :base64) node.save unless Chef::Config[:solo] -# Installation du Storage daemon BAREOS - +# Install BAREOS Storage Daemon Packages +include_recipe 'chef-bareos::repo' package 'bareos-storage' do action :install end -# if node['bareos']['tape'] == 'true' -# package "bareos-storage-tape" do -# action :install -# end -# end - -if Chef::Config[:solo] - bareos_server = node['bareos']['server'] +# Find Storage Daemon(s) and Director(s) +storage_search_query = node['bareos']['storage']['storage_search_query'] +dir_search_query = node['bareos']['director']['dir_search_query'] +if Chef::Config.solo + bareos_sd = node['bareos']['storage']['servers'] + bareos_dir = node['bareos']['director']['servers'] else - bareos_server = search(:node, 'role:bareos_server') + bareos_sd = search(:node, storage_search_query) + bareos_dir = search(:node, dir_search_query) end +# Create the custom config directory and placeholder file +directory '/etc/bareos/bareos-sd.d' do + owner 'root' + group 'bareos' + mode '0755' + action :create +end + +template '/etc/bareos/bareos-sd.d/sd_helper.conf' do + source 'sd_helper.conf.erb' + owner 'root' + group 'bareos' + mode '0644' + variables( + sd_help: node['bareos']['storage']['conf']['help'] + ) + sensitive true + action :create +end + +# SD Config template '/etc/bareos/bareos-sd.conf' do source 'bareos-sd.conf.erb' mode 0640 owner 'bareos' group 'bareos' variables( - bareos_server: bareos_server + bareos_sd: bareos_sd, + bareos_dir: bareos_dir ) - notifies :run, 'execute[restart-sd]', :immediately + sensitive true + only_if { File.exist?('/etc/bareos/bareos-sd.d/sd_helper.conf') } end +# Experimental Tape Autochanger Support +include_recipe 'chef-bareos::autochanger' if node['bareos']['storage']['autochanger_enabled'] + +# Test Config before restarting SD execute 'restart-sd' do command 'bareos-sd -t -c /etc/bareos/bareos-sd.conf' action :nothing + subscribes :run, 'template[/etc/bareos/bareos-sd.conf]', :immediately notifies :restart, 'service[bareos-sd]', :delayed end +# Start and enable SD service service 'bareos-sd' do supports status: true, restart: true, reload: false action [:enable, :start] diff --git a/recipes/workstation.rb b/recipes/workstation.rb index a874a9b..fb1d1e3 100644 --- a/recipes/workstation.rb +++ b/recipes/workstation.rb @@ -1,8 +1,9 @@ # encoding: UTF-8 -# Cookbook Name:: bareos -# Recipe:: workstation # -# Copyright (C) 2014 Leonard TAVAE +# Copyright (C) 2016 Leonard TAVAE +# +# Cookbook Name:: chef-bareos +# Recipe:: workstation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,15 +16,29 @@ # 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. -# +# Install bconsole from repo +include_recipe 'chef-bareos::repo' package 'bareos-bconsole' do action :install end +# Find director(s) +dir_search_query = node['bareos']['director']['dir_search_query'] +bareos_dir = if Chef::Config[:solo] + node['bareos']['director']['servers'] + else + search(:node, dir_search_query) + end + +# bconsole config template '/etc/bareos/bconsole.conf' do source 'bconsole.conf.erb' mode 0640 owner 'bareos' group 'bareos' + variables( + bareos_dir: bareos_dir + ) + sensitive true end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..4e00004 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,4 @@ +require 'chefspec' +require 'chefspec/berkshelf' + +at_exit { ChefSpec::Coverage.report! } diff --git a/spec/unit/recipes/default_spec.rb b/spec/unit/recipes/default_spec.rb new file mode 100644 index 0000000..7407482 --- /dev/null +++ b/spec/unit/recipes/default_spec.rb @@ -0,0 +1,69 @@ +# +# Cookbook Name:: chef-bareos +# Spec:: default +# +# Copyright (c) 2015 The Authors, All Rights Reserved. + +require 'spec_helper' + +describe 'chef-bareos::default' do + before do + allow_any_instance_of(Chef::Recipe).to receive(:include_recipe).and_call_original + allow_any_instance_of(Chef::Recipe).to receive(:include_recipe).with('chef-bareos::client') + end + + context 'When all attributes are default, on an unspecified platform' do + let(:chef_run) do + runner = ChefSpec::ServerRunner.new + runner.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + + it 'includes the client recipe' do + expect_any_instance_of(Chef::Recipe).to receive(:include_recipe).with('chef-bareos::client') + chef_run + end + end + + context 'on an ubuntu 14.04 box' do + let(:chef_run) do + runner = ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '14.04') + runner.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + + it 'adds the apt repo bareos' do + expect(chef_run).to add_apt_repository('bareos') + end + + it 'adds the apt repo bareos_contrib' do + expect(chef_run).to add_apt_repository('bareos_contrib') + end + end + + context 'on an centos 6.7 box' do + let(:chef_run) do + runner = ChefSpec::ServerRunner.new(platform: 'centos', version: '6.7') do + end + runner.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + + it 'adds the yum repo bareos' do + expect(chef_run).to create_yum_repository('bareos') + end + + it 'adds the yum repo bareos_contrib' do + expect(chef_run).to create_yum_repository('bareos_contrib') + end + end +end diff --git a/spec/unit/recipes/repo_spec.rb b/spec/unit/recipes/repo_spec.rb new file mode 100644 index 0000000..ea35ede --- /dev/null +++ b/spec/unit/recipes/repo_spec.rb @@ -0,0 +1,63 @@ +# Test that the repo is being put on the box as desired + +require 'spec_helper' + +describe 'chef-bareos::repo' do + ['6.7', '7.2.1511'].each do |version| + context "on CentOS #{version}" do + before do + Fauxhai.mock(platform: 'centos', version: version) + end + + let(:chef_run) do + ChefSpec::SoloRunner.new do + end.converge('chef-bareos::repo') + end + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + + it 'should add bareos yum repo' do + # expect(chef_run).to add_yum_repository('bareos') + end + + it 'should add bareos_contrib yum repo' do + # expect(chef_run).to add_yum_repository('bareos_contrib') + end + end + end + + ['12.04', '14.04'].each do |version| + context "on Ubuntu #{version}" do + before do + Fauxhai.mock(platform: 'ubuntu', version: version) + end + + let(:chef_run) do + ChefSpec::SoloRunner.new do + end.converge('chef-bareos::repo') + end + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + + it 'should add bareos apt repo' do + # expect(chef_run).to add_apt_repository('bareos').with( + # 'uri' => node['bareos']['baseurl'], + # 'key' => node['bareos']['gpgkey'], + # 'components' => ['/'] + # ) + end + + it 'should add bareos_contrib apt repo' do + # expect(chef_run).to add_apt_repository('bareos_contrib').with( + # 'uri' => node['bareos']['contrib_baseurl'], + # 'key' => node['bareos']['contrib_gpgkey'], + # 'components' => ['/'] + # ) + end + end + end +end diff --git a/templates/default/bareos-dir.conf.erb b/templates/default/bareos-dir.conf.erb index 5eacb8c..7c6adc3 100644 --- a/templates/default/bareos-dir.conf.erb +++ b/templates/default/bareos-dir.conf.erb @@ -1,80 +1,40 @@ <%# DIRECTOR TEMPLATE %> -# Generated by Chef for <%= node['fqdn'] %> +# Generated by Chef for <%= @dir_name %>-dir # Local modifications will be overwritten. +# +# Bareos Director Configuration File +####################### +# Director Definition # +####################### Director { - Name = <%= node['hostname'] %>-dir - DIRport = <%= node['bareos']['dir_port'] %> + Name = <%= @dir_name %>-dir + DIRport = <%= node['bareos']['director']['dir_port'] %> QueryFile = "/usr/lib/bareos/scripts/query.sql" - Maximum Concurrent Jobs = <%= node['bareos']['dir_max_concurrent_jobs'] %> + Maximum Concurrent Jobs = <%= node['bareos']['director']['dir_max_concurrent_jobs'] %> Password = "<%= node['bareos']['dir_password'] %>" Messages = Daemon - Heartbeat Interval = 600 - <% if node['bareos']['dir_subscription'] == true %> - Subscriptions = <%= node['bareos']['dir_subs'] %> + Heartbeat Interval = <%= node['bareos']['director']['heartbeat_interval'] %> + <% if node['bareos']['director']['dir_subscription'] == true %> + Subscriptions = <%= node['bareos']['director']['dir_subs'] %> <% end %> } +############################## +# Default Catalog Backup Job # +############################## Job { - Name = "<%= node['hostname'] %>-BackupCatalog" - JobDefs = "<%= node['hostname'] %>-Job" + Name = "<%= @dir_name %>-BackupCatalog" + Type = Backup + Client = <%= @dir_name %>-fd + JobDefs = "<%= node['bareos']['director']['catalog_jobdef'] %>" Level = Full - FileSet="Catalog" + FileSet = "Catalog" Schedule = "WeeklyCycleAfterBackup" - RunBeforeJob = "/usr/lib/bareos/scripts/make_catalog_backup.pl MyCatalog" + RunBeforeJob = "/usr/lib/bareos/scripts/make_catalog_backup.pl <%= node['bareos']['database']['catalog_name'] %>" RunAfterJob = "/usr/lib/bareos/scripts/delete_catalog_backup" - Write Bootstrap = "|/usr/sbin/bsmtp -h localhost -f \"\(Bareos\) \" -s \"Bootstrap for Job %j\" root@localhost" - Priority = 11 # run after main backup -} - -FileSet { - Name = "Full Set" - Include { - Options { - signature = MD5 - } - File = /etc - File = /home - } - - Exclude { - File = /var/lib/bareos - File = /var/lib/bareos/storage - File = /proc - File = /tmp - File = /.journal - File = /.fsck - } -} - -FileSet { - Name = "Windows All Drives" - Enable VSS = yes - Include { - Options { - Signature = MD5 - Drive Type = fixed - IgnoreCase = yes - WildFile = "[A-Z]:/pagefile.sys" - WildDir = "[A-Z]:/RECYCLER" - WildDir = "[A-Z]:/$RECYCLE.BIN" - WildDir = "[A-Z]:/System Volume Information" - Exclude = yes - } - File = / - } -} - -Schedule { - Name = "WeeklyCycle" - Run = Full 1st sun at 23:05 - Run = Differential 2nd-5th sun at 23:05 - Run = Incremental mon-sat at 23:05 -} - -Schedule { - Name = "WeeklyCycleAfterBackup" - Run = Full sun-sat at 23:10 + Write Bootstrap = "|/usr/sbin/bsmtp -h localhost -f \"\(Bareos\) \" -s \"Bootstrap for Job %j\" <%= node['bareos']['messages']['mail_to'] %>" + Priority = 11 # run after main backup } FileSet { @@ -88,76 +48,57 @@ FileSet { } } -Storage { - Name = File - Address = <%= node['fqdn'] %> # N.B. Use a fully qualified name here - Password = "<%= node['bareos']['sd_password'] %>" - Device = FileStorage - Media Type = File +Schedule { + Name = "WeeklyCycleAfterBackup" + Run = Full sun-sat at 23:10 } +################### +# Default Catalog # +################### Catalog { - Name = MyCatalog - dbdriver = "<%= @db_driver %>" - dbname = "<%= @db_name %>" - dbuser = "<%= @db_user %>" + Name = <%= node['bareos']['database']['catalog_name'] %> + dbdriver = <%= @db_driver %> + dbname = <%= @db_name %> + dbuser = <%= @db_user %> dbpassword = "<%= @db_password %>" <% if @db_address != nil %> - dbaddress = "<%= @db_address %>" + dbaddress = <%= @db_address %> <% end %> } +#################### +# Console/Messages # +#################### Console { - Name = backup-mon + Name = <%= @dir_name %>-mon Password = "<%= node['bareos']['mon_password'] %>" - CommandACL = status, .status + CommandACL = <%= node['bareos']['director']['console_commandacl'] %> } Messages { Name = Standard - mailcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bareos\) \<%r\>\" -s \"Bareos: %t %e of %c %l\" %r" - operatorcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bareos\) \<%r\>\" -s \"Bareos: Intervention needed for %j\" %r" - mail = root@localhost = all, !skipped - operator = root@localhost = mount + mailcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bareos\) \<\%r\>\" -s \"Bareos: %t %e of %c %l\" %r" + operatorcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bareos\) \<\%r\>\" -s \"Bareos: Intervention needed for %j\" %r" + mail on error = <%= node['bareos']['messages']['mail_to'] %> = all, !skipped + operator = <%= node['bareos']['messages']['mail_to'] %> = mount console = all, !skipped, !saved - append = "/var/log/bareos/bareos.log" = all, !skipped + append = "/var/log/bareos/bareos.log" = all, !skipped, !restored catalog = all } Messages { Name = Daemon - mailcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bareos\) \<%r\>\" -s \"Bareos daemon message\" %r" - mail = root@localhost = all, !skipped + mailcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bareos\) \<\%r\>\" -s \"Bareos daemon message\" %r" + mail on error = <%= node['bareos']['messages']['mail_to'] %> = all, !skipped console = all, !skipped, !saved append = "/var/log/bareos/bareos.log" = all, !skipped + catalog = all } -Pool { - Name = Default - Pool Type = Backup - Recycle = yes - AutoPrune = yes - Volume Retention = 365 days -} - -Pool { - Name = File - Pool Type = Backup - Recycle = yes - AutoPrune = yes - Volume Retention = 365 days - Maximum Volume Bytes = 50G - Maximum Volumes = 100 -} - -Pool { - Name = Scratch - Pool Type = Backup -} - -########################################################################## -# Other Stuff -########################################################################## +########################################### +# Custom Director Daemon Config Locations # +########################################### -#working#################### -@|"sh -c 'for f in /etc/bareos/bareos-dir.d/hosts/*.conf ; do echo @${f} ; done'" +# General +@|"sh -c 'for conf in /etc/bareos/bareos-dir.d/*.conf ; do echo @${conf} ; done'" diff --git a/templates/default/bareos-fd.conf.erb b/templates/default/bareos-fd.conf.erb index a01770c..945db27 100644 --- a/templates/default/bareos-fd.conf.erb +++ b/templates/default/bareos-fd.conf.erb @@ -1,28 +1,33 @@ <%# FILE DAEMON TEMPLATE %> -# Generated by Chef for <%= node['fqdn'] %> +# Generated by Chef for <%= node['bareos']['clients']['name'] %>-fd # Local modifications will be overwritten. +# +# Bareos Client FileDaemon Configuration File FileDaemon { - Name = <%= node['hostname'] %>-fd - Maximum Concurrent Jobs = 20 + Name = "<%= node['bareos']['clients']['name'] %>-fd" + FDPort = <%= node['bareos']['clients']['fd_port'] %> + Maximum Concurrent Jobs = <%= node['bareos']['clients']['max_concurrent_jobs'] %> + Heartbeat Interval = <%= node['bareos']['clients']['heartbeat_interval'] %> } -<% @bareos_server.each do |server| %> - +<% @bareos_dir.each do |director| %> +########## +# Director/Monitor Resources for <%= director['bareos']['director']['name'] %> +########## Director { - Name = <%= server['hostname'] %>-dir + Name = <%= director['bareos']['director']['name'] %>-dir Password = "<%= node['bareos']['fd_password'] %>" } Director { - Name = <%= server['hostname'] %>-mon - Password = "<%= node['bareos']['mon_password'] %>" - Monitor = yes + Name = <%= director['bareos']['director']['name'] %>-mon + Password = "<%= director['bareos']['mon_password'] %>" + Monitor = <%= node['bareos']['storage']['sd_mon_enable'] %> } Messages { - Name = Standard - director = backup-dir = all, !skipped, !restored + Name = <%= node['bareos']['messages']['default_messages'] %> + director = <%= director['bareos']['director']['name'] %>-dir = <%= node['bareos']['messages']['default_admin_messages'] %> } - <% end %> diff --git a/templates/default/bareos-sd.conf.erb b/templates/default/bareos-sd.conf.erb index 3d57a26..8c78955 100644 --- a/templates/default/bareos-sd.conf.erb +++ b/templates/default/bareos-sd.conf.erb @@ -1,37 +1,49 @@ <%# STORAGE DAEMON TEMPLATE %> -# Generated by Chef for <%= node['fqdn'] %> +# Generated by Chef for <%= node['bareos']['storage']['name'] %> # Local modifications will be overwritten. +# +# Bareos Storage Daemon Configuration File Storage { - Name = <%= node['hostname'] %>-sd - Maximum Concurrent Jobs = 20 + Name = <%= node['bareos']['storage']['name'] %>-sd + SDPort = <%= node['bareos']['storage']['sd_port'] %> + Maximum Concurrent Jobs = <%= node['bareos']['storage']['max_concurrent_jobs'] %> } +<% @bareos_dir.each do |director| %> +# Director/Monitor Resources for <%= director['bareos']['director']['name'] %> Director { - Name = <%= node['hostname'] %>-dir - Password = "<%= node['bareos']['sd_password'] %>" + Name = <%= director['bareos']['director']['name'] %>-dir + Password = "<%= director['bareos']['sd_password'] %>" } -<% @bareos_server.each do |server| %> Director { - Name = <%= server['hostname'] %>-mon - Password = "<%= server['bareos']['mon_password'] %>" - Monitor = yes + Name = <%= director['bareos']['director']['name'] %>-mon + Password = "<%= director['bareos']['mon_password'] %>" + Monitor = <%= director['bareos']['storage']['sd_mon_enable'] %> } -<% end %> -Device { - Name = FileStorage - Media Type = File - Archive Device = /var/lib/bareos/storage - LabelMedia = yes; - Random Access = Yes; - AutomaticMount = yes; - RemovableMedia = no; - AlwaysOpen = no; +Messages { + Name = <%= node['bareos']['messages']['default_messages'] %> + director = <%= director['bareos']['director']['name'] %>-dir = <%= node['bareos']['messages']['default_admin_messages'] %> } +########## -Messages { - Name = Standard - director = backup-dir = all +<% end -%> + +Device { + Name = FileStorage + Media Type = File + Archive Device = /var/lib/bareos/storage + Random Access = Yes; + AutomaticMount = yes; + RemovableMedia = no; + AlwaysOpen = no; + LabelMedia = yes } + +######################################## +# Custom Storage Daemon Config Locations +######################################## + +@|"sh -c 'for conf in /etc/bareos/bareos-sd.d/*.conf ; do echo @${conf} ; done'" diff --git a/templates/default/bconsole.conf.erb b/templates/default/bconsole.conf.erb index 9e7c184..0e67aa0 100644 --- a/templates/default/bconsole.conf.erb +++ b/templates/default/bconsole.conf.erb @@ -1,10 +1,15 @@ +<%# BCONSOLE TEMPLATE %> +# Generated by Chef for <%= node['bareos']['workstation']['name'] %> +# Local modifications will be overwritten. # # Bareos User Agent (or Console) Configuration File -# +<% @bareos_dir.sort.each do |director| %> Director { - Name = "<%= node['hostname'] %>-dir" - DIRport = 9101 - address = "<%= node['hostname'] %>" - Password = "<%= node['bareos']['dir_password'] %>" + Name = <%= director['bareos']['director']['name'] %>-dir + address = <%= director['bareos']['director']['net_name'] %> + DIRport = <%= director['bareos']['director']['dir_port'] %> + Password = "<%= director['bareos']['dir_password'] %>" } + +<% end %> diff --git a/templates/default/clients.conf.erb b/templates/default/clients.conf.erb new file mode 100644 index 0000000..293ce0b --- /dev/null +++ b/templates/default/clients.conf.erb @@ -0,0 +1,29 @@ +<%# BAREOS CLIENT TEMPLATE %> +# Generated by Chef for <%= node['bareos']['director']['name'] %>-dir +# Local modifications will be overwritten. +# +# Bareos Client Configuration File + +<% unless @unmanaged_clients.nil? %> + <% @unmanaged_clients.sort.each do |client_key, client_value| %> +Client { + Name = "<%= client_key %>" + <% client_value.each do |key, value| %> + <%= key %> = <%= value %> + <% end %> +} + + <% end %> +<% end %> +<% @bareos_clients.sort.each do |client| %> +Client { + Name = "<%= client['bareos']['clients']['name'] %>-fd" + Address = <%= client['bareos']['clients']['net_name'] %> + Password = "<%= client['bareos']['fd_password'] %>" # password for FileDaemon + Catalog = <%= client['bareos']['database']['catalog_name'] %> + <% @client_conf.each do |key, value| %> + <%= key %> = <%= value %> + <% end %> +} + +<% end %> diff --git a/templates/default/device-tape-with-autoloader.conf.erb b/templates/default/device-tape-with-autoloader.conf.erb new file mode 100644 index 0000000..1e7cbdc --- /dev/null +++ b/templates/default/device-tape-with-autoloader.conf.erb @@ -0,0 +1,77 @@ +<%# BAREOS TAPE AUTOLOADER DEFINITIONS TEMPLATE %> +# Generated by Chef for <%= node['bareos']['storage']['name'] %> +# Local modifications will be overwritten. +# +# Bareos Autochanger Definition File + +## Default commented lines from packaged config + +### Preparations + + +#### Include this configuration file in bareos-sd.conf by: + +#@/etc/bareos/bareos-sd.d/device-tape-with-autoloader.conf + + +#### On Linux use "lsscsi --generic" +#### to get a list of your SCSI devices. +#### However, normaly you should access your devices by-id +#### (eg. /dev/tape/by-id/scsi-350011d00018a5f03-nst), +#### because the short device names like /dev/nst1 +#### might change on reboot. + +#DriveIndex = 0 #default:0, only required if the autoloader have multiple drives. + + +#### If only one drive is available, this is normally /dev/nst0. +#### However, it is advised to access it via id (/dev/tape/by-id/...) + +#ArchiveDevice = /dev/nst0 +#ArchiveDevice = /dev/tape/by-id/scsi-350011d00018a5f03-nst + + +#### Arbitrary string that descripes the the storage media. + +#Description = "Some description for device" + + +#### Bareos uses this to determine which device can handle what media. + +#MediaType = lto + + +#### Enable "Check Labels" if tapes with ANSI/IBM labels should be preserved + +#Check Labels = yes +#AutoChanger = yes # default: no +#AutomaticMount = y # default: no +#MaximumFileSize = 10GB # default: 1000000000 (1GB) + + +######################################################### + +<%# AutoChanger Config %> +<% @autochangers.sort.each do |autochanger_key, line_value1| %> +Autochanger { + Name = <%= autochanger_key %> + Description = "<%= autochanger_key %> Defined by Chef" + <% line_value1.each do |key1, value1| %> + <% value1.each do |v1| %> + <%= key1 %> = <%= v1 %> + <% end %> + <% end %> +} + +<% end %> +<%# Device Config %> +<% @devices.sort.each do |device_key, line_value2| %> +Device { + Name = <%= device_key %> + Description = "<%= device_key %> Defined by Chef" + <% line_value2.each do |key2, value2| %> + <%= key2 %> = <%= value2 %> + <% end %> +} + +<% end %> diff --git a/templates/default/dir_helper.conf.erb b/templates/default/dir_helper.conf.erb new file mode 100644 index 0000000..31daa8b --- /dev/null +++ b/templates/default/dir_helper.conf.erb @@ -0,0 +1,17 @@ +<%# DIRECTOR HELPER TEMPLATE %> +# Generated by Chef for <%= node['bareos']['storage']['name'] %> +# Local modifications will be overwritten. +# +# Bareos Director Helper Configuration File + +# This is a base file so the recipe works with no additional help. +# You can also include a list of strings to assist with additonal config +# inclusions or other bits not currently available in the base director template + +<% unless @dir_help.nil? %> + <% @dir_help.sort.each do |helper_name, helper_str| %> +# <%= helper_name %> +<%= helper_str %> + + <% end %> +<% end %> diff --git a/templates/default/filesets.conf.erb b/templates/default/filesets.conf.erb new file mode 100644 index 0000000..48bc968 --- /dev/null +++ b/templates/default/filesets.conf.erb @@ -0,0 +1,31 @@ +<%# BAREOS FILESET DEFINITIONS TEMPLATE %> +# Generated by Chef for <%= node['bareos']['director']['name'] %>-dir +# Local modifications will be overwritten. +# +# Bareos Pool Definition File + +<% @fileset_config.sort.each do |fileset_name, section| -%> +FileSet { + Name = "<%= fileset_name %>-fileset" + Include { + Options { + <% section['options'].each do |key1, value1| %> + <%= key1 %> = <%= value1 %> + <% end %> + } + <% section['include'].each do |key2, value2| %> + <% value2.each do |v2| %> + <%= key2 %> = <%= v2 %> + <% end %> + <% end %> + } + Exclude { + <% section['exclude'].each do |key3, value3| %> + <% value3.each do |v3| %> + <%= key3 %> = <%= v3 %> + <% end %> + <% end %> + } +} + +<% end %> diff --git a/templates/default/graphite-poller.conf.erb b/templates/default/graphite-poller.conf.erb new file mode 100644 index 0000000..099c745 --- /dev/null +++ b/templates/default/graphite-poller.conf.erb @@ -0,0 +1,10 @@ +<%# BAREOS GRAPHITE PLUGIN CONFIGURATION TEMPLATE %> +[director] +server=<%= node['bareos']['director']['net_name'] %> +name=<%= node['bareos']['director']['name'] %>-dir +password=<%= node['bareos']['dir_password'] %> + +[graphite] +server=<%= node['bareos']['plugins']['graphite']['server'] %> +port=<%= node['bareos']['plugins']['graphite']['graphite_port'] %> +prefix=<%= node['bareos']['plugins']['graphite']['graphite_data_prefix'] %> diff --git a/templates/default/host.conf.erb b/templates/default/host.conf.erb deleted file mode 100644 index 3631e9b..0000000 --- a/templates/default/host.conf.erb +++ /dev/null @@ -1,112 +0,0 @@ -<%# HOST TEMPLATE %> -# Generated by Chef for <%= node['fqdn'] %> -# Local modifications will be overwritten. - -<%# @bareos_clients.each do |client| %> -# Bareos Host Config for <%= node['hostname'] %>-fd - -Client { - Name = <%= node['hostname'] %>-fd - Address = <%= node['fqdn'] %> - Password = "<%= node['bareos']['fd_password'] %>" # password for FileDaemon - File Retention = 30 days - Job Retention = 6 months - AutoPrune = no -} - -JobDefs { - Name = "<%= node['hostname'] %>-Job" - Type = Backup - Level = Incremental - Client = <%= node['hostname'] %>-fd - FileSet = "Full Set" - Schedule = "WeeklyCycle" - Storage = File - Messages = Standard - Pool = Scratch - # Each client can have its own Pool to help with certain cases -<% if node['bareos']['host_pools'] == true && node['bareos']['custom_host_pools'] == true %> - FullBackupPool = <%= node['bareos']['host_full_pool'] %> - IncrementalBackupPool = <%= node['bareos']['host_incremental_pool'] %> - DifferentialBackupPool = <%= node['bareos']['host_differential_pool'] %> -<% elsif node['bareos']['host_pools'] == true %> - FullBackupPool = <%= node['hostname'] %>-Full - IncrementalBackupPool = <%= node['hostname'] %>-Inc - DifferentialBackupPool = <%= node['hostname'] %>-Diff -<% else %> - # FullBackupPool = <%= node['bareos']['host_full_pool'] %> - # IncrementalBackupPool = <%= node['bareos']['host_incremental_pool'] %> - # DifferentialBackupPool = <%= node['bareos']['host_differential_pool'] %> -<% end %> - Priority = 10 - Write Bootstrap = "/var/lib/bareos/%c.bsr" -} - -# Default Job -Job { - Name = "<%= node['hostname'] %>-Job" - JobDefs = "<%= node['hostname'] %>-Job" -} - -# Restore Job -Job { - Name = "<%= node['hostname'] %>-Restore" - Type = Restore - Client = <%= node['hostname'] %>-fd - FileSet= "Full Set" - Storage = File -<% if node['bareos']['host_pools'] == true && node['bareos']['custom_host_pools'] == true %> - Pool = <%= node['bareos']['host_full_pool'] %> -<% elsif node['bareos']['host_pools'] == true %> - Pool = <%= node['hostname'] %>-Full -<% else %> - Pool = Default -<% end %> - Messages = Standard - Where = /tmp/<%= node['hostname'] %>_restored/ -} - -<% if node['bareos']['enable_vfulls'] == true %> -# VirtualFull Job - <%# Need some logic here to determine whether to use %> - <%# VirtualFull backups or not %> -<% end %> - -<% if node['bareos']['host_pools'] == true %> -# Individual host pools for better storage utilization -Pool { - <% if node['bareos']['custom_host_pools'] == true %> - Name = <%= node['bareos']['host_full_pool'] %> - <% else %> - Name = <%= node['hostname'] %>-Full - <% end %> - Pool Type = Backup - Recycle = yes - AutoPrune = yes - Volume Retention = 1 year -} - -Pool { - <% if node['bareos']['custom_host_pools'] == true %> - Name = <%= node['bareos']['host_incremental_pool'] %> - <% else %> - Name = <%= node['hostname'] %>-Inc - <% end %> - Pool Type = Backup - Recycle = yes - AutoPrune = yes - Volume Retention = 30 days -} - -Pool { - <% if node['bareos']['custom_host_pools'] == true %> - Name = <%= node['bareos']['host_differential_pool'] %> - <% else %> - Name = <%= node['hostname'] %>-Diff - <% end %> - Pool Type = Backup - Recycle = yes - AutoPrune = yes - Volume Retention = 3 months -} -<% end %> diff --git a/templates/default/job_definitions.conf.erb b/templates/default/job_definitions.conf.erb new file mode 100644 index 0000000..617a807 --- /dev/null +++ b/templates/default/job_definitions.conf.erb @@ -0,0 +1,17 @@ +<%# BAREOS JOB DEFINITIONS TEMPLATE %> +# Generated by Chef for <%= node['bareos']['director']['name'] %>-dir +# Local modifications will be overwritten. +# +# Bareos Job Definitions File + +<% unless @job_definitions.nil? %> + <% @job_definitions.sort.each do |def_name, def_value| %> +JobDefs { + Name = "<%= def_name %>" + <% def_value.each do |key,value| %> + <%= key %> = <%= value %> + <% end %> +} + + <% end %> +<% end %> diff --git a/templates/default/jobs.conf.erb b/templates/default/jobs.conf.erb new file mode 100644 index 0000000..8f7accf --- /dev/null +++ b/templates/default/jobs.conf.erb @@ -0,0 +1,17 @@ +<%# BAREOS JOBS TEMPLATE %> +# Generated by Chef for <%= node['bareos']['director']['name'] %>-dir +# Local modifications will be overwritten. +# +# Bareos Jobs File + +<% unless @jobs.nil? %> + <% @jobs.sort.each do |job_key, job_value| %> +Job { + Name = "<%= job_key %>" + <% job_value.each do |key, value| %> + <%= key %> = <%= value %> + <% end %> +} + + <% end %> +<% end %> diff --git a/templates/default/pools.conf.erb b/templates/default/pools.conf.erb new file mode 100644 index 0000000..171108f --- /dev/null +++ b/templates/default/pools.conf.erb @@ -0,0 +1,15 @@ +<%# BAREOS POOLS DEFINITIONS TEMPLATE %> +# Generated by Chef for <%= node['bareos']['director']['name'] %>-dir +# Local modifications will be overwritten. +# +# Bareos Pool Definition File + +<% @client_pools.sort.each do |pool_name, pool| %> +Pool { + Name = "<%= pool_name %>" +<% pool.each do |key,value| %> + <%= key %> = <%= value %> +<% end %> +} + +<% end %> diff --git a/templates/default/schedules.conf.erb b/templates/default/schedules.conf.erb new file mode 100644 index 0000000..90aa987 --- /dev/null +++ b/templates/default/schedules.conf.erb @@ -0,0 +1,21 @@ +<%# BAREOS SCHEDULE DEFINITIONS TEMPLATE %> +# Generated by Chef for <%= node['bareos']['director']['name'] %>-dir +# Local modifications will be overwritten. +# +# Bareos Schedule Definitions File + +<% @client_schedules.sort.each do |sched_name, directive| %> +Schedule { + Name = "<%= sched_name %>" + <% directive['Run'].each do |schedules| %> + Run = <%= schedules %> + <% end %> + <% directive['Description'].each do |description| %> + Description = "<%= description %>" + <% end %> + <% directive['Enabled'].each do |enabled| %> + Enabled = <%= enabled %> + <% end %> +} + +<% end %> diff --git a/templates/default/sd_helper.conf.erb b/templates/default/sd_helper.conf.erb new file mode 100644 index 0000000..943921a --- /dev/null +++ b/templates/default/sd_helper.conf.erb @@ -0,0 +1,17 @@ +<%# STORAGE DAEMON HELPER TEMPLATE %> +# Generated by Chef for <%= node['bareos']['storage']['name'] %> +# Local modifications will be overwritten. +# +# Bareos Storage Daemon Helper Configuration File + +# This is a base file so the recipe works with no additional help. +# You can also include a list of strings to assist with additonal config +# inclusions or other bits not currently available in the base storage daemon template + +<% unless @sd_help.nil? %> + <% @sd_help.sort.each do |helper_name, helper_str| %> +# <%= helper_name %> +<%= helper_str %> + + <% end %> +<% end %> diff --git a/templates/default/storages.conf.erb b/templates/default/storages.conf.erb new file mode 100644 index 0000000..4bdd72b --- /dev/null +++ b/templates/default/storages.conf.erb @@ -0,0 +1,16 @@ +<%# BAREOS STORAGE DEFINITIONS TEMPLATE %> +# Generated by Chef for <%= node['bareos']['director']['name'] %>-dir +# Local modifications will be overwritten. +# +# Bareos Storage Definitions File + +<% @client_storages.sort.each do |stor_name, stor| %> +Storage { + Name = "<%= stor_name %>" + Password = "<%= node['bareos']['sd_password'] %>" + <% stor.each do |key,value| %> + <%= key %> = <%= value %> + <% end %> +} + +<% end %> diff --git a/test/integration/aio-server-pools/serverspec/spec/spec_helper.rb b/test/integration/aio-server-pools/serverspec/spec/spec_helper.rb deleted file mode 100644 index 3c0aae9..0000000 --- a/test/integration/aio-server-pools/serverspec/spec/spec_helper.rb +++ /dev/null @@ -1,89 +0,0 @@ -# This file was generated by the `rspec --init` command. Conventionally, all -# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. -# The generated `.rspec` file contains `--require spec_helper` which will cause this -# file to always be loaded, without a need to explicitly require it in any files. -# -# Given that it is always loaded, you are encouraged to keep this file as -# light-weight as possible. Requiring heavyweight dependencies from this file -# will add to the boot time of your test suite on EVERY test run, even for an -# individual file that may not need all of that loaded. Instead, consider making -# a separate helper file that requires the additional dependencies and performs -# the additional setup, and require it from the spec files that actually need it. -# -# The `.rspec` file also contains a few flags that are not defaults but that -# users commonly want. -# -# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration -RSpec.configure do |config| - # rspec-expectations config goes here. You can use an alternate - # assertion/expectation library such as wrong or the stdlib/minitest - # assertions if you prefer. - config.expect_with :rspec do |expectations| - # This option will default to `true` in RSpec 4. It makes the `description` - # and `failure_message` of custom matchers include text for helper methods - # defined using `chain`, e.g.: - # be_bigger_than(2).and_smaller_than(4).description - # # => "be bigger than 2 and smaller than 4" - # ...rather than: - # # => "be bigger than 2" - expectations.include_chain_clauses_in_custom_matcher_descriptions = true - end - - # rspec-mocks config goes here. You can use an alternate test double - # library (such as bogus or mocha) by changing the `mock_with` option here. - config.mock_with :rspec do |mocks| - # Prevents you from mocking or stubbing a method that does not exist on - # a real object. This is generally recommended, and will default to - # `true` in RSpec 4. - mocks.verify_partial_doubles = true - end - - # The settings below are suggested to provide a good initial experience - # with RSpec, but feel free to customize to your heart's content. - begin - # These two settings work together to allow you to limit a spec run - # to individual examples or groups you care about by tagging them with - # `:focus` metadata. When nothing is tagged with `:focus`, all examples - # get run. - config.filter_run :focus - config.run_all_when_everything_filtered = true - - # Limits the available syntax to the non-monkey patched syntax that is recommended. - # For more details, see: - # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax - # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ - # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching - config.disable_monkey_patching! - - # This setting enables warnings. It's recommended, but in some cases may - # be too noisy due to issues in dependencies. - config.warnings = true - - # Many RSpec users commonly either run the entire suite or an individual - # file, and it's useful to allow more verbose output when running an - # individual spec file. - if config.files_to_run.one? - # Use the documentation formatter for detailed output, - # unless a formatter has already been configured - # (e.g. via a command-line flag). - config.default_formatter = 'doc' - end - - # Print the 10 slowest examples and example groups at the - # end of the spec run, to help surface which specs are running - # particularly slow. - config.profile_examples = 10 - - # Run specs in random order to surface order dependencies. If you find an - # order dependency and want to debug it, you can fix the order by providing - # the seed, which is printed after each run. - # --seed 1234 - config.order = :random - - # Seed global randomization in this process using the `--seed` CLI option. - # Setting this allows you to use `--seed` to deterministically reproduce - # test failures related to randomization by passing the same `--seed` value - # as the one that triggered the failure. - Kernel.srand config.seed - end -end diff --git a/test/integration/aio-server/serverspec/.rspec b/test/integration/aio-server/serverspec/.rspec deleted file mode 100644 index 83e16f8..0000000 --- a/test/integration/aio-server/serverspec/.rspec +++ /dev/null @@ -1,2 +0,0 @@ ---color ---require spec_helper diff --git a/test/integration/aio-server/serverspec/bareos_spec.rb b/test/integration/aio-server/serverspec/bareos_spec.rb deleted file mode 100644 index b6b14ce..0000000 --- a/test/integration/aio-server/serverspec/bareos_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'spec_helper' - -# Check Packages are installed -describe package('bareos-filedaemon') do - it { should be_installed } -end - -describe package('bareos-storage') do - it { should be_installed } -end - -describe package('bareos-director') do - it { should be_installed } -end - -# Check Services are running and enabled -describe service('bareos-fd') do - it { should be_enabled } - it { should be_running } -end - -describe service('bareos-sd') do - it { should be_enabled } - it { should be_running } -end - -describe service('bareos-dir') do - it { should be_enabled } - it { should be_running } -end diff --git a/test/integration/aio-server/serverspec/spec/spec_helper.rb b/test/integration/aio-server/serverspec/spec/spec_helper.rb deleted file mode 100644 index 3c0aae9..0000000 --- a/test/integration/aio-server/serverspec/spec/spec_helper.rb +++ /dev/null @@ -1,89 +0,0 @@ -# This file was generated by the `rspec --init` command. Conventionally, all -# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. -# The generated `.rspec` file contains `--require spec_helper` which will cause this -# file to always be loaded, without a need to explicitly require it in any files. -# -# Given that it is always loaded, you are encouraged to keep this file as -# light-weight as possible. Requiring heavyweight dependencies from this file -# will add to the boot time of your test suite on EVERY test run, even for an -# individual file that may not need all of that loaded. Instead, consider making -# a separate helper file that requires the additional dependencies and performs -# the additional setup, and require it from the spec files that actually need it. -# -# The `.rspec` file also contains a few flags that are not defaults but that -# users commonly want. -# -# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration -RSpec.configure do |config| - # rspec-expectations config goes here. You can use an alternate - # assertion/expectation library such as wrong or the stdlib/minitest - # assertions if you prefer. - config.expect_with :rspec do |expectations| - # This option will default to `true` in RSpec 4. It makes the `description` - # and `failure_message` of custom matchers include text for helper methods - # defined using `chain`, e.g.: - # be_bigger_than(2).and_smaller_than(4).description - # # => "be bigger than 2 and smaller than 4" - # ...rather than: - # # => "be bigger than 2" - expectations.include_chain_clauses_in_custom_matcher_descriptions = true - end - - # rspec-mocks config goes here. You can use an alternate test double - # library (such as bogus or mocha) by changing the `mock_with` option here. - config.mock_with :rspec do |mocks| - # Prevents you from mocking or stubbing a method that does not exist on - # a real object. This is generally recommended, and will default to - # `true` in RSpec 4. - mocks.verify_partial_doubles = true - end - - # The settings below are suggested to provide a good initial experience - # with RSpec, but feel free to customize to your heart's content. - begin - # These two settings work together to allow you to limit a spec run - # to individual examples or groups you care about by tagging them with - # `:focus` metadata. When nothing is tagged with `:focus`, all examples - # get run. - config.filter_run :focus - config.run_all_when_everything_filtered = true - - # Limits the available syntax to the non-monkey patched syntax that is recommended. - # For more details, see: - # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax - # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ - # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching - config.disable_monkey_patching! - - # This setting enables warnings. It's recommended, but in some cases may - # be too noisy due to issues in dependencies. - config.warnings = true - - # Many RSpec users commonly either run the entire suite or an individual - # file, and it's useful to allow more verbose output when running an - # individual spec file. - if config.files_to_run.one? - # Use the documentation formatter for detailed output, - # unless a formatter has already been configured - # (e.g. via a command-line flag). - config.default_formatter = 'doc' - end - - # Print the 10 slowest examples and example groups at the - # end of the spec run, to help surface which specs are running - # particularly slow. - config.profile_examples = 10 - - # Run specs in random order to surface order dependencies. If you find an - # order dependency and want to debug it, you can fix the order by providing - # the seed, which is printed after each run. - # --seed 1234 - config.order = :random - - # Seed global randomization in this process using the `--seed` CLI option. - # Setting this allows you to use `--seed` to deterministically reproduce - # test failures related to randomization by passing the same `--seed` value - # as the one that triggered the failure. - Kernel.srand config.seed - end -end diff --git a/test/integration/aio-server/serverspec/spec_helper.rb b/test/integration/aio-server/serverspec/spec_helper.rb deleted file mode 100644 index 8763eb5..0000000 --- a/test/integration/aio-server/serverspec/spec_helper.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'serverspec' - -set :backend, :exec - -RSpec.configure do |c| - c.before :all do - set :path, '$PATH:/sbin:/usr/local/sbin' - end - - if ENV['ASK_SUDO_PASSWORD'] - require 'highline/import' - c.sudo_password = ask('Enter sudo password: ') { |q| q.echo = false } - else - c.sudo_password = ENV['SUDO_PASSWORD'] - end -end diff --git a/test/integration/aio-server-pools/serverspec/bareos_spec.rb b/test/integration/bareos-aio-server/serverspec/bareos_spec.rb similarity index 100% rename from test/integration/aio-server-pools/serverspec/bareos_spec.rb rename to test/integration/bareos-aio-server/serverspec/bareos_spec.rb diff --git a/test/integration/aio-server-pools/serverspec/spec_helper.rb b/test/integration/bareos-aio-server/serverspec/spec_helper.rb similarity index 100% rename from test/integration/aio-server-pools/serverspec/spec_helper.rb rename to test/integration/bareos-aio-server/serverspec/spec_helper.rb diff --git a/test/integration/roles/bareos_base.json b/test/integration/roles/bareos_client.json similarity index 68% rename from test/integration/roles/bareos_base.json rename to test/integration/roles/bareos_client.json index 08eafd0..58fc178 100644 --- a/test/integration/roles/bareos_base.json +++ b/test/integration/roles/bareos_client.json @@ -1,6 +1,6 @@ { - "name": "base", - "description": "simple base role for a bareos box test", + "name": "bareos_client", + "description": "simple client role for a bareos box test", "json_class": "Chef::Role", "default_attributes": { }, diff --git a/test/integration/roles/bareos_server.json b/test/integration/roles/bareos_director.json similarity index 53% rename from test/integration/roles/bareos_server.json rename to test/integration/roles/bareos_director.json index f078924..8d3d4ec 100644 --- a/test/integration/roles/bareos_server.json +++ b/test/integration/roles/bareos_director.json @@ -1,6 +1,6 @@ { - "name": "bareos_server", - "description": "Backup server role", + "name": "bareos_director", + "description": "Bareos Director Role", "json_class": "Chef::Role", "default_attributes": { }, @@ -8,11 +8,12 @@ }, "chef_type": "role", "run_list": [ - "role[bareos_base]", - "recipe[chef-bareos::server]", + "role[bareos_client]", "recipe[chef-bareos::database]", - "recipe[chef-bareos::storage]", - "recipe[chef-bareos::workstation]" + "role[bareos_storage]", + "recipe[chef-bareos::server]", + "recipe[chef-bareos::workstation]", + "recipe[chef-bareos::graphite_plugin]" ], "env_run_lists": { } diff --git a/test/integration/roles/bareos_storage.json b/test/integration/roles/bareos_storage.json new file mode 100644 index 0000000..3d20bbf --- /dev/null +++ b/test/integration/roles/bareos_storage.json @@ -0,0 +1,15 @@ +{ + "name": "bareos_storage", + "description": "Bareos Storage Role", + "json_class": "Chef::Role", + "default_attributes": { + }, + "override_attributes": { + }, + "chef_type": "role", + "run_list": [ + "recipe[chef-bareos::storage]" + ], + "env_run_lists": { + } +} diff --git a/test/integration/server-host-pools/serverspec/.rspec b/test/integration/server-host-pools/serverspec/.rspec deleted file mode 100644 index 83e16f8..0000000 --- a/test/integration/server-host-pools/serverspec/.rspec +++ /dev/null @@ -1,2 +0,0 @@ ---color ---require spec_helper diff --git a/test/integration/server-host-pools/serverspec/bareos_spec.rb b/test/integration/server-host-pools/serverspec/bareos_spec.rb deleted file mode 100644 index bc63088..0000000 --- a/test/integration/server-host-pools/serverspec/bareos_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'spec_helper' - -describe package('bareos-director') do - it { should be_installed } -end - -describe service('bareos-dir') do - it { should be_enabled } - it { should be_running } -end - -describe package('bareos-storage') do - it { should be_installed } -end - -describe service('bareos-sd') do - it { should be_enabled } - it { should be_running } -end - -describe package('bareos-filedaemon') do - it { should be_installed } -end - -describe service('bareos-fd') do - it { should be_enabled } - it { should be_running } -end diff --git a/test/integration/server-host-pools/serverspec/spec/spec_helper.rb b/test/integration/server-host-pools/serverspec/spec/spec_helper.rb deleted file mode 100644 index 3c0aae9..0000000 --- a/test/integration/server-host-pools/serverspec/spec/spec_helper.rb +++ /dev/null @@ -1,89 +0,0 @@ -# This file was generated by the `rspec --init` command. Conventionally, all -# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. -# The generated `.rspec` file contains `--require spec_helper` which will cause this -# file to always be loaded, without a need to explicitly require it in any files. -# -# Given that it is always loaded, you are encouraged to keep this file as -# light-weight as possible. Requiring heavyweight dependencies from this file -# will add to the boot time of your test suite on EVERY test run, even for an -# individual file that may not need all of that loaded. Instead, consider making -# a separate helper file that requires the additional dependencies and performs -# the additional setup, and require it from the spec files that actually need it. -# -# The `.rspec` file also contains a few flags that are not defaults but that -# users commonly want. -# -# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration -RSpec.configure do |config| - # rspec-expectations config goes here. You can use an alternate - # assertion/expectation library such as wrong or the stdlib/minitest - # assertions if you prefer. - config.expect_with :rspec do |expectations| - # This option will default to `true` in RSpec 4. It makes the `description` - # and `failure_message` of custom matchers include text for helper methods - # defined using `chain`, e.g.: - # be_bigger_than(2).and_smaller_than(4).description - # # => "be bigger than 2 and smaller than 4" - # ...rather than: - # # => "be bigger than 2" - expectations.include_chain_clauses_in_custom_matcher_descriptions = true - end - - # rspec-mocks config goes here. You can use an alternate test double - # library (such as bogus or mocha) by changing the `mock_with` option here. - config.mock_with :rspec do |mocks| - # Prevents you from mocking or stubbing a method that does not exist on - # a real object. This is generally recommended, and will default to - # `true` in RSpec 4. - mocks.verify_partial_doubles = true - end - - # The settings below are suggested to provide a good initial experience - # with RSpec, but feel free to customize to your heart's content. - begin - # These two settings work together to allow you to limit a spec run - # to individual examples or groups you care about by tagging them with - # `:focus` metadata. When nothing is tagged with `:focus`, all examples - # get run. - config.filter_run :focus - config.run_all_when_everything_filtered = true - - # Limits the available syntax to the non-monkey patched syntax that is recommended. - # For more details, see: - # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax - # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ - # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching - config.disable_monkey_patching! - - # This setting enables warnings. It's recommended, but in some cases may - # be too noisy due to issues in dependencies. - config.warnings = true - - # Many RSpec users commonly either run the entire suite or an individual - # file, and it's useful to allow more verbose output when running an - # individual spec file. - if config.files_to_run.one? - # Use the documentation formatter for detailed output, - # unless a formatter has already been configured - # (e.g. via a command-line flag). - config.default_formatter = 'doc' - end - - # Print the 10 slowest examples and example groups at the - # end of the spec run, to help surface which specs are running - # particularly slow. - config.profile_examples = 10 - - # Run specs in random order to surface order dependencies. If you find an - # order dependency and want to debug it, you can fix the order by providing - # the seed, which is printed after each run. - # --seed 1234 - config.order = :random - - # Seed global randomization in this process using the `--seed` CLI option. - # Setting this allows you to use `--seed` to deterministically reproduce - # test failures related to randomization by passing the same `--seed` value - # as the one that triggered the failure. - Kernel.srand config.seed - end -end diff --git a/test/integration/server-host-pools/serverspec/spec_helper.rb b/test/integration/server-host-pools/serverspec/spec_helper.rb deleted file mode 100644 index 8763eb5..0000000 --- a/test/integration/server-host-pools/serverspec/spec_helper.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'serverspec' - -set :backend, :exec - -RSpec.configure do |c| - c.before :all do - set :path, '$PATH:/sbin:/usr/local/sbin' - end - - if ENV['ASK_SUDO_PASSWORD'] - require 'highline/import' - c.sudo_password = ask('Enter sudo password: ') { |q| q.echo = false } - else - c.sudo_password = ENV['SUDO_PASSWORD'] - end -end