Version information
This version is compatible with:
- Puppet Enterprise 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x, 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.6.0 < 8.0.0
- , , , , , , , , , ,
Tasks:
- test
Start using this module
Add this module to your Puppetfile:
mod 'example42-tp', '2.5.0'
Learn more about managing modules with a PuppetfileDocumentation
Tiny Puppet
Table of Contents
- Module description - What Tiny Puppet does?
- Setup
- Usage - Configuration options and additional functionality
- Reference
- Prerequisites and limitations
- Tests
Module description
The tp (short for Tiny Puppet) module allows you to manage any application on any (Linux flavours, Solaris, Darwin, Windows) Operating System.
It provides Puppet defined types to install packages and manage services (tp::install
), eventually handling relevant repos (tp::repo
) and then manage their configuration files (tp::conf
) and directories (tp::dir
).
Features
- Quick, easy to use, standard, coherent, powerful interface to applications installation and their config files management.
- Out of the box and easily expandable support for most common Operating Systems
- Modular data source design. Support for an easily growing set of applications.
- Smooth coexistence with any existing Puppet modules setup: you decide what to manage
- Application data stored in a configurable separated module (tinydata is the default source for applications data)
- Optional shell command (
tp
) which can be used to install, test, query for logs any tp managed application.
Use cases
Tiny Puppet is intended to be used in profiles, as replacement for dedicated componenent modules, or in the same modules, to ease the management of the provided files and packages.
The expected users are both experienced sysadmins who know exactly how to configure their applications and absolute beginners who want to simply install an application, without knowing how it's package is called on the underlying system or how to install its repositories or dependencies.
To see real world usage of tp defines give a look to the profiles in the psick module.
Setup
What tp affects
- any application package which is possible to install with the OS native package manager
- eventually application specific package repository files or release packages (if relevant tinydata is present)
- configuration files of any application (for which there's tinydata). Content is up to the user.
- full directories, whose source can also be a scm repository
Getting started with tp
Tiny Puppet is typically used in profiles, custom classes where we place the code we need to manage applications in the way we need.
This is a simple case, where the content of a configuration file is based on a template with custom values.
class profile::openssh (
String $template = 'profile/openssh/sshd_config.erb',
Hash $options = {},
) {
tp::install { 'openssh': }
tp::conf { 'openssh':
template => $template,
options_hash => $options,
}
}
Usage
Usage in Puppet code
Install an application with default settings (package installed, service started)
tp::install { 'redis': }
Configure the application main configuration file a custom erb template which uses data from a custom $options_hash:
tp::conf { 'rsyslog':
template => 'site/rsyslog/rsyslog.conf.erb',
options_hash => hiera('rsyslog::options_hash'),
}
Populate any custom directory from a Git repository (it requires Puppet Labs' vcsrepo module):
tp::dir { '/opt/apps/my_app':
source => 'https://git.example.42/apps/my_app/',
vcsrepo => 'git',
}
Installation options
Install custom packages (with the settings_hash
argument you can override any application specific setting)
tp::install { 'redis':
settings_hash => {
'package_name' => 'my_redis',
'config_file_path' => '/opt/etc/redis',
},
}
Some options are available to manage tp::install automation:
tp::install { 'virtualbox':
auto_repo => true, # This is the default, settings, if defined in tinydata, it installs the relevant package repository
auto_conf => true, # True by default. If defined in tinydata a default configuration is provided
auto_prerequisites => false, # False by default. If true eventual package or tp::install dependencies are installed
}
Other options are available to manage integrations:
tp::install { 'rabbitmq':
cli_enable => true, # Default value. Installs the tp command on the system and provides the data about the defined application.
puppi_enable => false, # Default value. Installs puppi and enables puppet integration
test_template => undef, # Default value. If provided, the provided erb template is used as script to test the application (instead of default tests)
options_hash => {} # An optional hash where to set variable to use in the test_template.
}
To uninstall an application, there are two alternatives:
tp::uninstall { 'redis': }
tp::install { 'redis': ensure => absent }
Installation alternatives
To manage packages installations and configuration files there's also the tp::stdmod
define to manage an application using stdmod compliant parameters.
Note that tp::stdmod
is alternative to tp::install
(both of them manage packages and services) and may be complementary to tp::conf
(you can configure files with both).
tp::stdmod { 'redis':
config_file_template => 'site/redis/redis.conf',
}
If you wonder what's better, use tp::install
+ tp::conf
rather than tp::stdmod
.
Managing configurations
By default, configuration files managed by tp::conf automatically notify the service(s) and require the package(s) installed via tp::install. If you use tp::conf without a relevant tp::install define and have dependency cycle problems or references to non existing resources, you can disable these automatic relationships:
tp::conf { 'bind':
config_file_notify => false,
config_file_require => false,
}
You can also set custom resource references to point to actual resources you declare in your manifests:
tp::conf { 'bind':
config_file_notify => 'Service[bind9]',
config_file_require => 'Package[bind9-server]',
}
It's possible to manage files with different methods, for example directly providing its content:
tp::conf { 'redis':
content => 'my content is king',
}
or providing a custom erb template (used as content => template($template)
):
tp::conf { 'openssh::ssh_config':
template => 'site/openssh/ssh_config.erb',
}
or using a custom epp template with Puppet code instead of Ruby (used as content => epp($epp)
):
tp::conf { 'redis:
epp => 'site/redis/redis.conf.epp',
}
also it's possible to provide the source to use, instead of managing it with the content argument:
tp::conf { 'redis':
source => [ "puppet:///modules/site/redis/redis.conf-${hostname}" ,
'puppet:///modules/site/redis/redis.conf' ] ,
}
tp::conf file paths conventions
Tp:conf has some conventions on the actual configuration file manages.
By default, if you just specify the application name, the file managed is the "main" configuration file of that application (in case this is not evident or may be questionable, check the config_file_path
value in the tinydata files for the used application).
# This manages /etc/ssh/sshd_config
tp::conf { 'openssh':
[...]
}
If you specify a file name after the application name in the title, separated by ::
, and you don't specify any alternative base_file
, then that file is placed in the "base" configuration dir (config_dir_path
in tinydata):
# This manages /etc/ssh/ssh_config
tp::conf { 'openssh::ssh_config':
[...]
}
If you specify the parameter base_file
then the path is the one of the specified base_file and the title does not provide any information about the managed file path (it still needs the relevant app in the first part, before ::, and it needs to be unique across the catalog). For example if base_file => 'init'
the path used is the value of the init_file_path
key in the relevant tinydata.
# This manages /etc/default/puppetserver on Debian or /etc/sysconfig/puppetserver on RedHat
tp::conf { 'puppetserver::init':
base_file => 'init',
[...]
}
If you explicitly set a path
, that path is used and the title is ignored (be sure, anyway, to refer to a supported application and is not duplicated in your catalog):
# This manages /usr/local/bin/openssh_check
tp::conf { 'openssh::ssh_check':
path => '/usr/local/bin/openssh_check',
[...]
}
Managing directories
Manage a whole configuration directory:
tp::dir { 'redis':
source => 'puppet:///modules/site/redis/',
}
Manage a specific directory type. Currently defined directories types are:
config
: The application [main] configuration directory (Default value)conf
: A directory where you can place single configuration files (typically called ./conf.d )data
: Directory where application data resideslog
: Dedicated directory for logs, if present
Note that some of these directory types might not be defined for every application.
tp::dir { 'apache':
base_dir => 'data',
source => 'puppet:///modules/site/apache/default_site',
}
Clone a whole configuration directory from a Git repository (it requires Puppet Labs' vcsrepo module):
tp::dir { 'redis':
source => 'https://git.example.42/puppet/redis/conf/',
vcsrepo => 'git',
}
Populate any custom directory from a Subversion repository (it requires Puppet Labs' vcsrepo module):
tp::dir { 'my_app': # The title is irrilevant, when path argument is used
path => '/opt/apps/my_app',
source => 'https://svn.example.42/apps/my_app/',
vcsrepo => 'svn',
}
Provide a data directory (the default DocumentRoot, for apache) from a Git repository (it requires Puppet Labs' vcsrepo module) (TODO):
tp::dir { 'apache':
# base_dir is a tag that defines the type of directory for the specified application.
# Default: config. Other possible dir types: 'data', 'log', 'confd', 'lib'
# or any other name defined in the application data with a format like: ${base_dir}_dir_path
base_dir => 'data'
source => 'https://git.example.42/apps/my_app/',
vcsrepo => 'git',
}
Managing repositories
Currently Tiny Puppet supports applications' installation only via the OS native packaging system or Chocolatey on Windows and HomeBrew on MacOS. In order to cope with software which may not be provided by default on an OS, TP provides the tp::repo
define that manages YUM and APT repositories for RedHat and Debian based Linux distributions.
The data about a repository is managed as all the other data of Tiny Puppet. Find here an example for managing Apt repositories and here one for Yum ones.
Generally you don't have to use directly the tp::repo
define, as, when the repository data is present, it's automatically added from the tp::install
one.
When it's present the relevant data for an application, it's possible to install it using different alternative repos. For example you can use:
tp::install { 'mongodb':
repo => 'mongodb-org-3.2',
}
to install MongoDB using packages from the 3.2 upstream repo, instead of the default OS ones.
In some cases, where for the given application name there are no packages, the following commands have exactly the same effect:
tp::install { 'epel': } # Installs Epel repository on RedHat derivatives. Does nothing on other OS.
tp::repo { 'epel': } # Same effect of tp::install since no package is actually installed
If, for whatever reason, you don't want to automatically manage a repository for an application, you can set to false
the auto_repo
parameter, and, eventually you can manage the repository in a custom dependency class:
tp::install { 'elasticsearch':
auto_repo => false,
}
Using alternative data sources
By default Tiny Puppet uses the tinydata module to retrieve data for different applications, but it's possible to use a custom one:
tp::install { 'apache':
data_module => 'my_data', # Default: tinydata
}
Reproduce the structure of tinydata in your data module to make it work with tp.
If you want to use your own data module for all your applications, you might prefer to set the following resource defaults in your main manifest (manifest/site.pp
, typically):
Tp::Install {
data_module => 'my_data',
}
Tp::Conf {
data_module => 'my_data',
}
Tp::Dir {
data_module => 'my_data',
}
Starting from version 2.3.0 (with tinydata version > 0.3.0) tp can even install applications for which there's no tinydata defined. In this case just the omonimous package is (tried to be) installed and a warning about missing tinydata is shown.
Usage on the command line
Tiny Puppet adds the tp command to Puppet. Just have it in your modulepath and install the tp command with:
puppet tp setup
With the tp command you can install on the local OS the given application, taking care of naming differences, additional repos or prerequisites.
tp install <application>
tp uninstall <application>
tp test # Test all the applications installed by tp
tp test <application> # Test the specified application
tp log # Tail all the logs of all the applications installed by tp
tp log <application> # Tail the log of the specified application
Each of these commands can be inkoed also via the tp puppet face:
puppet tp <command> <arguments>
Reference
The tp modules provides the following resources.
Classes
tp
Offers antry points for data driven management of tp resources, and the possibility to install the tp command
Defined types
tp::install
. It installs an application and starts its service, by defaulttp::conf
. It allows to manage configuration filestp::dir
. Manages the content of directoriestp::stdmod
. Manages the installation of an application using StdMod compliant parameterstp::test
. Allows quick and easy (acceptance) testing of an applicationtp::repo
. Manages extra repositories for the supported applicationstp::puppi
. Puppi integration (Don't worry, fully optional)
Types
- [tp-settings], validates all the possible setting for tinydata
Functions
- [tp::content], manages content for files based on supplied (erb) template, epp, and content
- [tp::ensure2bool], converts ensure values to boolean
- [tp::ensure2dir], converts ensure values to esnure values to be used for directories
- [tp::install], wrapper around the tp::install define, it tries to avoid eventual duplicated resources issues
- [tp::is_something], returna true if input of any type exists and is not empty
Tasks
- [
tp::test
], runs a tp test command on a system to check status of [tp] installed applications
Refer to in code documentation for full reference.
Check Puppetmodule.info for online version.
Prerequisites and limitations
Current version of Tiny Puppet is compatible with Puppet 4.4 or later and PE 2016.1.1 or later.
To use it on Puppet 3 you have to use tp version 1.x with the 3.x compatible defines (with the 3
suffix).
If tp doesn't correctly install a specific application on the OS you want, please TELL US. It's very easy and quick to add new apps or support for new OS in tinydata.
Currently most of the applications are supported on RedHat and Debian derivatives Linux distributions, but as long as you provide a valid installable package name, tp can install any application given in the title, even if there's no specific Tinydata for it..
Tiny Puppet requires these Puppet modules:
In order to work on some OS you need some additional modules and software:
- On Windows you need Chocolatey and puppetlabs-chocolatey module with chocolatey package provider.
- On Mac OS you need Home Brew and thekevjames-homebrew or equivalent module with homebrew package provider.
If you use the relevant defines, other dependencies are needed:
-
Define
tp::concat
requires puppetlabs-concat module. -
Define
tp::dir
, when used with thevcsrepo
argument, requires puppetlabs-vcsrepo module. -
Define
tp::puppi
requires example42-puppi module.
Tests
You can experiment and play with Tiny Puppet and see a lot of use examples on Example42's PSICK control-repo.
Acceptance tests are done to verify tp support for different applications on different Operating Systems. They are in the TP acceptance repo.
What are tasks?
Modules can contain tasks that take action outside of a desired state managed by Puppet. It’s perfect for troubleshooting or deploying one-off changes, distributing scripts to run across your infrastructure, or automating changes that need to happen in a particular order as part of an application deployment.
Tasks in this module release
CHANGELOG
2.5.0
- Added tinydata params git_source and git_destination to install apps from git source
- Added param repo_file_url to install a repo directly from http url (Note: if using https, the repo webserver certificate must be valid and accepted by locally installed CAs certs).
- Added repo_description tinydata setting
- Added support for puppet gem packages in tp test
- Improved support for Windows
- tp test now shows also tp managed repos
2.4.3
- Added repo_description setting
2.4.2
- Ensure we find tp command in task tp::test
- Propagate data_module var to tp defines used in tp::install
- pdk convert
2.4.1
- Fix for tp::install when upstream_repo is missing in tinydata
2.4.0
- Added upstream_repo option
2.3.5
- Explicitly close open files in tp_lookup
- Add purge_dirs argument to tp class
2.3.4
- Added repo_exec_environment argument to tp::install
2.3.3
- Updated README
2.3.2
- Approved status request [MODULES-5811] - https://tickets.puppetlabs.com/browse/MODULES-5811
- Skip danger in travis CI
- any variables can be accepted for ensure of dir (#59)
2.3.1
- Allow spaces in key for apt-key checks in tp::repo (#57)
2.3.0
- Do not fail on missing tinydata, try to install homonimous package
2.2.1
- Added support for tinydata settings repo_name and repo_filename in tp::repo
- Added support for tinydata settings config_file_params and config_dir_params
- tp from command line Install cli integration by default
2.2.0
- Added support for tinydata setting [repo_package_params] in tp::repo
- tp::repo just installs the release package if tinydata exists
- Install via wget and dkpg release package from repo_package_url On Debian in tp::repo
- Added support for package_params and service_params in tp::install
2.1.1
- [#52] Add support for trust_server_cert and any extra option on tp::dir
- [#44] Install_hash should support arrays [@logicminds]
2.1.0
- Added validate_syntax option to tp::conf
2.0.4
- Added task tp::test
2.0.1
- Added more spec tests
- Minor fixes
2.0.0
- Removed Puppet3 defines
- Class tp: Removed params: packages, services, files
- Define tp::install: Params auto_prerequisites renamed to auto_prereq
- More Puppet 4 language constructs
- Removed pick_undef and tp_pick functions. Use stdlib pick_default
- Removed tp::concat define
- Main tp class refactored to use params pattern instead of data in modules for backwards compatibility
- Refactored spec tests. Now is possible to test any tp define on any os on any app
- Added tests for tp::test, tp::uninstall, tp::stdmod
Dependencies
- puppetlabs/stdlib (>= 3.2.0 < 7.0.0)
- example42/tinydata (>= 0.0.1 < 5.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.