├── .fixtures.yml ├── .gitignore ├── .rspec ├── .rubocop.yml ├── .travis.yml ├── .yardopts ├── CHANGELOG ├── CONTRIBUTING.md ├── Gemfile ├── LICENSE ├── README.md ├── Rakefile ├── lib └── puppet │ └── parser │ └── functions │ └── generate_clients.rb ├── manifests ├── bat.pp ├── client.pp ├── common.pp ├── config.pp ├── config │ ├── client.pp │ └── validate.pp ├── console.pp ├── director.pp ├── init.pp └── storage.pp ├── metadata.json ├── spec ├── acceptance │ ├── bacula_spec.rb │ └── nodesets │ │ ├── centos-511-x64.yml │ │ ├── centos-6-x64.yml │ │ ├── centos-66-x64-pe.yml │ │ ├── centos-66-x64.yml │ │ ├── centos-7-x64.yml │ │ ├── centos-72-x64.yml │ │ ├── debian-7-x64.yml │ │ ├── debian-78-x64.yml │ │ ├── debian-82-x64.yml │ │ ├── default.yml │ │ ├── ubuntu-server-1204-x64.yml │ │ └── ubuntu-server-1404-x64.yml ├── classes │ ├── bacula_spec.rb │ └── coverage_spec.rb ├── spec_helper.rb └── spec_helper_acceptance.rb ├── templates ├── bacula-dir.conf.erb ├── bacula-fd.conf.erb ├── bacula-sd.conf.erb ├── bconsole.conf.erb └── client_config.erb └── tests └── init.pp /.fixtures.yml: -------------------------------------------------------------------------------- 1 | fixtures: 2 | repositories: 3 | stdlib: git://github.com/puppetlabs/puppetlabs-stdlib.git 4 | mysql: git://github.com/puppetlabs/puppetlabs-mysql.git 5 | sqlite: git://github.com/puppetlabs/puppetlabs-sqlite.git 6 | symlinks: 7 | bacula: "#{source_dir}" -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | pkg/ 2 | Gemfile.lock 3 | Gemfile.local 4 | vendor/ 5 | .vendor/ 6 | spec/fixtures/ 7 | .vagrant/ 8 | .bundle/ 9 | coverage/ 10 | log/ 11 | .idea/ 12 | *.iml 13 | .*.sw 14 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --format documentation 2 | --color 3 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | require: rubocop-rspec 2 | AllCops: 3 | TargetRubyVersion: 1.9 4 | Include: 5 | - ./**/*.rb 6 | Exclude: 7 | - vendor/**/* 8 | - .vendor/**/* 9 | - pkg/**/* 10 | - spec/fixtures/**/* 11 | 12 | # Configuration parameters: AllowURI, URISchemes. 13 | Metrics/LineLength: 14 | Max: 328 15 | 16 | # 'Complexity' is very relative 17 | Metrics/PerceivedComplexity: 18 | Enabled: false 19 | 20 | # 'Complexity' is very relative 21 | Metrics/CyclomaticComplexity: 22 | Enabled: false 23 | 24 | # 'Complexity' is very relative 25 | Metrics/AbcSize: 26 | Enabled: false 27 | 28 | # Method length is not necessarily an indicator of code quality 29 | Metrics/MethodLength: 30 | Enabled: false 31 | 32 | # Module length is not necessarily an indicator of code quality 33 | Metrics/ModuleLength: 34 | Enabled: false 35 | 36 | # Class length is not necessarily an indicator of code quality 37 | Metrics/ClassLength: 38 | Enabled: false 39 | 40 | # dealbreaker: 41 | Style/TrailingCommaInArguments: 42 | Enabled: false 43 | Style/TrailingCommaInLiteral: 44 | Enabled: false 45 | Style/ClosingParenthesisIndentation: 46 | Enabled: false 47 | 48 | Lint/AmbiguousRegexpLiteral: 49 | Enabled: true 50 | Style/RegexpLiteral: 51 | Enabled: true 52 | Style/WordArray: 53 | Enabled: true 54 | 55 | # this catches the cases of using `module` for parser functions, types, or 56 | # providers 57 | Style/ClassAndModuleChildren: 58 | Enabled: false 59 | 60 | Style/Documentation: 61 | Description: 'Document classes and non-namespace modules.' 62 | Enabled: false 63 | 64 | # More comfortable block layouts 65 | Style/BlockDelimiters: 66 | Enabled: False 67 | 68 | Style/MultilineBlockLayout: 69 | Enabled: False 70 | 71 | # Rspec 72 | 73 | # We don't use rspec in this way 74 | RSpec/DescribeClass: 75 | Enabled: False 76 | 77 | # Example length is not necessarily an indicator of code quality 78 | RSpec/ExampleLength: 79 | Enabled: False 80 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | sudo: false 3 | language: ruby 4 | cache: bundler 5 | bundler_args: --without system_tests development 6 | before_install: 7 | - bundle -v 8 | - rm Gemfile.lock || true 9 | - gem update --system 10 | - gem update bundler 11 | - gem --version 12 | - bundle -v 13 | script: 14 | - 'bundle exec rake $CHECK' 15 | matrix: 16 | fast_finish: true 17 | include: 18 | - rvm: 1.9.3 19 | env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" CHECK=test 20 | - rvm: 1.9.3 21 | env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" FUTURE_PARSER="yes" CHECK=test 22 | - rvm: 2.1 23 | env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" CHECK=test 24 | - rvm: 2.1 25 | env: PUPPET_VERSION="~> 4.0" STRICT_VARIABLES="yes" CHECK=test 26 | - rvm: 2.2 27 | env: PUPPET_VERSION="~> 4.0" STRICT_VARIABLES="yes" CHECK=test 28 | - rvm: 2.3.1 29 | env: PUPPET_VERSION="~> 4.0" STRICT_VARIABLES="yes" CHECK=rubocop 30 | - rvm: 2.3.1 31 | env: PUPPET_VERSION="~> 4.0" STRICT_VARIABLES="yes" CHECK=test 32 | notifications: 33 | email: false 34 | deploy: 35 | provider: puppetforge 36 | user: puppet 37 | password: 38 | secure: "xgqHA/tU1N5t0W+mQDv0JCmWEUSvlB//SmYFfns2oy3XbAy1N+ZawAhFSHnPmFYCQMfpsPAPuFHFM38SHOeXnV+Fssycia8P2AgsjHhSiZfA4yF5Qi2qyiGmX2gdZkPXqoKGfxIux92l25XIicsL8l++aHSZg3/YHvzwNXB1bbc=" 39 | on: 40 | tags: true 41 | # all_branches is required to use tags 42 | all_branches: true 43 | # Only publish if our main Ruby target builds 44 | rvm: 2.2 45 | -------------------------------------------------------------------------------- /.yardopts: -------------------------------------------------------------------------------- 1 | --markup markdown 2 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | 2011-12-15 - Carl Caum - 0.0.1 2 | - Support multiple DB backends 3 | - Support Managing databases through 3rd party modules 4 | - Ability to declare clients through class parameters 5 | or ENC variables 6 | - Documentation improvements 7 | 8 | 2011-12-08 - Carl Caum - 0.0.1 9 | - Manage a Bacula director 10 | - Manage Bacula clients 11 | - Manage a Bacula storage daemon 12 | - Manage console installations 13 | - Customize configuration files with custom templates 14 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | This module has grown over time based on a range of contributions from 2 | people using it. If you follow these contributing guidelines your patch 3 | will likely make it into a release a little quicker. 4 | 5 | 6 | ## Contributing 7 | 8 | Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. [Contributor Code of Conduct](https://voxpupuli.org/coc/). 9 | 10 | 1. Fork the repo. 11 | 12 | 1. Create a separate branch for your change. 13 | 14 | 1. Run the tests. We only take pull requests with passing tests, and 15 | documentation. 16 | 17 | 1. Add a test for your change. Only refactoring and documentation 18 | changes require no new tests. If you are adding functionality 19 | or fixing a bug, please add a test. 20 | 21 | 1. Squash your commits down into logical components. Make sure to rebase 22 | against the current master. 23 | 24 | 1. Push the branch to your fork and submit a pull request. 25 | 26 | Please be prepared to repeat some of these steps as our contributors review 27 | your code. 28 | 29 | ## Dependencies 30 | 31 | The testing and development tools have a bunch of dependencies, 32 | all managed by [bundler](http://bundler.io/) according to the 33 | [Puppet support matrix](http://docs.puppetlabs.com/guides/platforms.html#ruby-versions). 34 | 35 | By default the tests use a baseline version of Puppet. 36 | 37 | If you have Ruby 2.x or want a specific version of Puppet, 38 | you must set an environment variable such as: 39 | 40 | export PUPPET_VERSION="~> 4.2.0" 41 | 42 | Install the dependencies like so... 43 | 44 | bundle install 45 | 46 | ## Syntax and style 47 | 48 | The test suite will run [Puppet Lint](http://puppet-lint.com/) and 49 | [Puppet Syntax](https://github.com/gds-operations/puppet-syntax) to 50 | check various syntax and style things. You can run these locally with: 51 | 52 | bundle exec rake lint 53 | bundle exec rake validate 54 | 55 | ## Running the unit tests 56 | 57 | The unit test suite covers most of the code, as mentioned above please 58 | add tests if you're adding new functionality. If you've not used 59 | [rspec-puppet](http://rspec-puppet.com/) before then feel free to ask 60 | about how best to test your new feature. 61 | 62 | To run your all the unit tests 63 | 64 | bundle exec rake spec SPEC_OPTS='--format documentation' 65 | 66 | To run a specific spec test set the `SPEC` variable: 67 | 68 | bundle exec rake spec SPEC=spec/foo_spec.rb 69 | 70 | To run the linter, the syntax checker and the unit tests: 71 | 72 | bundle exec rake test 73 | 74 | 75 | ## Integration tests 76 | 77 | The unit tests just check the code runs, not that it does exactly what 78 | we want on a real machine. For that we're using 79 | [beaker](https://github.com/puppetlabs/beaker). 80 | 81 | This fires up a new virtual machine (using vagrant) and runs a series of 82 | simple tests against it after applying the module. You can run this 83 | with: 84 | 85 | bundle exec rake acceptance 86 | 87 | This will run the tests on an Ubuntu 12.04 virtual machine. You can also 88 | run the integration tests against Centos 6.5 with. 89 | 90 | BEAKER_set=centos-64-x64 bundle exec rake acceptances 91 | 92 | If you don't want to have to recreate the virtual machine every time you 93 | can use `BEAKER_DESTROY=no` and `BEAKER_PROVISION=no`. On the first run you will 94 | at least need `BEAKER_PROVISION` set to yes (the default). The Vagrantfile 95 | for the created virtual machines will be in `.vagrant/beaker_vagrant_fies`. 96 | 97 | # vim: syntax=markdown 98 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source ENV['GEM_SOURCE'] || "https://rubygems.org" 2 | 3 | def location_for(place, fake_version = nil) 4 | if place =~ /^(git[:@][^#]*)#(.*)/ 5 | [fake_version, { :git => $1, :branch => $2, :require => false }].compact 6 | elsif place =~ /^file:\/\/(.*)/ 7 | ['>= 0', { :path => File.expand_path($1), :require => false }] 8 | else 9 | [place, { :require => false }] 10 | end 11 | end 12 | 13 | group :test do 14 | gem 'puppetlabs_spec_helper', :require => false 15 | gem 'rspec-puppet', :require => false, :git => 'https://github.com/rodjek/rspec-puppet.git' 16 | gem 'rspec-puppet-facts', :require => false 17 | gem 'rspec-puppet-utils', :require => false 18 | gem 'puppet-lint', :require => false, :git => 'https://github.com/rodjek/puppet-lint.git' 19 | gem 'puppet-lint-absolute_classname-check', :require => false 20 | gem 'puppet-lint-leading_zero-check', :require => false 21 | gem 'puppet-lint-trailing_comma-check', :require => false 22 | gem 'puppet-lint-version_comparison-check', :require => false 23 | gem 'puppet-lint-classes_and_types_beginning_with_digits-check', :require => false 24 | gem 'puppet-lint-unquoted_string-check', :require => false 25 | gem 'puppet-lint-variable_contains_upcase', :require => false 26 | gem 'metadata-json-lint', :require => false 27 | gem 'puppet-blacksmith', :require => false, :git => 'https://github.com/voxpupuli/puppet-blacksmith.git' 28 | gem 'voxpupuli-release', :require => false, :git => 'https://github.com/voxpupuli/voxpupuli-release-gem.git' 29 | gem 'puppet-strings', :require => false, :git => 'https://github.com/puppetlabs/puppetlabs-strings.git' 30 | gem 'rubocop-rspec', '~> 1.4', :require => false 31 | end 32 | 33 | group :development do 34 | gem 'travis', :require => false 35 | gem 'travis-lint', :require => false 36 | gem 'guard-rake', :require => false 37 | end 38 | 39 | group :system_tests do 40 | gem 'beaker', :require => false 41 | if beaker_version = ENV['BEAKER_VERSION'] 42 | gem 'beaker', *location_for(beaker_version) 43 | end 44 | if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION'] 45 | gem 'beaker-rspec', *location_for(beaker_rspec_version) 46 | else 47 | gem 'beaker-rspec', :require => false 48 | end 49 | gem 'beaker-puppet_install_helper', :require => false 50 | end 51 | 52 | 53 | 54 | if facterversion = ENV['FACTER_GEM_VERSION'] 55 | gem 'facter', facterversion.to_s, :require => false, :groups => [:test] 56 | else 57 | gem 'facter', :require => false, :groups => [:test] 58 | end 59 | 60 | ENV['PUPPET_VERSION'].nil? ? puppetversion = '~> 4.0' : puppetversion = ENV['PUPPET_VERSION'].to_s 61 | gem 'puppet', puppetversion, :require => false, :groups => [:test] 62 | 63 | # vim: syntax=ruby 64 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2011 Puppet Labs LLC 2 | 3 | Apache License 4 | Version 2.0, January 2004 5 | http://www.apache.org/licenses/ 6 | 7 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 8 | 9 | 1. Definitions. 10 | 11 | "License" shall mean the terms and conditions for use, reproduction, 12 | and distribution as defined by Sections 1 through 9 of this document. 13 | 14 | "Licensor" shall mean the copyright owner or entity authorized by 15 | the copyright owner that is granting the License. 16 | 17 | "Legal Entity" shall mean the union of the acting entity and all 18 | other entities that control, are controlled by, or are under common 19 | control with that entity. For the purposes of this definition, 20 | "control" means (i) the power, direct or indirect, to cause the 21 | direction or management of such entity, whether by contract or 22 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 23 | outstanding shares, or (iii) beneficial ownership of such entity. 24 | 25 | "You" (or "Your") shall mean an individual or Legal Entity 26 | exercising permissions granted by this License. 27 | 28 | "Source" form shall mean the preferred form for making modifications, 29 | including but not limited to software source code, documentation 30 | source, and configuration files. 31 | 32 | "Object" form shall mean any form resulting from mechanical 33 | transformation or translation of a Source form, including but 34 | not limited to compiled object code, generated documentation, 35 | and conversions to other media types. 36 | 37 | "Work" shall mean the work of authorship, whether in Source or 38 | Object form, made available under the License, as indicated by a 39 | copyright notice that is included in or attached to the work 40 | (an example is provided in the Appendix below). 41 | 42 | "Derivative Works" shall mean any work, whether in Source or Object 43 | form, that is based on (or derived from) the Work and for which the 44 | editorial revisions, annotations, elaborations, or other modifications 45 | represent, as a whole, an original work of authorship. For the purposes 46 | of this License, Derivative Works shall not include works that remain 47 | separable from, or merely link (or bind by name) to the interfaces of, 48 | the Work and Derivative Works thereof. 49 | 50 | "Contribution" shall mean any work of authorship, including 51 | the original version of the Work and any modifications or additions 52 | to that Work or Derivative Works thereof, that is intentionally 53 | submitted to Licensor for inclusion in the Work by the copyright owner 54 | or by an individual or Legal Entity authorized to submit on behalf of 55 | the copyright owner. For the purposes of this definition, "submitted" 56 | means any form of electronic, verbal, or written communication sent 57 | to the Licensor or its representatives, including but not limited to 58 | communication on electronic mailing lists, source code control systems, 59 | and issue tracking systems that are managed by, or on behalf of, the 60 | Licensor for the purpose of discussing and improving the Work, but 61 | excluding communication that is conspicuously marked or otherwise 62 | designated in writing by the copyright owner as "Not a Contribution." 63 | 64 | "Contributor" shall mean Licensor and any individual or Legal Entity 65 | on behalf of whom a Contribution has been received by Licensor and 66 | subsequently incorporated within the Work. 67 | 68 | 2. Grant of Copyright License. Subject to the terms and conditions of 69 | this License, each Contributor hereby grants to You a perpetual, 70 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 71 | copyright license to reproduce, prepare Derivative Works of, 72 | publicly display, publicly perform, sublicense, and distribute the 73 | Work and such Derivative Works in Source or Object form. 74 | 75 | 3. Grant of Patent License. Subject to the terms and conditions of 76 | this License, each Contributor hereby grants to You a perpetual, 77 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 78 | (except as stated in this section) patent license to make, have made, 79 | use, offer to sell, sell, import, and otherwise transfer the Work, 80 | where such license applies only to those patent claims licensable 81 | by such Contributor that are necessarily infringed by their 82 | Contribution(s) alone or by combination of their Contribution(s) 83 | with the Work to which such Contribution(s) was submitted. If You 84 | institute patent litigation against any entity (including a 85 | cross-claim or counterclaim in a lawsuit) alleging that the Work 86 | or a Contribution incorporated within the Work constitutes direct 87 | or contributory patent infringement, then any patent licenses 88 | granted to You under this License for that Work shall terminate 89 | as of the date such litigation is filed. 90 | 91 | 4. Redistribution. You may reproduce and distribute copies of the 92 | Work or Derivative Works thereof in any medium, with or without 93 | modifications, and in Source or Object form, provided that You 94 | meet the following conditions: 95 | 96 | (a) You must give any other recipients of the Work or 97 | Derivative Works a copy of this License; and 98 | 99 | (b) You must cause any modified files to carry prominent notices 100 | stating that You changed the files; and 101 | 102 | (c) You must retain, in the Source form of any Derivative Works 103 | that You distribute, all copyright, patent, trademark, and 104 | attribution notices from the Source form of the Work, 105 | excluding those notices that do not pertain to any part of 106 | the Derivative Works; and 107 | 108 | (d) If the Work includes a "NOTICE" text file as part of its 109 | distribution, then any Derivative Works that You distribute must 110 | include a readable copy of the attribution notices contained 111 | within such NOTICE file, excluding those notices that do not 112 | pertain to any part of the Derivative Works, in at least one 113 | of the following places: within a NOTICE text file distributed 114 | as part of the Derivative Works; within the Source form or 115 | documentation, if provided along with the Derivative Works; or, 116 | within a display generated by the Derivative Works, if and 117 | wherever such third-party notices normally appear. The contents 118 | of the NOTICE file are for informational purposes only and 119 | do not modify the License. You may add Your own attribution 120 | notices within Derivative Works that You distribute, alongside 121 | or as an addendum to the NOTICE text from the Work, provided 122 | that such additional attribution notices cannot be construed 123 | as modifying the License. 124 | 125 | You may add Your own copyright statement to Your modifications and 126 | may provide additional or different license terms and conditions 127 | for use, reproduction, or distribution of Your modifications, or 128 | for any such Derivative Works as a whole, provided Your use, 129 | reproduction, and distribution of the Work otherwise complies with 130 | the conditions stated in this License. 131 | 132 | 5. Submission of Contributions. Unless You explicitly state otherwise, 133 | any Contribution intentionally submitted for inclusion in the Work 134 | by You to the Licensor shall be under the terms and conditions of 135 | this License, without any additional terms or conditions. 136 | Notwithstanding the above, nothing herein shall supersede or modify 137 | the terms of any separate license agreement you may have executed 138 | with Licensor regarding such Contributions. 139 | 140 | 6. Trademarks. This License does not grant permission to use the trade 141 | names, trademarks, service marks, or product names of the Licensor, 142 | except as required for reasonable and customary use in describing the 143 | origin of the Work and reproducing the content of the NOTICE file. 144 | 145 | 7. Disclaimer of Warranty. Unless required by applicable law or 146 | agreed to in writing, Licensor provides the Work (and each 147 | Contributor provides its Contributions) on an "AS IS" BASIS, 148 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 149 | implied, including, without limitation, any warranties or conditions 150 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 151 | PARTICULAR PURPOSE. You are solely responsible for determining the 152 | appropriateness of using or redistributing the Work and assume any 153 | risks associated with Your exercise of permissions under this License. 154 | 155 | 8. Limitation of Liability. In no event and under no legal theory, 156 | whether in tort (including negligence), contract, or otherwise, 157 | unless required by applicable law (such as deliberate and grossly 158 | negligent acts) or agreed to in writing, shall any Contributor be 159 | liable to You for damages, including any direct, indirect, special, 160 | incidental, or consequential damages of any character arising as a 161 | result of this License or out of the use or inability to use the 162 | Work (including but not limited to damages for loss of goodwill, 163 | work stoppage, computer failure or malfunction, or any and all 164 | other commercial damages or losses), even if such Contributor 165 | has been advised of the possibility of such damages. 166 | 167 | 9. Accepting Warranty or Additional Liability. While redistributing 168 | the Work or Derivative Works thereof, You may choose to offer, 169 | and charge a fee for, acceptance of support, warranty, indemnity, 170 | or other liability obligations and/or rights consistent with this 171 | License. However, in accepting such obligations, You may act only 172 | on Your own behalf and on Your sole responsibility, not on behalf 173 | of any other Contributor, and only if You agree to indemnify, 174 | defend, and hold each Contributor harmless for any liability 175 | incurred by, or claims asserted against, such Contributor by reason 176 | of your accepting any such warranty or additional liability. 177 | 178 | END OF TERMS AND CONDITIONS 179 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | bacula 2 | ============= 3 | 4 | Author: Carl Caum 5 | Copyright (c) 2011, Puppet Labs Inc. 6 | 7 | 8 | ABOUT 9 | ===== 10 | 11 | This module manages [Bacula](http://bacula.org). Through declaration of the `bacula` class, you can configure Directors, Storage Daemons, Clients, and consoles. 12 | 13 | INSTALLATION 14 | ============ 15 | 16 | The module can be obtained from the [Puppet Forge](http://forge.puppetlabs.com/puppetlabs/bacula). Select `Download` which downloads a tar.gz file. Upload the tar.gz file to your Puppet Master. Untar the file. This will create a new directory called `puppetlabs-bacula-${version_number}`. Rename this directory to just **bacula** and place it in your [modulepath](http://docs.puppetlabs.com/learning/modules1.html#modules). 17 | 18 | You can also use the [puppet-module tool](https://github.com/puppetlabs/puppet-module-tool). Just run this command from your modulepath. 19 | `puppet-module install puppetlabs/bacula` 20 | 21 | REQUIREMENTS 22 | ============ 23 | 24 | * Puppet >=2.6 if using parameterized classes 25 | * Puppetlabs/stdlib module. Can be obtained here http://forge.puppetlabs.com/puppetlabs/stdlib or with the command `puppet-module install puppetlabs/stdlib` 26 | * Puppetlabs/mysql module. Can be obtained here http://forge.puppetlabs.com/puppetlabs/mysql or with the command `puppet-module install puppetlabs/mysql` 27 | Declare the mysql::server class to set up a mysql server on the bacula director node and set `manage_db` to true to have bacula manage the mysql database. 28 | * Puppetlabs/sqlite module. Can be obtained here http://forge.puppetlabs.com/puppetlabs/sqlite or with the command `puppet-module install puppetlabs/sqlite` 29 | Declare the mysql::sqlite class so it's available for the bacula class to use. 30 | 31 | 32 | CONFIGURATION 33 | ============= 34 | 35 | There is one class (bacula) that needs to be declared on all nodes managing any component of bacula. 36 | These nodes are configured using one of two methods. 37 | 38 | 1. Using Top Scope (e.g. Dashboard) parameters 39 | 2. Declare the bacula class on node definitions in your manifest. 40 | 41 | NOTE: The two methods can be mixed and matched, but take care not to create the same Top Scope parameter and class parameter simultaneously (See below for class parameters and their matching Top Scope parameter) as you may get unexpected results. 42 | Order of parameter precendence: 43 | 44 | * Class Parameter 45 | * Top Scope Parameter 46 | * Hard Coded value 47 | 48 | Using Top Scope (Dashboard) 49 | --------------------------- 50 | Steps: 51 | 52 | 1. Add the `bacula` class to the nodes or groups you want to manage any bacula component on. 53 | 2. Add the parameters (See below) to the nodes or groups to configure the bacula class 54 | 55 | [Grouping and Classifying Nodes](http://docs.puppetlabs.com/pe/2.0/console_classes_groups.html) 56 | 57 | 58 | Using Parameterized Classes 59 | --------------------------- 60 | Declaration example: 61 | 62 | ```puppet 63 | class { 'bacula': 64 | is_storage => true, 65 | is_director => true, 66 | is_client => true, 67 | manage_console => true, 68 | director_password => 'XXXXXXXXX', 69 | console_password => 'XXXXXXXXX', 70 | director_server => 'bacula.domain.com', 71 | mail_to => 'bacula-admin@domain.com', 72 | storage_server => 'bacula.domain.com', 73 | } 74 | ``` 75 | 76 | [Using Parameterized Classes](http://docs.puppetlabs.com/guides/parameterized_classes.html) 77 | 78 | Parameters 79 | ---------- 80 | 81 | The following lists all the class parameters the bacula class accepts as well as their Top Scope equivalent. 82 | 83 | BACULA CLASS PARAMETER TOP SCOPE EQUIVALENT DESCRIPTION 84 | ------------------------------------------------------------------------- 85 | 86 | COMMON PARAMETERS: 87 | db_backend bacula_db_backend Which database backend system you want to use to store the catalog data 88 | mail_to bacula_mail_to Address to email reports to 89 | is_director bacula_is_director Whether the node should be a director 90 | is_client bacula_is_client Whether the node should be a client 91 | is_storage bacula_is_storage Whether the node should be a storage server 92 | director_password bacula_director_password The director's password 93 | console_password bacula_console_password The console's password 94 | director_server bacula_director_server The FQDN of the bacula director 95 | storage_server bacula_storage_server The FQDN of the storage server 96 | manage_console bacula_manage_console Whether the bconsole should be managed on the node 97 | manage_bat bacula_manage_bat Whether the bat should be managed on the node 98 | clients *See Adding Clients section* 99 | 100 | 101 | UNCOMMON PARAMETERS: 102 | manage_db_tables bacula_manage_db_tables Whether to manage the SQL tables in te database specified in db_backend. Defaults to true 103 | manage_db bacula_manage_db Whether to manage creation of the database specified by db_database. Default to false. In order 104 | for this to work, you must declare the `mysql::server` class 105 | director_package bacula_director_package The name of the package to install the director 106 | storage_package bacula_storage_package The name of the package to install the storage 107 | client_package bacula_client_package The name of the package to install the client 108 | director_sqlite_package bacula_director_sqlite_package The name of the package to install the director's sqlite functionality 109 | storage_sqlite_package bacula_storage_sqlite_package The name of the package to install the storage daemon's sqlite functionality 110 | director_mysql_package bacula_director_mysql_package The name of the package to install the director's mysql functionality 111 | storage_mysql_package bacula_storage_mysql_package The name of the package to install the storage's sqlite functionality 112 | director_template bacula_director_template The ERB template to use for configuring the director instead of the one included with the module 113 | storage_template bacula_storage_template The ERB template to use for configuring the storage daemon instead of the one included with the module 114 | console_template bacula_console_template The ERB template to use for configuring the bconsole instead of the one included with the module 115 | use_console bacula_use_console Whether to configure a console resource on the director 116 | console_password bacula_console_password The password to use for the console resource on the director 117 | 118 | Additionally the following (uncommon) parameters can be passed to the bacula::client class: 119 | 120 | client_conf - File name of bacula-fd configuration file 121 | client_conf_template - Template for bacula-fd configuration file 122 | client_service - The name of bacula-fd service 123 | package_provider - Package provider (for solaris only) 124 | pid_dir - The bacula-fd pid dir 125 | working_dir - The bacula-fd working dir 126 | 127 | 128 | CLIENTS 129 | ======= 130 | 131 | To back up clients on your network, you need to tell the director about them. The director is whichever node you included the 132 | `bacula` class and you specifed the parameter `is_director` to true. The way to add clients is different depending on if 133 | you're using an ENC such as Dashboard or if you're using parameterized classes. Both need to know the parameters of the client 134 | 135 | Client Parameters 136 | ----------------- 137 | 138 | PARAMETERS DESCRIPTION 139 | 140 | fileset Which FileSet to assign to the client 141 | schedule Which schedule to assign to the client 142 | template Which template to use for client config.Default: bacula/client_config.erb 143 | 144 | Using Parameterized Classes 145 | --------------------------- 146 | 147 | The `bacula` class takes a `clients` parameter. The value for `clients` must be a hash with the keys of the hash being 148 | the FQDN of the client. The value of the client needs to be a hash containing the parameters for the client. 149 | 150 | ```puppet 151 | $clients = { 152 | 'node1.domain.com' => { 153 | 'fileset' => 'Basic:noHome', 154 | 'schedule' => 'Weekly', 155 | 'template' => 'bacula/client_config.erb' 156 | } 157 | } 158 | 159 | class { 'bacula': 160 | is_storage => true, 161 | is_director => true, 162 | is_client => true, 163 | manage_console => true, 164 | director_password => 'XXXXXXXXX', 165 | console_password => 'XXXXXXXXX', 166 | director_server => 'bacula.domain.com', 167 | mail_to => 'bacula-admin@domain.com', 168 | storage_server => 'bacula.domain.com', 169 | clients => $clients, 170 | } 171 | ``` 172 | 173 | Using Top Scope (Dashboard) 174 | --------------------------- 175 | 176 | The bacula module will look for parameters of a certain format to build its clients list. For each client, make a parmaeter of this 177 | format: 178 | bacula_client_client1.domain.com 179 | with value: 180 | fileset=MyFileSet,schedule=MySchedule 181 | 182 | 183 | Included FileSets 184 | ================= 185 | 186 | * Basic:noHome: 187 | Include: 188 | * /boot 189 | * /etc 190 | * /usr/local 191 | * /var 192 | * /opt 193 | * /srv 194 | 195 | Exclude: 196 | * /var/cache 197 | * /var/tmp 198 | * /var/lib/apt 199 | * /var/lib/dpkg 200 | * /var/lib/puppet 201 | * /var/lib/mysql 202 | * /var/lib/postgresql 203 | * /var/lib/ldap 204 | * /var/lib/bacula 205 | 206 | * Basic:withHome 207 | Include: 208 | * /home 209 | * /boot 210 | * /etc 211 | * /usr/local 212 | * /var 213 | * /opt 214 | * /srv 215 | 216 | Exclude: 217 | * /var/cache 218 | * /var/tmp 219 | * /var/lib/apt 220 | * /var/lib/dpkg 221 | * /var/lib/puppet 222 | * /var/lib/mysql 223 | * /var/lib/postgresql 224 | * /var/lib/ldap 225 | * /var/lib/bacula 226 | 227 | Included Schedules 228 | ================== 229 | 230 | * WeeklyCycle 231 | * Full First Sun at 23:05 232 | * Differential Second-Fifth Sun at 23:05 233 | * Incremental Mon-Sat at 23:05 234 | 235 | * WeeklyCycleAfterBackup 236 | * Full Mon-Sun at 23:10 237 | 238 | * Weekly:onFriday 239 | * Full First Fri at 18:30 240 | * Differential Second-Fifth Fri at 18:30 241 | * Incremental Sat-Thu at 20:00 242 | 243 | * Weekly:onSaturday 244 | * Full First Sat at 15:30 245 | * Differential Second-Fifth Sat at 15:30 246 | * Incremental Sun-Fri at 20:00 247 | 248 | * Weekly:onSunday 249 | * Full First Sun at 15:30 250 | * Differential Second-Fifth Sun at 15:30 251 | * Incremental Mon-Sat at 20:00 252 | 253 | * Weekly:onMonday 254 | * Full First Mon at 18:30 255 | * Differential Second-Fifth Mon at 18:30 256 | * Incremental Tue-Sun at 20:00 257 | 258 | * Weekly:onTuesday 259 | * Full First Tue at 18:30 260 | * Differential Second-Fifth Tue at 18:30 261 | * Incremental Wed-Mon at 20:00 262 | 263 | * Weekly:onWednesday 264 | * Full First Wed at 18:30 265 | * Differential Second-Fifth Wed at 18:30 266 | * Incremental Thu-Tue at 20:00 267 | 268 | * Weekly:onThursday 269 | * Full First Thu at 18:30 270 | * Differential Second-Fifth Thu at 18:30 271 | * Incremental Fri-Wed at 20:00 272 | 273 | * Hourly 274 | * Incremental hourly at 0:30 275 | 276 | TEMPLATES 277 | ========= 278 | 279 | The Bacula module comes with templates that set default Fileset resources. To configure different Filesets, copy the 280 | bacula-dir.conf.erb file out of the bacula/templates directory to another location in your manifests (can be another 281 | module). Make the modifications you want and set the director_template parameter (listed above) to point to the path where you have 282 | stored the custom template. 283 | 284 | [Using Puppet Templates](http://docs.puppetlabs.com/guides/templating.html) 285 | 286 | SOLARIS SUPPORT 287 | =============== 288 | 289 | Currently this module only configures the Bacula client on Solaris. Bacula Directors and Storage Daemon are not supported yet. 290 | 291 | To use bacula::client with the Solaris CSWbaculaclient package set the following class paramenters: 292 | 293 | ```puppet 294 | class { 'bacula::client': 295 | director_server => 'bacula.domain.com', 296 | director_password => 'xxxxxxx', 297 | client_package => 'CSWbaculaclient', 298 | package_provider => "pkgutil", 299 | client_conf => "/opt/csw/etc/bacula/bacula-fd.conf", 300 | client_service => "cswbacula", 301 | working_dir => "/opt/csw/var/bacula/working", 302 | pid_dir => "/opt/csw/var/bacula/run" 303 | } 304 | ``` 305 | 306 | TODO 307 | ==== 308 | 309 | * Add ability to set custom Filesets for clients. 310 | 311 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'puppetlabs_spec_helper/rake_tasks' 2 | require 'puppet_blacksmith/rake_tasks' 3 | require 'voxpupuli/release/rake_tasks' 4 | require 'rubocop/rake_task' 5 | require 'puppet-strings/rake_tasks' 6 | 7 | RuboCop::RakeTask.new(:rubocop) do |task| 8 | # These make the rubocop experience maybe slightly less terrible 9 | task.options = ['-D', '-S', '-E'] 10 | end 11 | 12 | PuppetLint.configuration.log_format = '%{path}:%{linenumber}:%{check}:%{KIND}:%{message}' 13 | PuppetLint.configuration.fail_on_warnings = true 14 | PuppetLint.configuration.send('relative') 15 | PuppetLint.configuration.send('disable_140chars') 16 | PuppetLint.configuration.send('disable_class_inherits_from_params_class') 17 | PuppetLint.configuration.send('disable_documentation') 18 | PuppetLint.configuration.send('disable_single_quote_string_with_variables') 19 | 20 | exclude_paths = %w( 21 | pkg/**/* 22 | vendor/**/* 23 | .vendor/**/* 24 | spec/**/* 25 | ) 26 | PuppetLint.configuration.ignore_paths = exclude_paths 27 | PuppetSyntax.exclude_paths = exclude_paths 28 | 29 | desc 'Run acceptance tests' 30 | RSpec::Core::RakeTask.new(:acceptance) do |t| 31 | t.pattern = 'spec/acceptance' 32 | end 33 | 34 | desc 'Run tests metadata_lint, lint, syntax, spec' 35 | task test: [ 36 | :metadata_lint, 37 | :lint, 38 | :syntax, 39 | :spec, 40 | ] 41 | # vim: syntax=ruby 42 | -------------------------------------------------------------------------------- /lib/puppet/parser/functions/generate_clients.rb: -------------------------------------------------------------------------------- 1 | module Puppet::Parser::Functions 2 | newfunction(:generate_clients) do |args| 3 | Puppet::Parser::Functions.autoloader.loadall 4 | 5 | # This searches top scope for variables in the style 6 | # $bacula_client_mynode with values in format 7 | # fileset=Basic:noHome,schedule=Hourly 8 | to_hash.each do |variable, value| 9 | next unless variable =~ /^bacula_client_.*$/ 10 | client = variable[14..-1] 11 | 12 | begin 13 | parameters = Hash[value.split(',').map do |val| 14 | val_array = val.split('=', 2) 15 | if val_array.size != 2 16 | raise Puppet::ParseError, 'Could not parse parameters given. Please check your format' 17 | end 18 | if [nil, ''].include?(val_array[0]) || [nil, ''].include?(val_array[1]) 19 | raise Puppet::ParseError, 'Could not parse parameters given. Please check your format' 20 | end 21 | val_array 22 | end] 23 | rescue 24 | raise Puppet::ParseError, 'Could not parse parameters given. Please check your format' 25 | end 26 | 27 | function_create_resources(['bacula::config::client', { client => parameters }]) 28 | end 29 | 30 | begin 31 | function_create_resources(['bacula::config::client', args[0]]) 32 | rescue => e 33 | raise Puppet::ParseError, e 34 | end 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /manifests/bat.pp: -------------------------------------------------------------------------------- 1 | # Class: bacula::bat 2 | # 3 | # This class installs the BAT application for QT supported systems 4 | # 5 | # Actions: 6 | # - Enforce the bacula-console-qt package is installed 7 | # - Enforce /etc/bacula/bat.conf points to /etc/bacula/bconsole.bat 8 | # 9 | # Sample Usage: 10 | # 11 | # class { 'bacula::bat': } 12 | class bacula::bat inherits bacula::console { 13 | 14 | package { 'bacula-console-qt': 15 | ensure => installed, 16 | } 17 | 18 | file { '/etc/bacula/bat.conf': 19 | ensure => 'symlink', 20 | target => 'bconsole.conf', 21 | require => [ Package['bacula-console-qt'], File['/etc/bacula/bconsole.conf'] ], 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /manifests/client.pp: -------------------------------------------------------------------------------- 1 | # Class: bacula::client 2 | # 3 | # This class manages the bacula client (bacula-fd) 4 | # 5 | # Parameters: 6 | # $director_server: 7 | # The FQDN of the bacula director 8 | # $director_password: 9 | # The director's password 10 | # $client_package: 11 | # The name of the package to install the bacula-fd service. 12 | # $client_conf: 13 | # File name of bacula-fd configuration file 14 | # $client_conf_template: 15 | # Template for bacula-fd configuration fie 16 | # $client_service: 17 | # The name of bacula-fd service 18 | # $package_provider: 19 | # Package provider (for solaris only) 20 | # $pid_dir: 21 | # The bacula-fd pid dir 22 | # $working_dir: 23 | # The bacula-fd working dir 24 | # 25 | # Actions: 26 | # - Enforce the $client_package package be installed 27 | # - Manage the /etc/bacula/bacula-fd.conf file 28 | # - Enforce the bacula-fd service to be running 29 | # 30 | # Sample Usage: 31 | # 32 | # class { 'bacula::client': 33 | # director_server => 'bacula.domain.com', 34 | # director_password => 'XXXXXXXXXX', 35 | # client_package => 'bacula-client', 36 | # } 37 | class bacula::client( 38 | $client_conf = '/etc/bacula/bacula-fd.conf', 39 | $client_conf_template = 'bacula/bacula-fd.conf.erb', 40 | $client_package = 'bacula-client', 41 | $client_service = 'bacula-fd', 42 | $director_password, 43 | $director_server, 44 | $package_provider = undef, 45 | $pid_dir = '/var/run/bacula', 46 | $working_dir = '/var/lib/bacula' 47 | ) { 48 | 49 | $director_name_array = split($director_server, '[.]') 50 | $director_name = $director_name_array[0] 51 | 52 | package { $client_package: 53 | ensure => installed, 54 | provider => $package_provider, 55 | } 56 | 57 | file { $client_conf: 58 | ensure => file, 59 | content => template($client_conf_template), 60 | notify => Service[$client_service], 61 | require => Package[$client_package], 62 | } 63 | 64 | service { $client_service: 65 | ensure => running, 66 | enable => true, 67 | require => Package[$client_package], 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /manifests/common.pp: -------------------------------------------------------------------------------- 1 | # Class: bacula::common 2 | # 3 | # This class enforces common resources needed by all 4 | # bacula components 5 | # 6 | # Actions: 7 | # - Enforce the bacula user and groups exist 8 | # - Enforce the /var/spool/bacula is a director and /var/lib/bacula points to it 9 | # 10 | # Sample Usage: 11 | # 12 | # class { 'bacula::common': } 13 | class bacula::common ( 14 | $packages, 15 | $manage_db_tables, 16 | $manage_db = true, 17 | $db_backend, 18 | $db_user, 19 | $db_database, 20 | $db_password, 21 | $db_port, 22 | $db_host, 23 | ) { 24 | 25 | $notify_database = $manage_db_tables ? { 26 | true => Exec['make_db_tables'], 27 | false => undef, 28 | } 29 | 30 | if $packages { 31 | package { $packages: 32 | ensure => installed, 33 | notify => $notify_database, 34 | } 35 | } 36 | 37 | $db_parameters = $db_backend ? { 38 | 'sqlite' => '', 39 | 'mysql' => "--host=${db_host} --user=${db_user} --password=${db_password} --port=${db_port} --database=${db_database}", 40 | } 41 | 42 | if $manage_db_tables { 43 | exec { 'make_db_tables': 44 | command => "/usr/lib/bacula/make_bacula_tables ${db_parameters}", 45 | refreshonly => true, 46 | } 47 | } 48 | 49 | if $manage_db { 50 | 51 | if defined(Class['mysql::server']) { 52 | $mysql_class = 'Class["mysql::server"]' 53 | } else { 54 | $mysql_class = undef 55 | } 56 | 57 | case $db_backend { 58 | 'mysql': { 59 | mysql::db { $db_database: 60 | user => $db_user, 61 | password => $db_password, 62 | host => $db_host, 63 | notify => $notify_database, 64 | require => $mysql_class, 65 | } 66 | } 67 | 68 | 'sqlite': { 69 | sqlite::db { $db_database: 70 | ensure => present, 71 | location => "/var/lib/bacula/${db_database}.db", 72 | owner => 'bacula', 73 | group => 'bacula', 74 | require => File['/var/lib/bacula'], 75 | } 76 | } 77 | 78 | default: { 79 | fail "The bacula module does not support managing the ${db_backend} backend database" 80 | } 81 | } 82 | } 83 | 84 | user { 'bacula': 85 | ensure => present, 86 | gid => 'bacula', 87 | } 88 | 89 | group { 'bacula': 90 | ensure => present, 91 | } 92 | 93 | file { '/etc/bacula/': 94 | ensure => directory, 95 | } 96 | 97 | file { '/var/lib/bacula': 98 | ensure => directory, 99 | owner => bacula, 100 | group => bacula, 101 | } 102 | 103 | file { '/var/spool/bacula': 104 | ensure => directory, 105 | owner => bacula, 106 | group => bacula, 107 | } 108 | 109 | file { '/var/log/bacula': 110 | ensure => directory, 111 | owner => bacula, 112 | group => bacula, 113 | recurse => true, 114 | } 115 | 116 | file { '/var/run/bacula': 117 | ensure => directory, 118 | owner => bacula, 119 | group => bacula, 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /manifests/config.pp: -------------------------------------------------------------------------------- 1 | # Class:: bacula::config 2 | # 3 | # This class determines default values for parameters needed 4 | # to configure the bacula class. It looks for variables in 5 | # top scope (probably from an ENC such as Dashboard). 6 | # If the variable doesn't exist in top scope, fall back to 7 | # a hard coded default. 8 | # 9 | # Some of the variables in this class need to be booleans. 10 | # However, if we get the value from top scope, it could 11 | # be a string since Dashboard can't express booleans. 12 | # So we need to see if it's a string and attempt to 13 | # convert it to a boolean 14 | # 15 | # Sample Usage: 16 | # 17 | # class { 'bacula::config': } 18 | class bacula::config { 19 | 20 | #If we have a top scope variable defined, use it. 21 | #Fall back to a hardcoded value. 22 | # 23 | #Since the top scope variable could be a string 24 | #(if from an ENC), we might need to convert it 25 | #to a boolean 26 | $manage_console = $::bacula_manage_console ? { 27 | undef => false, 28 | default => $::bacula_manage_console, 29 | } 30 | if is_string($manage_console) { 31 | $safe_manage_console = str2bool($manage_console) 32 | } else { 33 | $safe_manage_console = $manage_console 34 | } 35 | 36 | $manage_bat = $::bacula_manage_bat ? { 37 | undef => false, 38 | default => $::bacula_manage_bat, 39 | } 40 | if is_string($manage_bat) { 41 | $safe_manage_bat = str2bool($manage_bat) 42 | } else { 43 | $safe_manage_bat = $manage_bat 44 | } 45 | 46 | 47 | $is_director = $::bacula_is_director ? { 48 | undef => false, 49 | default => $::bacula_is_director, 50 | } 51 | if is_string($is_director) { 52 | $safe_is_director = str2bool($is_director) 53 | } else { 54 | $safe_is_director = $is_director 55 | } 56 | 57 | $is_client = $::bacula_is_client ? { 58 | undef => true, 59 | default => $::bacula_is_client, 60 | } 61 | if is_string($is_client) { 62 | $safe_is_client = str2bool($is_client) 63 | } else { 64 | $safe_is_client = $is_client 65 | } 66 | 67 | $is_storage = $::bacula_is_storage ? { 68 | undef => false, 69 | default => $::bacula_is_storage, 70 | } 71 | if is_string($is_storage) { 72 | $safe_is_storage = str2bool($is_storage) 73 | } else { 74 | $safe_is_storage= $is_storage 75 | } 76 | 77 | $use_console = $::bacula_use_console ? { 78 | undef => false, 79 | default => $::bacula_use_console, 80 | } 81 | if is_string($use_console) { 82 | $safe_use_console = str2bool($use_console) 83 | } else { 84 | $safe_use_console = $use_console 85 | } 86 | 87 | $manage_db = $::bacula_manage_db ? { 88 | undef => false, 89 | default => $::bacula_manage_db, 90 | } 91 | if is_string($manage_db) { 92 | $safe_manage_db = str2bool($manage_db) 93 | } else { 94 | $safe_manage_db = $manage_db 95 | } 96 | 97 | $manage_db_tables = $::bacula_manage_db_tables ? { 98 | undef => true, 99 | default => $::bacula_manage_db_tables, 100 | } 101 | if is_string($manage_db_tables) { 102 | $safe_manage_db_tables = str2bool($manage_db_tables) 103 | } else { 104 | $safe_manage_db_tables = $manage_db_tables 105 | } 106 | 107 | $db_backend = $::bacula_db_backend ? { 108 | undef => 'sqlite', 109 | default => $::bacula_db_backend, 110 | } 111 | 112 | $mail_to = $::bacula_mail_to ? { 113 | undef => "root@${::domain}", 114 | default => $::bacula_mail_to, 115 | } 116 | 117 | $director_password = $::bacula_director_password ? { 118 | undef => false, 119 | default => $::bacula_director_password, 120 | } 121 | 122 | $console_password = $::bacula_console_password ? { 123 | undef => false, 124 | default => $::bacula_console_password, 125 | } 126 | 127 | $director_server = $::bacula_director_server ? { 128 | undef => false, 129 | default => $::bacula_director_server, 130 | } 131 | 132 | $storage_server = $::bacula_storage_server ? { 133 | undef => false, 134 | default => $::bacula_storage_server, 135 | } 136 | 137 | $director_package = $::bacula_director_package ? { 138 | undef => false, # By default, let the db package handle this 139 | default => $::bacula_director_package, 140 | } 141 | 142 | $storage_package = $::bacula_storage_package ? { 143 | undef => false, # By default, let the db package handle this 144 | default => $::bacula_storage_package, 145 | } 146 | 147 | $client_package = $::bacula_client_package ? { 148 | undef => 'bacula-client', 149 | default => $::bacula_client_package, 150 | } 151 | 152 | $director_mysql_package = $::bacula_director_mysql_package ? { 153 | undef => 'bacula-director-mysql', 154 | default => $::bacula_director_mysql_package, 155 | } 156 | 157 | $storage_mysql_package = $::bacula_storage_mysql_package ? { 158 | undef => 'bacula-sd-mysql', 159 | default => $::bacula_storage_mysql_package, 160 | } 161 | 162 | $director_sqlite_package = $::bacula_director_sqlite_package ? { 163 | undef => 'bacula-director-sqlite3', 164 | default => $::bacula_director_sqlite_package, 165 | } 166 | 167 | $storage_sqlite_package = $::bacula_storage_sqlite_package ? { 168 | undef => 'bacula-sd-sqlite3', 169 | default => $::bacula_storage_sqlite_package, 170 | } 171 | 172 | $director_db_package = $::bacula_director_db_package ? { 173 | undef => false, 174 | default => $::bacula_director_db_package, 175 | } 176 | 177 | $console_package = $::bacula_console_package ? { 178 | undef => 'bacula-console', 179 | default => $::bacula_console_package, 180 | } 181 | 182 | $storage_db_package = $::bacula_storage_db_package ? { 183 | undef => false, 184 | default => $::bacula_director_db_package, 185 | } 186 | 187 | $db_user = $::bacula_db_user ? { 188 | undef => false, 189 | default => $::bacula_db_user, 190 | } 191 | 192 | $db_port = $::bacula_db_port ? { 193 | undef => '3306', 194 | default => $::bacula_db_port, 195 | } 196 | 197 | $db_password = $::bacula_db_password ? { 198 | undef => false, 199 | default => $::bacula_db_password, 200 | } 201 | 202 | $db_host = $::bacula_db_host ? { 203 | undef => 'localhost', 204 | default => $::bacula_db_host, 205 | } 206 | 207 | $db_database = $::bacula_db_database ? { 208 | undef => 'bacula', 209 | default => $::bacula_db_database, 210 | } 211 | 212 | $packages = $::bacula_packages ? { 213 | undef => ['bacula-common', 'bacula-client'], 214 | default => $::bacula_packages, 215 | } 216 | 217 | #If it's undef, that's fine 218 | $director_template = $::bacula_director_template 219 | $storage_template = $::bacula_storage_template 220 | $console_template = $::bacula_console_template 221 | } 222 | -------------------------------------------------------------------------------- /manifests/config/client.pp: -------------------------------------------------------------------------------- 1 | define bacula::config::client ( 2 | $fileset = 'Basic:noHome', 3 | $backup_schedule = 'WeeklyCycle', 4 | $template = 'bacula/client_config.erb', 5 | ) { 6 | 7 | if ! is_domain_name($name) { 8 | fail "Name for client ${name} must be a fully qualified domain name" 9 | } 10 | 11 | $name_array = split($name, '[.]') 12 | $hostname = $name_array[0] 13 | 14 | file { "/etc/bacula/bacula-dir.d/${name}.conf": 15 | ensure => file, 16 | content => template($template), 17 | notify => Service['bacula-director'], 18 | require => File['/etc/bacula/bacula-dir.d/'], 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /manifests/config/validate.pp: -------------------------------------------------------------------------------- 1 | # Class: bacula::config::validate 2 | # 3 | # This class takes parameters which values need to be 4 | # validated in some way 5 | class bacula::config::validate( 6 | $db_backend, 7 | $db_database, 8 | $db_port, 9 | $db_host, 10 | $db_user, 11 | $db_password, 12 | $mail_to, 13 | $is_director, 14 | $is_client, 15 | $is_storage, 16 | $director_password, 17 | $console_password, 18 | $director_server, 19 | $storage_server, 20 | $manage_console, 21 | $manage_bat, 22 | $use_console, 23 | $manage_db, 24 | $manage_db_tables 25 | ) { 26 | 27 | #Validate our booleans 28 | validate_bool($manage_console) 29 | validate_bool($manage_bat) 30 | validate_bool($is_director) 31 | validate_bool($is_storage) 32 | validate_bool($is_client) 33 | validate_bool($use_console) 34 | validate_bool($manage_db_tables) 35 | validate_bool($manage_db) 36 | 37 | if $use_console { 38 | if empty($console_password) { 39 | fail 'console_password cannot be empty' 40 | } 41 | } 42 | 43 | #Validate mail_to is an email address 44 | if $is_director { 45 | validate_re($mail_to, '^[\w\.-]+@([\w-]+\.)+[\w-]+$') 46 | } 47 | 48 | #Validate the director and storage servers given are fully qualified domain names 49 | validate_re($director_server, '^[a-z0-9_-]+(\.[a-z0-9_-]+){2,}$') 50 | validate_re($storage_server, '^[a-z0-9_-]+(\.[a-z0-9_-]+){2,}$') 51 | 52 | #Validate server values aren't empty 53 | if empty($director_server) { 54 | fail '$director_server cannot be empty' 55 | } 56 | if empty($storage_server) { 57 | fail '$storage_server cannot be empty' 58 | } 59 | 60 | #Validate the passwords aren't empty 61 | if $is_director { 62 | if empty($director_password) { 63 | fail '$director_password cannot be empty' 64 | } 65 | } 66 | 67 | if $manage_console { 68 | if empty($console_password) { 69 | fail '$console_password cannot be empty' 70 | } 71 | } 72 | 73 | if empty($db_database) { 74 | fail '$db_database cannot be empty' 75 | } 76 | 77 | if $db_backend != 'sqlite' { 78 | if empty($db_host) { 79 | fail '$db_host cannot be empty' 80 | } 81 | if empty($db_user) { 82 | fail '$db_user cannot be empty' 83 | } 84 | if ! is_integer($db_port) { 85 | fail "${db_port} must be a port number" 86 | } 87 | if empty($db_password) { 88 | fail '$db_password cannot be empty' 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /manifests/console.pp: -------------------------------------------------------------------------------- 1 | # Class: bacula::console 2 | # 3 | # This class manages the bconsole application 4 | # 5 | # Parameters: 6 | # $director_server: 7 | # The FQDN of the director 8 | # $director_password: 9 | # The password of the director 10 | # $template: 11 | # The template to use to generate the bconsole.conf file (Optional) 12 | # - Default: 'bacula/bconsole.conf.erb' 13 | # 14 | # Sample Usage: 15 | # 16 | # class { 'bacula::console': 17 | # director_server => 'bacula.domain.com', 18 | # director_password => 'XXXXXXXX', 19 | # } 20 | class bacula::console( 21 | $director_server, 22 | $director_password, 23 | $console_package, 24 | $template = 'bacula/bconsole.conf.erb' 25 | ) { 26 | 27 | if $console_package == '' { 28 | $real_console_package = undef 29 | } else { 30 | $real_console_package = Package['bacula-console'] 31 | } 32 | 33 | 34 | $director_name_array = split($director_server, '[.]') 35 | $director_name = $director_name_array[0] 36 | 37 | if $console_package { 38 | package { $console_package: 39 | ensure => 'latest'; 40 | } 41 | } 42 | 43 | file { '/etc/bacula/bconsole.conf': 44 | ensure => file, 45 | owner => 'bacula', 46 | group => 'bacula', 47 | content => template($template), 48 | require => $real_console_package, 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /manifests/director.pp: -------------------------------------------------------------------------------- 1 | # Class: bacula::director 2 | # 3 | # This class manages the bacula director component 4 | # 5 | # Parameters: 6 | # $server: 7 | # The FQDN of the bacula director 8 | # $password: 9 | # The password of the director 10 | # $db_backend: 11 | # The DB backend to store the catalogs in. (Currently only support sqlite) 12 | # $storage_server: 13 | # The FQDN of the storage daemon server 14 | # $director_package: 15 | # The name of the package that installs the director (Optional) 16 | # $mysql_package: 17 | # The name of the package that installs the mysql support for the director 18 | # $sqlite_package: 19 | # The name of the package that installs the sqlite support for the director 20 | # $template: 21 | # The ERB template to us to generate the bacula-dir.conf file 22 | # - Default: 'bacula/bacula-dir.conf.erb' 23 | # $use_console: 24 | # Whether to manage the Console resource in the director 25 | # $console_password: 26 | # If $use_console is true, then use this value for the password 27 | # 28 | # Sample Usage: 29 | # 30 | # class { 'bacula::director': 31 | # server => 'bacula.domain.com', 32 | # password => 'XXXXXXXXX', 33 | # db_backend => 'sqlite', 34 | # storage_server => 'bacula.domain.com', 35 | # mail_to => 'bacula-admin@domain.com', 36 | # use_console => true, 37 | # console_password => 'XXXXXX', 38 | # } 39 | class bacula::director ( 40 | $server, 41 | $password, 42 | $db_backend, 43 | $db_user, 44 | $db_password, 45 | $db_host, 46 | $db_database, 47 | $db_port, 48 | $storage_server, 49 | $director_package, 50 | $mysql_package, 51 | $mail_to, 52 | $sqlite_package, 53 | $template = 'bacula/bacula-dir.conf.erb', 54 | $use_console, 55 | $console_password, 56 | $clients = {} 57 | ) { 58 | 59 | $storage_name_array = split($storage_server, '[.]') 60 | $director_name_array = split($server, '[.]') 61 | $storage_name = $storage_name_array[0] 62 | $director_name = $director_name_array[0] 63 | 64 | 65 | # This function takes each client specified in $clients 66 | # and generates a bacula::client resource for each 67 | # 68 | # It also searches top scope for variables in the style 69 | # $bacula_client_mynode with values in format 70 | # fileset=Basic:noHome,schedule=Hourly 71 | generate_clients($clients) 72 | 73 | # Only support mysql or sqlite. 74 | # The given backend is validated in the bacula::config::validate class 75 | # before this code is reached. 76 | $db_package = $db_backend ? { 77 | 'mysql' => $mysql_package, 78 | 'sqlite' => $sqlite_package, 79 | } 80 | 81 | if $director_package { 82 | package { $director_package: 83 | ensure => installed, 84 | } 85 | File['/etc/bacula/bacula-dir.conf'] { 86 | require +> Package[$director_package], 87 | } 88 | } 89 | 90 | if $db_package { 91 | package { $db_package: 92 | ensure => installed, 93 | } 94 | } 95 | 96 | # Create the configuration for the Director and make sure the directory for 97 | # the per-Client configuration is created before we run the realization for 98 | # the exported files below 99 | file { '/etc/bacula/bacula-dir.conf': 100 | ensure => file, 101 | owner => 'bacula', 102 | group => 'bacula', 103 | content => template($template), 104 | notify => Service['bacula-director'], 105 | } 106 | 107 | file { '/etc/bacula/bacula-dir.d': 108 | ensure => directory, 109 | owner => 'bacula', 110 | group => 'bacula', 111 | before => Service['bacula-director'], 112 | } 113 | 114 | file { '/etc/bacula/bacula-dir.d/empty.conf': 115 | ensure => file, 116 | before => Service['bacula-director'], 117 | } 118 | 119 | if $db_package == '' { 120 | $real_db_package = undef 121 | } else { 122 | $real_db_package = 'Package[$db_package]' 123 | } 124 | 125 | 126 | # Register the Service so we can manage it through Puppet 127 | service { 'bacula-director': 128 | ensure => running, 129 | enable => true, 130 | hasstatus => true, 131 | hasrestart => true, 132 | require => $real_db_package, 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /manifests/init.pp: -------------------------------------------------------------------------------- 1 | # Class: bacula 2 | # 3 | # This is the main class to manage all the components of a Bacula 4 | # infrastructure. This is the only class that needs to be declared. 5 | # 6 | # Parameters: 7 | # $db_backend: 8 | # The database backend to use 9 | # $mail_to: 10 | # Address to email reports to 11 | # $is_director: 12 | # Whether the node should be a director 13 | # $is_client 14 | # Whether the node should be a client 15 | # $is_storage 16 | # Whether the node should be a storage server 17 | # $director_password 18 | # The director's password 19 | # $console_password 20 | # The console's password 21 | # $director_server 22 | # The FQDN of the bacula director 23 | # $storage_server 24 | # The FQDN of the storage server 25 | # $manage_console 26 | # Whether the bconsole should be managed on the node 27 | # $manage_bat 28 | # Whether the bat should be managed on the node 29 | # $director_package 30 | # The name of the package to install the director 31 | # $storage_package 32 | # The name of the package to install the storage 33 | # $client_package 34 | # The name of the package to install the client 35 | # $director_sqlite_package 36 | # The name of the package to install the director's sqlite functionality 37 | # $storage_sqlite_package 38 | # The name of the package to install the storage daemon's sqlite functionality 39 | # $director_mysql_package 40 | # The name of the package to install the director's mysql functionality 41 | # $storage_mysql_package 42 | # The name of the package to install the storage's sqlite functionality 43 | # $director_template 44 | # The ERB template to use for configuring the director instead of the one included with the module 45 | # $storage_template 46 | # The ERB template to use for configuring the storage daemon instead of the one included with the module 47 | # $console_template 48 | # The ERB template to use for configuring the bconsole instead of the one included with the module 49 | # $use_console 50 | # Whether to configure a console resource on the director 51 | # $console_password 52 | # The password to use for the console resource on the director 53 | # $db_user 54 | # The user to authenticate to $db_db with. 55 | # $db_password 56 | # The password to authenticate $db_user with 57 | # $db_host 58 | # The db server host to connect to 59 | # $db_database 60 | # The db database to connect to on $db_host 61 | # $console_package 62 | # The package to install the bconsole application 63 | # $manage_db_tables 64 | # Whether to create the DB tables during install 65 | # $manage_db 66 | # Whether to manage the existance of the database. If true, the $db_user must have privileges 67 | # to create databases on $db_host 68 | # $clients 69 | # For directors, $clients is a hash of clients. The keys are the clients while the value is a hash of parameters 70 | # The parameters accepted are fileset and schedule. 71 | # 72 | # Example clients hash 73 | # $clients = { 74 | # 'somenode' => { 75 | # 'fileset' => 'Basic:noHome', 76 | # 'schedule' => 'Hourly', 77 | # }, 78 | # 'node2' => { 79 | # 'fileset' => 'Basic:noHome', 80 | # 'schedule' => 'Hourly', 81 | # } 82 | # } 83 | # 84 | # 85 | # Sample Usage 86 | # 87 | # class { 'bacula': 88 | # is_storage => true, 89 | # is_director => true, 90 | # is_client => true, 91 | # manage_console => true, 92 | # director_password => 'xxxxxxxxx', 93 | # console_password => 'xxxxxxxxx', 94 | # director_server => 'bacula.domain.com', 95 | # mail_to => 'bacula-admin@domain.com', 96 | # storage_server => 'bacula.domain.com', 97 | # clients => $clients, 98 | # } 99 | class bacula ( 100 | $db_backend = $bacula::config::db_backend, 101 | $db_user = $bacula::config::db_user, 102 | $db_password = $bacula::config::db_password, 103 | $db_host = $bacula::config::db_host, 104 | $db_database = $bacula::config::db_database, 105 | $db_port = $bacula::config::db_port, 106 | $manage_db = $bacula::config::safe_manage_db, 107 | $manage_db_tables = $bacula::config::safe_manage_db_tables, 108 | $mail_to = $bacula::config::mail_to, 109 | $is_director = $bacula::config::safe_is_director, 110 | $is_client = $bacula::config::safe_is_client, 111 | $is_storage = $bacula::config::safe_is_storage, 112 | $director_password = $bacula::config::director_password, 113 | $console_password = $bacula::config::console_password, 114 | $director_server = $bacula::config::bacula_director_server, 115 | $storage_server = $bacula::config::bacula_storage_server, 116 | $manage_console = $bacula::config::safe_manage_console, 117 | $console_package = $bacula::config::console_package, 118 | $packages = $bacula::config::packages, 119 | $manage_bat = $bacula::config::safe_manage_bat, 120 | $director_package = $bacula::config::director_package, 121 | $storage_package = $bacula::config::storage_package, 122 | $client_package = $bacula::config::client_package, 123 | $director_sqlite_package = $bacula::config::director_sqlite_package, 124 | $storage_sqlite_package = $bacula::config::storage_sqlite_package, 125 | $director_mysql_package = $bacula::config::director_mysql_package, 126 | $storage_mysql_package = $bacula::config::storage_mysql_package, 127 | $director_template = $bacula::config::director_template, 128 | $storage_template = $bacula::config::storage_template, 129 | $console_template = $bacula::config::console_template, 130 | $use_console = $bacula::config::safe_use_console, 131 | $clients = {} 132 | ) inherits bacula::config { 133 | 134 | #Validate our parameters 135 | #It's ugly to do it in the parent class 136 | class { '::bacula::config::validate': 137 | db_backend => $db_backend, 138 | mail_to => $mail_to, 139 | is_director => $is_director, 140 | is_client => $is_client, 141 | is_storage => $is_storage, 142 | director_password => $director_password, 143 | use_console => $use_console, 144 | console_password => $console_password, 145 | director_server => $director_server, 146 | storage_server => $storage_server, 147 | manage_console => $manage_console, 148 | manage_bat => $manage_bat, 149 | db_user => $db_user, 150 | db_password => $db_password, 151 | db_host => $db_host, 152 | db_database => $db_database, 153 | db_port => $db_port, 154 | manage_db_tables => $manage_db_tables, 155 | manage_db => $manage_db, 156 | } 157 | 158 | class { '::bacula::common': 159 | manage_db_tables => $manage_db_tables, 160 | db_backend => $db_backend, 161 | db_user => $db_user, 162 | db_password => $db_password, 163 | db_host => $db_host, 164 | db_database => $db_database, 165 | db_port => $db_port, 166 | packages => $packages, 167 | } 168 | 169 | if $is_director { 170 | class { '::bacula::director': 171 | db_backend => $db_backend, 172 | server => $director_server, 173 | storage_server => $storage_server, 174 | password => $director_password, 175 | mysql_package => $director_mysql_package, 176 | sqlite_package => $director_sqlite_package, 177 | director_package => $director_package, 178 | mail_to => $mail_to, 179 | template => $director_template, 180 | use_console => $use_console, 181 | console_password => $console_password, 182 | db_user => $db_user, 183 | db_password => $db_password, 184 | db_host => $db_host, 185 | db_port => $db_port, 186 | db_database => $db_database, 187 | require => Class['bacula::common'], 188 | clients => $clients, 189 | } 190 | } 191 | 192 | if $is_storage { 193 | class { '::bacula::storage': 194 | db_backend => $db_backend, 195 | director_server => $director_server, 196 | director_password => $director_password, 197 | storage_server => $storage_server, 198 | mysql_package => $storage_mysql_package, 199 | sqlite_package => $storage_sqlite_package, 200 | storage_package => $storage_package, 201 | console_password => $console_password, 202 | template => $storage_template, 203 | require => Class['bacula::common'], 204 | } 205 | } 206 | 207 | if $is_client { 208 | class { '::bacula::client': 209 | director_server => $director_server, 210 | director_password => $director_password, 211 | client_package => $client_package, 212 | require => Class['bacula::common'], 213 | } 214 | } 215 | 216 | if $manage_console { 217 | class { '::bacula::console': 218 | director_server => $director_server, 219 | director_password => $director_password, 220 | console_package => $console_package, 221 | require => Class['bacula::common'], 222 | } 223 | } 224 | 225 | if $manage_bat { 226 | class { '::bacula::bat': 227 | require => Class['bacula::common'], 228 | } 229 | } 230 | } 231 | -------------------------------------------------------------------------------- /manifests/storage.pp: -------------------------------------------------------------------------------- 1 | # Class: bacula::storage 2 | # 3 | # This class manages the bacula storage daemon (bacula-sd) 4 | # 5 | # Parameters: 6 | # $db_backend: 7 | # The database backend to use. (Currently only supports sqlite) 8 | # $director_server: 9 | # The FQDN of the bacula director 10 | # $director_password: 11 | # The director's password 12 | # $storage_server: 13 | # The FQDN of the storage daemon server 14 | # $storage_package: 15 | # The package name to install the storage daemon (Optional) 16 | # $mysql_package: 17 | # The package name to install the storage daemon mysql component 18 | # $sqlite_package: 19 | # The package name to install the storage daemon sqlite component 20 | # $console_password: 21 | # The password for the Console compoenent of the Director service 22 | # $template: 23 | # The tempalte to use for generating the bacula-sd.conf file 24 | # - Default: 'bacula/bacula-sd.conf.erb' 25 | # 26 | # Actions: 27 | # - Enforce the DB compoenent package package be installed 28 | # - Manage the /etc/bacula/bacula-sd.conf file 29 | # - Manage the /mnt/bacula and /mnt/bacula/default directories 30 | # - Manage the /etc/bacula/bacula-sd.conf file 31 | # - Enforce the bacula-sd service to be running 32 | # 33 | # Sample Usage: 34 | # 35 | # class { 'bacula::client': 36 | # director_server => 'bacula.domain.com', 37 | # director_password => 'XXXXXXXXXX', 38 | # client_package => 'bacula-client', 39 | # } 40 | class bacula::storage( 41 | $db_backend, 42 | $director_server, 43 | $director_password, 44 | $storage_server, 45 | $storage_package = '', 46 | $mysql_package, 47 | $sqlite_package, 48 | $console_password, 49 | $template = 'bacula/bacula-sd.conf.erb' 50 | ) { 51 | 52 | $storage_name_array = split($storage_server, '[.]') 53 | $director_name_array = split($director_server, '[.]') 54 | $storage_name = $storage_name_array[0] 55 | $director_name = $director_name_array[0] 56 | 57 | $db_package = $db_backend ? { 58 | 'mysql' => $mysql_package, 59 | 'sqlite' => $sqlite_package, 60 | } 61 | 62 | # This is necessary because the bacula-common package will 63 | # install the bacula-storage-mysql package regardless of 64 | # wheter we're installing the bacula-storage-sqlite package 65 | # This causes the bacula storage daemon to use mysql no 66 | # matter what db backend we want to use. 67 | # 68 | # However, if we install only the db compoenent package, 69 | # it will install the bacula-common package without 70 | # necessarily installing the bacula-storage-mysql package 71 | if $storage_package { 72 | package { $storage_package: 73 | ensure => installed, 74 | } 75 | File['/etc/bacula/bacula-sd.conf'] { 76 | require +> Package[$storage_package], 77 | } 78 | Service['bacula-sd'] { 79 | require +> Package[$storage_package], 80 | } 81 | } 82 | 83 | if $db_package { 84 | package { $db_package: 85 | ensure => installed, 86 | } 87 | } 88 | 89 | if $db_package == '' { 90 | $real_db_package = undef 91 | } else { 92 | $real_db_package = 'Package[$db_package]' 93 | } 94 | 95 | file { '/etc/bacula/bacula-sd.conf': 96 | ensure => file, 97 | owner => 'bacula', 98 | group => 'bacula', 99 | content => template($template), 100 | notify => Service['bacula-sd'], 101 | require => $real_db_package, 102 | } 103 | 104 | file { ['/mnt/bacula', '/mnt/bacula/default']: 105 | ensure => directory, 106 | owner => 'bacula', 107 | group => 'bacula', 108 | mode => '0750', 109 | } 110 | 111 | file { '/etc/bacula/bacula-sd.d': 112 | ensure => directory, 113 | owner => 'bacula', 114 | group => 'bacula', 115 | before => Service['bacula-sd'], 116 | } 117 | 118 | file { '/etc/bacula/bacula-sd.d/empty.conf': 119 | ensure => file, 120 | before => Service['bacula-sd'], 121 | } 122 | 123 | # Register the Service so we can manage it through Puppet 124 | service { 'bacula-sd': 125 | ensure => running, 126 | enable => true, 127 | hasstatus => true, 128 | hasrestart => true, 129 | require => $real_db_package, 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "puppet-bacula", 3 | "version": "0.0.3-rc0", 4 | "source": "https://github.com/voxpupuli/puppet-bacula", 5 | "author": "voxpupuli", 6 | "license": "Apache-2.0", 7 | "summary": "Installs and configures Bacula", 8 | "description": "Installs and configures Bacula", 9 | "project_page": "https://github.com/voxpupuli/puppet-bacula", 10 | "dependencies": [ 11 | { 12 | "name": "puppetlabs/stdlib", 13 | "version_range": ">= 2.2.0" 14 | }, 15 | { 16 | "name": "puppetlabs/mysql", 17 | "version_range": ">= 0.0.1" 18 | }, 19 | { 20 | "name": "puppetlabs/sqlite", 21 | "version_range": ">= 0.0.1" 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /spec/acceptance/bacula_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_acceptance' 2 | 3 | describe 'bacula class' do 4 | describe 'with sample parameters' do 5 | it 'should idempotently run' do 6 | pp = <<-EOS 7 | class { 'bacula': 8 | is_storage => false, 9 | is_director => false, 10 | is_client => true, 11 | manage_console => true, 12 | director_password => 'xxxxxxxxx', 13 | console_password => 'xxxxxxxxx', 14 | director_server => 'bacula.domain.com', 15 | mail_to => 'bacula-admin@domain.com', 16 | storage_server => 'bacula.domain.com', 17 | clients => $clients, 18 | } 19 | EOS 20 | 21 | apply_manifest(pp, catch_failures: true) 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/centos-511-x64.yml: -------------------------------------------------------------------------------- 1 | --- 2 | HOSTS: 3 | centos-511-x64: 4 | roles: 5 | - master 6 | platform: el-5-x86_64 7 | box: puppetlabs/centos-5.11-64-nocm 8 | hypervisor: vagrant 9 | CONFIG: 10 | type: foss 11 | ... 12 | # vim: syntax=yaml 13 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/centos-6-x64.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | centos-6-x64: 3 | roles: 4 | - default 5 | platform: el-6-x86_64 6 | box: puppetlabs/centos-6.6-64-puppet 7 | hypervisor: vagrant 8 | CONFIG: 9 | log_level: verbose 10 | type: foss -------------------------------------------------------------------------------- /spec/acceptance/nodesets/centos-66-x64-pe.yml: -------------------------------------------------------------------------------- 1 | --- 2 | HOSTS: 3 | centos-66-x64: 4 | roles: 5 | - master 6 | - database 7 | - dashboard 8 | platform: el-6-x86_64 9 | box: puppetlabs/centos-6.6-64-puppet-enterprise 10 | hypervisor: vagrant 11 | CONFIG: 12 | type: pe 13 | ... 14 | # vim: syntax=yaml 15 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/centos-66-x64.yml: -------------------------------------------------------------------------------- 1 | --- 2 | HOSTS: 3 | centos-66-x64: 4 | roles: 5 | - master 6 | platform: el-6-x86_64 7 | box: puppetlabs/centos-6.6-64-nocm 8 | hypervisor: vagrant 9 | CONFIG: 10 | type: foss 11 | ... 12 | # vim: syntax=yaml 13 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/centos-7-x64.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | centos-7-x64: 3 | roles: 4 | - default 5 | platform: el-7-x86_64 6 | box: puppetlabs/centos-7.0-64-nocm 7 | hypervisor: vagrant 8 | CONFIG: 9 | log_level: verbose 10 | type: aio -------------------------------------------------------------------------------- /spec/acceptance/nodesets/centos-72-x64.yml: -------------------------------------------------------------------------------- 1 | --- 2 | HOSTS: 3 | centos-72-x64: 4 | roles: 5 | - master 6 | platform: el-7-x86_64 7 | box: puppetlabs/centos-7.2-64-nocm 8 | hypervisor: vagrant 9 | CONFIG: 10 | type: foss 11 | ... 12 | # vim: syntax=yaml 13 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/debian-7-x64.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | debian-7-x64: 3 | roles: 4 | - default 5 | platform: debian-7-x86_64 6 | box: puppetlabs/debian-7.8-64-puppet 7 | hypervisor: vagrant 8 | CONFIG: 9 | log_level: verbose 10 | type: foss -------------------------------------------------------------------------------- /spec/acceptance/nodesets/debian-78-x64.yml: -------------------------------------------------------------------------------- 1 | --- 2 | HOSTS: 3 | debian-78-x64: 4 | roles: 5 | - master 6 | platform: debian-7-amd64 7 | box: puppetlabs/debian-7.8-64-nocm 8 | hypervisor: vagrant 9 | CONFIG: 10 | type: foss 11 | ... 12 | # vim: syntax=yaml 13 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/debian-82-x64.yml: -------------------------------------------------------------------------------- 1 | --- 2 | HOSTS: 3 | debian-82-x64: 4 | roles: 5 | - master 6 | platform: debian-8-amd64 7 | box: puppetlabs/debian-8.2-64-nocm 8 | hypervisor: vagrant 9 | CONFIG: 10 | type: foss 11 | ... 12 | # vim: syntax=yaml 13 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/default.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | ubuntu-1404-x64: 3 | roles: 4 | - default 5 | platform: ubuntu-1404-x86_64 6 | box: puppetlabs/ubuntu-14.04-64-puppet 7 | hypervisor: vagrant 8 | CONFIG: 9 | log_level: verbose 10 | type: foss -------------------------------------------------------------------------------- /spec/acceptance/nodesets/ubuntu-server-1204-x64.yml: -------------------------------------------------------------------------------- 1 | --- 2 | HOSTS: 3 | ubuntu-server-1204-x64: 4 | roles: 5 | - master 6 | platform: ubuntu-12.04-amd64 7 | box: puppetlabs/ubuntu-12.04-64-nocm 8 | hypervisor: vagrant 9 | CONFIG: 10 | type: foss 11 | ... 12 | # vim: syntax=yaml 13 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/ubuntu-server-1404-x64.yml: -------------------------------------------------------------------------------- 1 | --- 2 | HOSTS: 3 | ubuntu-server-1404-x64: 4 | roles: 5 | - master 6 | platform: ubuntu-14.04-amd64 7 | box: puppetlabs/ubuntu-14.04-64-nocm 8 | hypervisor: vagrant 9 | CONFIG: 10 | type: foss 11 | ... 12 | # vim: syntax=yaml 13 | -------------------------------------------------------------------------------- /spec/classes/bacula_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'bacula' do 4 | context 'with default parameters' do 5 | let(:params) { 6 | { 7 | is_storage: true, 8 | is_director: true, 9 | is_client: true, 10 | manage_console: true, 11 | director_password: 'XXXXXXXXX', 12 | console_password: 'XXXXXXXXX', 13 | director_server: 'bacula.domain.com', 14 | mail_to: 'bacula-admin@domain.com', 15 | storage_server: 'bacula.domain.com', 16 | } 17 | } 18 | 19 | let(:facts) { 20 | { 21 | bacula_manage_console: '', 22 | bacula_manage_bat: '', 23 | bacula_is_director: '', 24 | bacula_is_client: '', 25 | bacula_is_storage: '', 26 | bacula_use_console: '', 27 | bacula_manage_db: '', 28 | bacula_manage_db_tables: '', 29 | bacula_db_backend: 'mysql', 30 | bacula_mail_to: '', 31 | bacula_director_password: '', 32 | bacula_console_password: '', 33 | bacula_director_server: '', 34 | bacula_storage_server: '', 35 | bacula_director_package: 'bacula-director', 36 | bacula_storage_package: 'bacula-storage', 37 | bacula_client_package: 'bacula-client', 38 | bacula_director_sqlite_package: '', 39 | bacula_storage_sqlite_package: '', 40 | bacula_director_mysql_package: '', 41 | bacula_storage_mysql_package: '', 42 | bacula_director_template: '', 43 | bacula_storage_template: '', 44 | bacula_console_template: '', 45 | bacula_director_db_package: '', 46 | bacula_console_package: '', 47 | bacula_storage_db_package: '', 48 | bacula_db_user: 'root', 49 | bacula_db_port: '3306', 50 | bacula_db_password: 'fakepw', 51 | bacula_db_host: 'localhost', 52 | bacula_db_database: 'testdb', 53 | bacula_packages: 'bacula-console', 54 | } 55 | } 56 | it { should contain_class('bacula') } 57 | it { should contain_class('bacula::common') } 58 | it { should contain_class('bacula::config') } 59 | it { should contain_class('bacula::config::validate') } 60 | it { should contain_class('bacula::director') } 61 | it { should contain_class('bacula::storage') } 62 | it { should contain_class('bacula::client') } 63 | it { should contain_class('bacula::console') } 64 | 65 | it { should contain_exec('make_db_tables') } 66 | 67 | it { should contain_file '/etc/bacula/' } 68 | it { should contain_file '/etc/bacula/bacula-dir.conf' } 69 | it { should contain_file '/etc/bacula/bacula-dir.d/empty.conf' } 70 | it { should contain_file '/etc/bacula/bacula-dir.d' } 71 | it { should contain_file '/etc/bacula/bacula-fd.conf' } 72 | it { should contain_file '/etc/bacula/bacula-sd.conf' } 73 | it { should contain_file '/etc/bacula/bacula-sd.d/empty.conf' } 74 | it { should contain_file '/etc/bacula/bacula-sd.d' } 75 | it { should contain_file '/etc/bacula/bconsole.conf' } 76 | it { should contain_file '/mnt/bacula' } 77 | it { should contain_file '/mnt/bacula/default' } 78 | it { should contain_file '/var/lib/bacula' } 79 | it { should contain_file '/var/log/bacula' } 80 | it { should contain_file '/var/run/bacula' } 81 | it { should contain_file '/var/spool/bacula' } 82 | 83 | it { should contain_group 'bacula' } 84 | 85 | it { should contain_package 'bacula-client' } 86 | it { should contain_package 'bacula-console' } 87 | it { should contain_package 'bacula-director-sqlite3' } 88 | it { should contain_package 'bacula-sd-sqlite3' } 89 | 90 | it { should contain_service 'bacula-director' } 91 | it { should contain_service 'bacula-fd' } 92 | it { should contain_service 'bacula-sd' } 93 | 94 | it { should contain_user 'bacula' } 95 | end 96 | end 97 | -------------------------------------------------------------------------------- /spec/classes/coverage_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rspec-puppet' 2 | 3 | at_exit { RSpec::Puppet::Coverage.report! } 4 | # vim: syntax=ruby 5 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'puppetlabs_spec_helper/module_spec_helper' 2 | require 'rspec-puppet-facts' 3 | include RspecPuppetFacts 4 | # vim: syntax=ruby 5 | -------------------------------------------------------------------------------- /spec/spec_helper_acceptance.rb: -------------------------------------------------------------------------------- 1 | require 'beaker-rspec/spec_helper' 2 | require 'beaker-rspec/helpers/serverspec' 3 | 4 | hosts.each do |host| 5 | # Install Puppet 4 on CentOS 7 6 | if host['platform'] =~ /el-7/ 7 | on host, 'yum install -y http://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm' 8 | on host, 'yum install -y install puppet-agent' 9 | else 10 | # Install Puppet 3.x on any other OS 11 | install_puppet 12 | end 13 | end 14 | 15 | RSpec.configure do |c| 16 | # Project root 17 | proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) 18 | 19 | # Readable test descriptions 20 | c.formatter = :documentation 21 | 22 | # Configure all nodes in nodeset 23 | c.before :suite do 24 | # Install module and dependencies 25 | puppet_module_install(source: proj_root, module_name: 'bacula') 26 | hosts.each do |host| 27 | on host, puppet('module', 'install', 'puppetlabs-stdlib'), acceptable_exit_codes: [0, 1] 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /templates/bacula-dir.conf.erb: -------------------------------------------------------------------------------- 1 | # DO NOT EDIT - Managed by Puppet 2 | # 3 | # Bacula Director Master Configuration 4 | # for <%= @director_name %> 5 | 6 | # Define the name of this director so other clients can 7 | # connect to it and work with our system 8 | Director { 9 | Name = "<%= @director_name -%>:director" 10 | Query File = "/etc/bacula/scripts/query.sql" 11 | Working Directory = "/var/lib/bacula" 12 | PID Directory = "/var/run/bacula" 13 | Maximum Concurrent Jobs = 5 14 | Password = "<%= @password -%>" 15 | Messages = "<%= @director_name -%>:messages:daemon" 16 | } 17 | 18 | # This is where the catalog information will be stored (basically 19 | # this should be how to connect to whatever database we're using) 20 | Catalog { 21 | Name = "<%= @director_name -%>:<%= @db_backend -%>" 22 | dbname = "<%= @db_database -%>"; dbdriver = dbi:<%= @db_backend %> 23 | <% unless @db_backend == 'sqlite' -%> 24 | dbaddress = <%= @db_host %>; dbport = <%= @db_port %>; user = <%= @db_user %>; password = <%= @db_password %> 25 | <% end %> 26 | } 27 | 28 | # Configure how the directory will log and/or send messages. This 29 | # should should be for just about everything. 30 | Messages { 31 | Name = "<%= @director_name -%>:messages:standard" 32 | Mail Command = "/usr/lib/bacula/bsmtp -h localhost -f bacula@<%= @domain -%> -s \"Bacula %t %e (for %c)\" %r" 33 | Operator Command = "/usr/lib/bacula/bsmtp -h localhost -f bacula@<%= @domain -%> -s \"Bacula Intervention Required (for %c)\" %r" 34 | Mail = <%= @mail_to -%> = all, !skipped 35 | Operator = <%= @mail_to -%> = mount 36 | Console = all, !skipped, !saved 37 | # WARNING! the following will create a file that you must cycle from 38 | # time to time as it will grow indefinitely. However, it will 39 | # also keep all your messages if they scroll off the console. 40 | Append = "/var/log/bacula/<%= @director_name -%>:director.log" = all, !skipped 41 | Catalog = all 42 | } 43 | 44 | # These are messages directly from the various daemons themselves. 45 | Messages { 46 | Name = "<%= @director_name -%>:messages:daemon" 47 | Mail Command = "/usr/lib/bacula/bsmtp -h localhost -f bacula@<%= @domain -%> -s \"Bacula Notice (from Director %d)\" %r" 48 | Mail = <%= @mail_to -%> = all, !skipped 49 | Console = all, !skipped, !saved 50 | Append = "/var/log/bacula/<%= @director_name -%>:director.log" = all, !skipped 51 | } 52 | 53 | <% if @use_console -%> 54 | # Restricted console used by tray-monitor to get the status of the director 55 | Console { 56 | Name = "<%= @director_name -%>:monitor:director" 57 | Password = "<%= @console_password -%>" 58 | CommandACL = status, .status 59 | } 60 | <% end -%> 61 | 62 | # DEFAULT STORAGE SERVER ------------------------------------------------------ 63 | # All the clients will define their own Storage Daemon configuration as they 64 | # will connect to a dedicated File device on that director_name (to aid Pool & Volume 65 | # management along with concurrent access). This section will define a default 66 | # Storage Daemon to connect to (using the standard FileStorage device) and a 67 | # Pool which will be used with that as well. 68 | Storage { 69 | Name = "<%= @storage_name -%>:storage:default" 70 | Address = <%= @storage_name %> 71 | Password = "<%= @password -%>" 72 | Device = "FileStorage" 73 | Media Type = File 74 | } 75 | 76 | Pool { 77 | Name = "<%= @storage_name -%>:pool:default" 78 | # All Volumes will have the format standard.date.time to ensure they 79 | # are kept unique throughout the operation and also aid quick analysis 80 | # We won't use a counter format for this at the moment. 81 | Label Format = "${Job}.${Year}${Month:p/2/0/r}${Day:p/2/0/r}.${Hour:p/2/0/r}${Minute:p/2/0/r}" 82 | Pool Type = Backup 83 | # Clean up any we don't need, and keep them for a maximum of a month (in 84 | # theory the same time period for weekly backups from the clients) 85 | Recycle = Yes 86 | Auto Prune = Yes 87 | Volume Retention = 1 Week 88 | # Don't allow re-use of volumes; one volume per job only 89 | Maximum Volume Jobs = 1 90 | } 91 | 92 | Pool { 93 | Name = "<%= @storage_name -%>:pool:catalog" 94 | # All Volumes will have the format director.catalog.date.time to ensure they 95 | # are kept unique throughout the operation and also aid quick analysis 96 | Label Format = "<%= @director_name -%>.catalog.${Counter<%= @server.capitalize -%>Catalog+:p/3/0/r}" 97 | Pool Type = Backup 98 | # Clean up any we don't need, and keep them for a maximum of a month (in 99 | # theory the same time period for weekly backups from the clients) 100 | Recycle = Yes 101 | Auto Prune = Yes 102 | # We have no limit on the number of volumes, but we will simply set that 103 | # we should keep at least three days worth of backups of the database 104 | Volume Retention = 3 Days 105 | # Don't allow re-use of volumes; one volume per job only 106 | Maximum Volume Jobs = 1 107 | } 108 | 109 | # Create a Counter which will be used to label the catalog volumes on the sytem 110 | Counter { 111 | Name = "Counter<%= @server.capitalize -%>Catalog" 112 | Minimum = 1 113 | Catalog = "<%= @director_name -%>:<%= @db_backend %>" 114 | } 115 | 116 | # FILE SETS ------------------------------------------------------------------- 117 | # Define the standard set of locations which which will be backed up (along 118 | # what within those should not be). In general, we have two types: 119 | # 120 | # Basic:noHome This doesn't back up the /home directory as its mounted 121 | # from an NFS director_name on the network (this is the default). 122 | # Basic:withHome This one does for servers where we don't mount NFS on it. 123 | 124 | FileSet { 125 | Name = "Basic:noHome" 126 | Include { 127 | Options { 128 | Signature = MD5 129 | Compression = GZIP 130 | } 131 | 132 | # Don't worry about most of the director_name as Puppet manages the 133 | # configuration. Ensure that per-machine state files or settings 134 | # are backed up, along with stuff from /var or /srv which should be 135 | # most service-related files 136 | File = /boot 137 | File = /etc 138 | File = /usr/local 139 | File = /var 140 | File = /opt 141 | File = /srv 142 | # /home will not be backed up on any normal director_name as it's managed from 143 | # a central file-server for most servers. 144 | } 145 | 146 | Exclude { 147 | # Ignore stuff that can be ignored 148 | File = /var/cache 149 | File = /var/tmp 150 | # The state of the packages installed, or their files, etc. 151 | # can be ignored as we use puppet to rebuild much of the server 152 | File = /var/lib/apt 153 | File = /var/lib/dpkg 154 | File = /var/lib/puppet 155 | # Ignore database stuff; this will need to be handled 156 | # using some sort of a dump script 157 | File = /var/lib/mysql 158 | File = /var/lib/postgresql 159 | File = /var/lib/ldap 160 | # Bacula's state files are no use to us on restore 161 | File = /var/lib/bacula 162 | } 163 | } 164 | 165 | FileSet { 166 | Name = "Basic:withHome" 167 | Include { 168 | Options { 169 | Signature = SHA1 170 | Compression = GZIP 171 | } 172 | 173 | File = /boot 174 | File = /etc 175 | File = /usr/local 176 | File = /var 177 | File = /opt 178 | File = /srv 179 | # This set does include /home 180 | File = /home 181 | } 182 | 183 | Exclude { 184 | File = /var/cache 185 | File = /var/tmp 186 | File = /var/lib/apt 187 | File = /var/lib/dpkg 188 | File = /var/lib/puppet 189 | File = /var/lib/mysql 190 | File = /var/lib/postgresql 191 | File = /var/lib/ldap 192 | File = /var/lib/bacula 193 | } 194 | } 195 | 196 | # This set is specifically for Bacula to allow it to backup its own internal 197 | # cataloge as part of the normal process. 198 | FileSet { 199 | Name = "Catalog" 200 | Include { 201 | Options { 202 | Signature = SHA1 203 | Compression = GZIP 204 | } 205 | File = "/var/lib/bacula/bacula.sql" 206 | } 207 | } 208 | 209 | 210 | # SCHEDULE -------------------------------------------------------------------- 211 | # Define when jobs should be run, and what Levels of backups they will be when 212 | # they are run. 213 | 214 | # These two are the default backup schedule; don't change them 215 | Schedule { 216 | Name = "WeeklyCycle" 217 | Run = Level=Full First Sun at 23:05 218 | Run = Level=Differential Second-Fifth Sun at 23:05 219 | Run = Level=Incremental Mon-Sat at 23:05 220 | } 221 | 222 | Schedule { 223 | Name = "WeeklyCycleAfterBackup" 224 | Run = Level=Full Mon-Sun at 23:10 225 | } 226 | 227 | # These cycles are set up so that we can spread out the full backups of our 228 | # servers across the week. Some at the weekend, some mid-week. 229 | Schedule { 230 | Name = "Weekly:onFriday" 231 | Run = Level=Full First Fri at 18:30 232 | Run = Level=Differential Second-Fifth Fri at 18:30 233 | Run = Level=Incremental Sat-Thu at 20:00 234 | } 235 | 236 | Schedule { 237 | Name = "Weekly:onSaturday" 238 | # Because this is a weekend job, we'll start the full runs earlier 239 | Run = Level=Full First Sat at 15:30 240 | Run = Level=Differential Second-Fifth Sat at 15:30 241 | Run = Level=Incremental Sun-Fri at 20:00 242 | } 243 | 244 | Schedule { 245 | Name = "Weekly:onSunday" 246 | # Because this is a weekend job, we'll start the full runs earlier 247 | Run = Level=Full First Sun at 15:30 248 | Run = Level=Differential Second-Fifth Sun at 15:30 249 | Run = Level=Incremental Mon-Sat at 20:00 250 | } 251 | 252 | Schedule { 253 | Name = "Weekly:onMonday" 254 | Run = Level=Full First Mon at 18:30 255 | Run = Level=Differential Second-Fifth Mon at 18:30 256 | Run = Level=Incremental Tue-Sun at 20:00 257 | } 258 | 259 | Schedule { 260 | Name = "Weekly:onTuesday" 261 | Run = Level=Full First Tue at 18:30 262 | Run = Level=Differential Second-Fifth Tue at 18:30 263 | Run = Level=Incremental Wed-Mon at 20:00 264 | } 265 | 266 | Schedule { 267 | Name = "Weekly:onWednesday" 268 | Run = Level=Full First Wed at 18:30 269 | Run = Level=Differential Second-Fifth Wed at 18:30 270 | Run = Level=Incremental Thu-Tue at 20:00 271 | } 272 | 273 | Schedule { 274 | Name = "Weekly:onThursday" 275 | Run = Level=Full First Thu at 18:30 276 | Run = Level=Differential Second-Fifth Thu at 18:30 277 | Run = Level=Incremental Fri-Wed at 20:00 278 | } 279 | 280 | Schedule { 281 | Name = "Hourly" 282 | Run = Level=Incremental hourly at 0:30 283 | } 284 | 285 | # JOB DEFINITIONS ------------------------------------------------------------- 286 | # Create the types of jobs we need to run. 287 | 288 | # Create a standard profile for all normal servers 289 | <% 290 | ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'].each do |onDay| 291 | ['noHome','withHome'].each do |doHome| -%> 292 | JobDefs { 293 | Name = "Basic:<%= doHome -%>:on<%= onDay -%>" 294 | Type = Backup 295 | Level = Incremental 296 | FileSet = "Basic:<%= doHome -%>" 297 | Schedule = "Weekly:on<%= onDay -%>" 298 | Messages = "<%= @director_name -%>:messages:standard" 299 | # Set the job to work as standard with the default Pool & Storage 300 | # (this will be overridden by the Job configuration for each Client) 301 | Storage = "<%= @storage_name -%>:storage:default" 302 | Pool = "<%= @storage_name -%>:pool:default" 303 | Write Bootstrap = "/var/lib/bacula/%c.bsr" 304 | Priority = 15 305 | # Define how long any of these jobs are allowed to run for before we should 306 | # kill them. Note that this is the run time (how long the actual backup is 307 | # running for after starting, and not a maximum time after it was scheduled) 308 | Full Max Run Time = 36 Hours 309 | Differential Max Run Time = 6 Hours 310 | Incremental Max Run Time = 6 Hours 311 | } 312 | <% end 313 | end %> 314 | 315 | # Finally, bring in all the additional pieces of configuration from the 316 | # different servers for which this Director was configured to manage 317 | @|"sh -c 'for f in /etc/bacula/bacula-dir.d/*.conf ; do echo @${f} ; done'" 318 | -------------------------------------------------------------------------------- /templates/bacula-fd.conf.erb: -------------------------------------------------------------------------------- 1 | # DO NOT EDIT - Managed by Puppet 2 | # 3 | # Bacula File Daemon Configuration 4 | # for <%= @hostname.split('.').first %> 5 | # via <%= @director_server -%>:director (<%= @director_server -%>) 6 | 7 | # Configure the Director which will manage this host's backups 8 | Director { 9 | Name = "<%= @director_name -%>:director" 10 | Password = "<%= @director_password -%>" 11 | } 12 | 13 | # Now configure the actual File Daemon 14 | FileDaemon { 15 | Name = "<%= @hostname.split('.').first -%>" 16 | Working Directory = <%= @working_dir %> 17 | PID Directory = <%= @pid_dir %> 18 | Maximum Concurrent Jobs = 3 19 | } 20 | 21 | # Finally, set where the messages are going to go 22 | Messages { 23 | Name = "<%= @director_name -%>:messages:standard" 24 | Director = "<%= @director_name -%>:director" = all, !skipped, !restored 25 | } 26 | -------------------------------------------------------------------------------- /templates/bacula-sd.conf.erb: -------------------------------------------------------------------------------- 1 | # DO NOT EDIT - Managed by Puppet 2 | # 3 | # Bacula Storage Daemon Configuration 4 | # for <%= @storage_name %> 5 | # via <%= @director_name -%>:director (<%= @director_name -%>) 6 | 7 | # Configure the Director which will manage this Storage Daemon, and the 8 | # Director through which we'll send our messages (will be the same) one. 9 | Director { 10 | Name = "<%= @director_name -%>:director" 11 | Password = "<%= @director_password -%>" 12 | } 13 | 14 | Messages { 15 | Name = "<%= @storage_name -%>:messages:standard" 16 | Director = "<%= @director_name -%>:director" = all 17 | } 18 | 19 | # Configure the basic details for the Storage Daemon on this server 20 | Storage { 21 | Name = "<%= @storage_name -%>:storage" 22 | Working Directory = "/var/lib/bacula" 23 | PID Directory = "/var/run/bacula" 24 | Maximum Concurrent Jobs = 20 25 | } 26 | 27 | # Also configure access for something to monitor this Storage Daemon 28 | Director { 29 | Name = "<%= @storage_name -%>:monitor:storage" 30 | Password = "<%= @console_password -%>" 31 | Monitor = Yes 32 | } 33 | 34 | # Not configure the default Device this Storage Daemon will provide 35 | Device { 36 | Name = "FileStorage" 37 | Media Type = File 38 | Archive Device = /mnt/bacula/default 39 | Label Media = Yes 40 | Random Access = Yes 41 | Automatic Mount = Yes 42 | Removable Media = No 43 | Always Open = No 44 | } 45 | 46 | # All other Devices are created by the clients that need them - each will 47 | # prepare their own device and pool configuration, which will then be 48 | # saved under /etc/bacula/bacula-sd.d and imported by the following line: 49 | @|"sh -c 'for f in /etc/bacula/bacula-sd.d/*.conf ; do echo @${f} ; done'" 50 | -------------------------------------------------------------------------------- /templates/bconsole.conf.erb: -------------------------------------------------------------------------------- 1 | # DO NOT EDIT - Managed by Puppet 2 | # 3 | # Bacula Console Configuration 4 | # for <%= @fqdn %> 5 | # to <%= @director_name -%>:director (<%= @director_server -%>) 6 | 7 | Director { 8 | Name = "<%= @director_name -%>:monitor:director" 9 | Address = <%= @director_server %> 10 | Password = "<%= @director_password -%>" 11 | } 12 | -------------------------------------------------------------------------------- /templates/client_config.erb: -------------------------------------------------------------------------------- 1 | Client { 2 | Name = "<%= @hostname %>" 3 | Address = "<%= @name %>" 4 | Password = "<%= scope.lookupvar('bacula::director::password') %>" 5 | Catalog = "<%= scope.lookupvar('bacula::director::director_name') %>:<%= scope.lookupvar('bacula::director::db_backend') %>" 6 | File Retention = 6 Weeks 7 | Job Retention = 1 Year 8 | Auto Prune = Yes 9 | } 10 | 11 | Job { 12 | Name = "<%= hostname %>" 13 | Client = "<%= hostname %>" 14 | Type = Backup 15 | FileSet = "<%= fileset %>" 16 | Storage = "<%= scope.lookupvar('bacula::director::storage_name') %>:storage:default" 17 | Schedule = "<%= @backup_schedule %>" 18 | Pool = "<%= scope.lookupvar('bacula::director::storage_name') %>:pool:default" 19 | Messages = "<%= scope.lookupvar('bacula::director::director_name') %>:messages:standard" 20 | } 21 | -------------------------------------------------------------------------------- /tests/init.pp: -------------------------------------------------------------------------------- 1 | class { '::bacula': 2 | is_storage => true, 3 | is_director => true, 4 | is_client => true, 5 | manage_console => true, 6 | director_password => 'XXXXXXXXX', 7 | console_password => 'XXXXXXXXX', 8 | director_server => 'bacula.domain.com', 9 | mail_to => 'bacula-admin@domain.com', 10 | storage_server => 'bacula.domain.com', 11 | } 12 | --------------------------------------------------------------------------------