znapzend
Version information
This version is compatible with:
- Puppet Enterprise 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x, 2018.1.x, 2017.3.x, 2017.2.x, 2017.1.x, 2016.5.x, 2016.4.x
- Puppet >= 4.7.0 < 7.0.0
- , , ,
Start using this module
Add this module to your Puppetfile:
mod 'millerjl1701-znapzend', '1.1.0'
Learn more about managing modules with a PuppetfileDocumentation
znapzend
Table of Contents
- Module Description - What the module does and why it is useful
- Setup - The basics of getting started with znapzend
- Usage - Configuration options and additional functionality
- Reference - An under-the-hood peek at what the module is doing and how
- Limitations - OS compatibility, etc.
- Development - Guide for contributing to the module
Module Description
This module installs, configures, and manages the znapzend service on CentOS 6 and 7. For znapzend to function properly, zfs needs to be installed and zpools with appropriate zfs file systems need to be created.
This module does not manage zfs installation. For this please consider using the bodgit/zfs puppet module.
This module does not manage creation of zfs file systems or zpools. Puppet provides zfs and zpool resource types which could be used for management of these resources.
The documentation for znapzend can be found in the code repository: https://github.com/oetiker/znapzend. The methods for installation of znapzend in this module mirror the methods documented in the repository; however, it is possible to change what is installed in for prerequisites if needed. For example, if instead of installing perl-core as the documentation states, one could pass an array of perl RPMs instead for a smaller installation footprint. The znapzend code supports other operating systems; however, support in this module for those other opererating systems is not included (pull requests are welcome) at this time.
Configuration of znapzend backup plans may be managed using the either the import define type or imports class. Management of the backup plans uses configuration files and the znapzendzetup import
command to write the backup plan into the zfs file system properties for the znapzend service to use. If you would prefer to manage each zfs file system property for znapzend directly instead of using the method of import provided here, consider using either the ggrant/znapzend or the cais/znapzend puppet module instead.
Note: no validation of the znapzend backup plans is made in this module. If invalid parameters are passed to the template, it will fail to be imported by the znapzendzetup
command.
Setup
What znapzend affects
- Yumrepo: epel via the epel class (enabled by default, but may be disabled with the manage_epel parameter)
- Packages: gcc, gcc-g++ (enabled by default, but may be disabled with the manage_gcc parameter)
- Package: mbuffer (enabled by default, but may be disabled with the manage_mbuffer parameter)
- Package: perl-core (enabled by default, but may be disagled with the manage_perl parameter)
- File: /usr/local/src/znapzend-versionnumber Extracted archive location for building the binaries. Archive extraction may be targeted to a different location if desired.
- File: /opt/znapzend-versionnumber Location for installation which may be set to a different location if desired.
- File: /usr/local/bin/znapzend Link to the appropriate binary version. Link location can be placed in a different directory if desired.
- File: /usr/local/bin/znapzendzetup Link to the approriate binary version. Link location can be placed in a different directory if desired.
- File: /usr/local/bin/znapzendztatz Link to the appropriate binary version. Link location can be placed in a different directory if desired.
- File: /etc/default/znapzend
- File: /etc/znapzend/configs Directory for where backup plan configuration files are placed. A different location may be used if needed.
- File: /etc/init.d/znapzend (CentOS 6)
- File: /etc/systemd/system/znapzend.service (CentOS 7)
- Service: znapzend
Setup Requirements
This module relies on other Puppet modules for functionality:
- camptocamp/systemd for systemd service management.
- puppet/archive for downloading and extracting the source code tar.gz file.
- puppetlabs/stdlib
- stahnma/epel for setting up the EPEL repository for use.
Since this module installz znapzend from source, there are pieces needed to generate the binaries (gcc, perl-core, etc.). Parameters have been provided to disable these pieces if you already have them declared in different other puppet code to prevent resource duplication.
Beginning with znapzend
include znapzend
is all that is needed to install and configure the znapzend service. However, if zfs is not installed or if there are no zfs file systems, the service startup will likely fail.
Usage
All parameters to the main class may be passed via puppet code or hiera.
Note: the Puppet lookup function will by default create a merged hash for parameter znapzend::imports::plans
. It is possible to override the merge behavior in your own hiera data; however, this has not been tested and could create unanticipated results.
Another note: no validation of the znapzend backup plans is made in this module. If invalid parameters are passed to the template, it will fail to be imported by the znapzendzetup
command.
Some futher examples that one could do with the class.
Use of the class with EPEL repository not being managed
class { 'znapzend':
manage_epel => false,
}
Use of the class without managing gcc since it is added to the system by some other means
class { 'znapzend':
manage_gcc => false,
}
Use of the class and the defined type for management of a znapzend backup plan for an existing tank/home zfs file system
class { 'znapzend': }
znapzend::import { 'tank/home':
options => {
enabled => 'on',
src => 'tank/home',
src_plan => '7d=>1h,30d=>4h,90d=>1d',
dst_0 => 'backup/home',
dst_0_plan => '7d=>1h,30d=>4h,90d=>1d,1y=>1w,10y=>1month',
mbuffer => 'off',
mbuffer_size => '1G',
post_znap_cmd => 'off',
pre_znap_cmd => 'off',
recursive => 'off',
tsformat => '%Y-%m-%d-%H%M%S',
},
}
Note: The name of the resource should be the zfs file system name and not the mount point of the file system.
Use of hiera and the imports class for creating the same backup plan as in the previous example.
---
znapzend::imports::plans:
'tank/home':
enabled: 'on'
src: 'tank/home'
src_plan: '7d=>1h,30d=>4h,90d=>1d'
dst_0: 'backup/home'
dst_0_plan: '7d=>1h,30d=>4h,90d=>1d,1y=>1w,10y=>1month'
mbuffer: 'off'
mbuffer_size: '1G'
post_znap_cmd: 'off'
pre_znap_cmd: 'off'
recursive: 'off'
tsformat: '%Y-%m-%d-%H%M%S'
Use of the class without purging the /etc/znapzend and /etc/znapzend/configs directories
class { 'znapzend':
plan_confdir_purge => false,
}
Note: if disabling the purge is done, then one would need to remove backup plans no longer in use via some other means from the directory.
Reference
Generated puppet strings documentation with examples is available from https://millerjl1701.github.io/millerjl1701-znapzend.
The puppet strings documentation is also included in the /docs folder.
Public Classes
- znapzend: Main class which installs, configures, and manages the znapzend service
- znapzend::imports: Class for managing the znapzend backup plans for zfs file systems.
Private Classes
- znapzend::config: Class which manages the configuration of the znapzend service service scripts.
- znapzend::install: Class which manages the build and installation of znapzend.
- znapzend::prereqs: Class which installs the pieces the documation points to as requirements for building znapzend.
- znapzend::repos: Class which manages the setup of the EPEL repository.
- znapzend::service: Class which manages the znapzend service.
Public Defined Types
- znapzend::import: Defined type for creation of a znapzend backup plan configuration file and properties on the appropriate zfs file system.
Limitations
This module installs from source znapzend on CentOS 6 and CentOS 7. It relies on zfs already being installed as well as prior creation of zfs file systems. However, this module makes no attempt at those tasks as there are other existing modules and resources available for use. As an example, please see the acceptance tests written in the spec directory.
This module does not allow for the removal of backup plans from a zfs file system; however, one can overwrite the plans as needed by just changing the parameters fed to the znapzend::imports::plans
parameter for that zfs file system or the znapzend::import::options
parameter if using the defined type directly.
Note: no validation of the znapzend backup plans is made in this module. If invalid parameters are passed to the template, it will fail to be imported by the znapzendzetup
command.
Development
This module has been converted over to using the Puppet Development Kit from a legacy Gemfile setup. Prior to submitting a pull request, run the pdk validate
command to ensure that the metadata and puppet manifests are of correct syntax. To specify a specific version of puppet to validate sysntax, run the command pdk validate --puppet-version 5.5.12
which would validate against Puppet 5.5.12.
All new code should have unit tests using rspec-puppet in the spec/classes
directory. Once written, the pdk test unit
command compiles catalogs for all supported operating systems ensuring that all resources are present in the catalog according the the unit test requirements.
All new functionality should have acceptance tests written using ServerSpec. Beaker is used as the test harness to provision a virtual machine, install puppet, and then configure the virtual machine with the module. If you have vagrant installed, the commands that you would use to run acceptance tests would be:
BEAKER_PUPPET_COLLECTION=puppet5 pdk bundle exec rake beaker
BEAKER_destroy=no BEAKER_PUPPET_COLLECTION=puppet5 pdk bundle exec rake beaker
BEAKER_provision=no BEAKER_destroy=no BEAKER_PUPPET_COLLECTION=puppet5 pdk bundle exec rake beaker
BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_set=centos-6-x64 pdk bundle exec rake beaker
The first command runs acceptance tests against the default node set using the puppet5 collection. The second command add BEAKER_destroy=no
to prevent the virtual machine from being destroyed at the end of the run in order to inspect the actual virtual machine. The third command allows you rerun the acceptance tests against the virtual machine without reprovisioning. The last command adds BEAKER_set
to change the nodeset away from default to allow for testing other operating systems.
Contributors
To see who is involved with this module, see the GitHub list of contributors or the CONTRIBUTORS document.
Reference
Table of Contents
Classes
Public Classes
znapzend
: Main class for managing the installation and configuration of the znapzend service.znapzend::imports
: Class for collecting and created znapzend backup plans to import onto datasets.
Private Classes
znapzend::config
: This class is called from znapzend for service config.znapzend::install
: This class is called from the main znapzend class for install.znapzend::prereqs
: This class is called from the main znapzend class for installing prerequisites.znapzend::repos
: This class is called from the main znapzend class for adding needed repos.znapzend::service
: This class is meant to be called from znapzend to manage the znapzend service.
Defined types
znapzend::import
: Define znapzend::import =========================== Defined type for a backup plan for a zfs dataset to be imported by znapzendzetup. Note:
Classes
znapzend
Class: znapzend
Main class that includes all other classes for the znapzend module.
Parameters
The following parameters are available in the znapzend
class.
gcc_packages
Data type: Array
Specifies what packages are installed for the build requirements of znapzend for providing gcc/make.
Default value: [ 'gcc', 'gcc-c++', ]
manage_epel
Data type: Boolean
Specifies whether or not the module should manage the EPEL repository.
Default value: true
manage_gcc
Data type: Boolean
Specifies whether or not the module should manage the installation of gcc.
Default value: true
manage_mbuffer
Data type: Boolean
Specifies whether or not the module should manage the installation of mbuffer.
Default value: true
manage_perl
Data type: Boolean
Specifies whether on not the module should manage the installation of the perl-core rpm.
Default value: true
manage_prereqs
Data type: Boolean
Specifies whether or not the module should manage any of the components of the preqrequites for building znapzend.
Default value: true
mbuffer_packages
Data type: Array
Specifies what package(s) should be installed on the system to provide mbuffer support for znapzend to use.
Default value: [ 'mbuffer', ]
perl_packages
Data type: Array
Specifies what perl RPM(s) should be installed on the system for building and running znapzend.
Default value: [ 'perl-core', ]
plan_confdir
Data type: Stdlib::Unixpath
Specifies where the znapzend backup plan configuration files will be located.
Default value: '/etc/znapzend/configs'
plan_confdir_purge
Data type: Boolean
Specifies whether or not the znapzend configuration directories should be purged of files not managed by puppet.
Default value: true
plan_confdir_setup
Data type: Array[Stdlib::Unixpath]
An array of directories that puppet should create on the system for where the znapzend backup plans will be stored.
Default value: [ '/etc/znapzend', '/etc/znapzend/configs', ]
plan_conffile_mode
Data type: String
The mode that should be used for the znapzend backup plan configuration files.
Default value: '0644'
plan_conffile_template
Data type: String
The name of the template to use for the znapzend backup plan configuration files.
Default value: 'znapzend/plan_conffile_template.erb'
service_enable
Data type: Boolean
Whether to enable the znapzend service at boot.
Default value: true
service_ensure
Data type: Enum['running', 'stopped']
Whether the znapzend service should be running.
Default value: 'running'
service_name
Data type: String
Specifies the name of the service to manage.
Default value: 'znapzend'
service_options
Data type: String
Specifies options placed in /etc/default/znapzend for use by the znapzend service.
Default value: ''
service_options_template
Data type: String
Specifies the name of the template to use for /etc/default/znapzend.
Default value: 'znapzend/znapzend.default.erb'
service_systemd_afters
Data type: Array
Specifes what systemd services should be started up prior to the znapzend.service.
Default value: [ 'zfs-import-cache.service', 'zfs-import-scan.service', ]
service_systemd_template
Data type: String
Specifies the name of the template to use for the /etc/systemd/system/znapzend.service file.
Default value: 'znapzend/znapzend.service.erb'
service_sysv_template
Data type: String
Specifies the name of the template to use for the /etc/init.d/znapzend file.
Default value: 'znapzend/znapzend.sysv.erb'
znapzend_download_location
Data type: Stdlib::Unixpath
Specifies where the znapzend archive resource should download the tar.gz file to for later extraction.
Default value: '/tmp'
znapzend_package_version
Data type: String
Specifies the version of znapzend to download and install.
Default value: '0.19.1'
znapzend_package_extractpath
Data type: Stdlib::Unixpath
Specifies where the znapzend archive resource should extract the tar.gz file to for building
Default value: '/usr/local/src'
znapzend_package_url
Data type: Stdlib::Httpurl
Specifies the URL of where to download the znapzend tar.gz file. By default, this uses the znapzend_package_version version.
Default value: "https://github.com/oetiker/znapzend/releases/download/v${znapzend_package_version}/znapzend-${znapzend_package_version}.tar.gz"
znapzend_install_prefix
Data type: Stdlib::Unixpath
Specifies the directory to which znapzend should be installed.
Default value: "/opt/znapzend-${znapzend_package_version}"
znapzend_installed_binaries
Data type: Array
Specifies a list of znapzend programs to link.
Default value: [ 'znapzend', 'znapzendzetup', 'znapzendztatz', ]
znapzend_linkpath
Data type: Stdlib::Unixpath
Specifies where the znapzend program links should be created.
Default value: '/usr/local/bin'
znapzend::imports
Class znapzend::imports
Class for collecting and created znapzend backup plans to import onto datasets. Data is either passed via the imports plans parameter or via hiera.
Parameters
The following parameters are available in the znapzend::imports
class.
plans
Data type: Hash
Hash of plans for which each will result in creation of a config file which is then imported into the properties of the zfs file system for use by znapzend. The title of each plan needs to be the zfs file system name in the form of poolname/filesystem/filesystem.
Default value: {}
Defined types
znapzend::import
Define znapzend::import
Defined type for a backup plan for a zfs dataset to be imported by znapzendzetup. Note: the title of the defined type should match the zfs file system name not the mountpoint.
Parameters
The following parameters are available in the znapzend::import
defined type.
options
Data type: Hash
A hash of znapzend options to be imported into the file system.
Change log
All notable changes to this project will be documented in this file. The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
v1.1.0 (2020-06-18)
Added
- Update to pdk 1.18.0 #8 (millerjl1701)
- Updated documentation by puppet strings #7 (millerjl1701)
- Add support for Puppet 6 #6 (millerjl1701)
- znapzend_imports_spec.rb: add a plans param for testing #4 (millerjl1701)
- Convert module to pdk 1.17.0 #2 (millerjl1701)
v1.0.0 (2018-09-07)
* This Changelog was automatically generated by github_changelog_generator
Dependencies
- camptocamp-systemd (>=1.0.0 <3.0.0)
- puppet-archive (>=3.0.0 <4.0.0)
- puppetlabs-stdlib (>=4.7.0 <6.0.0)
- stahnma-epel (>=1.0.0 <2.0.0)
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.