example42/puppet-tp

Name: puppet-tp

Owner: Example42

Description: Tiny Puppet - The Universal Installer

Created: 2015-02-05 23:11:01.0

Updated: 2017-12-19 19:49:39.0

Pushed: 2018-01-10 09:38:34.0

Homepage: http://tiny-puppet.com

Size: 931

Language: Ruby

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Tiny Puppet

Build Status Coverage Status Codacy Badge

The Universal Installer

Tiny Puppet is single Puppet module that manages virtually any application on any Operating System:

puppet module install example42-tp
puppet tp setup
tp install <any_app>

It can be used inside Puppet manifests or directly from the command line.

Features:

It 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.

Provided Puppet defines

Tiny Puppet provides the following Puppet user defines:

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>
Prerequisites and limitations

Current version of Tiny Puppet is compatible only with Puppet 4.4 or later and PE 2016.1.1 or later.

To use it 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.

Support for Solaris, Windows, MacOS, *BSD and others is currently limited, mostly for lack of tinydata.

Tiny Puppet requires these Puppet modules:

If you use the relevant defines, other dependencies are needed:

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::stdmodis alternative to ``tp::install` (both of them manage packages and services) and may be complementary totp::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 thantp::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 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 data files for the actual value used).

# 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:

# 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).

# 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:

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. 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::repodefine, 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 `falsethe ``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',
}
Testing and playing with Tiny Puppet

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.

Check this Compatibility Matrix for a quick overview on how different applications are currently supported on different Operating Systems.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.