Forge Home

format

Puppet formatting functions to transform text into rich text

11,228 downloads

4,309 latest version

5.0 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 1.1.1 (latest)
  • 1.1.0
  • 1.0.0
  • 0.1.1
  • 0.1.1-rc0 (deleted)
released Feb 15th 2024
This version is compatible with:
  • Puppet Enterprise 2023.8.x, 2023.7.x, 2023.6.x, 2023.5.x, 2023.4.x, 2023.3.x, 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
  • Puppet >= 7.0.0 < 9.0.0
  • , , , , , , , , , ,

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'puppet-format', '1.1.1'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add puppet-format
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install puppet-format --version 1.1.1

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

puppet/format — version 1.1.1 Feb 15th 2024

puppet-format

CI Puppet Forge Puppet Forge - downloads Puppet Forge - endorsement Puppet Forge - scores Apache-2 License

This module includes puppet functions to transform your boring, old and worn looking ascii characters into beautiful looking masterpieces.

Table of Contents

  1. Description
  2. Setup - The basics of getting started with format
  3. Usage - Configuration options and additional functionality
  4. Limitations - OS compatibility, etc.
  5. Development - Guide for contributing to the module

Description

With this module you can produce amazing looking tables, colorized strings and others transformations for output to the terminal screen. While this module is mainly for bolt plans it could be used in puppet code anywhere.

Setup

What format affects

This module includes functions and datatypes only.

Setup Requirements

This module requires the terminal-table gem. It's a direct dependency for bolt, so open source users don't need to install additional gems. For PE users that want to use the function, they need to install terminal-table for the orchestrator:

GEM_PATH=/opt/puppetlabs/server/apps/bolt-server/lib/ruby GEM_HOME=/opt/puppetlabs/server/apps/bolt-server/lib/ruby /opt/puppetlabs/puppet/bin/gem install terminal-table --no-document

Usage

This module only contains functions to format and transform data. It will not output anything to stdout and only return formatted data ready to be sent to stdout or stderr.

Functions

  • format::colorize("string", red) # options include red, green, yellow, fatal, warning, good.
  • format::table([['one', 1], ['two', 2]])

The print_table function wraps the Terminal-Table ruby gem in a function and tries to provide the same API. You can create a table in two ways.

  • by passing a TableRows type (Array of Arrays)
  • by passing a TerminalTable type (Hash of various keys)

Example:

# puppet code
format::table({title => 'GPU list', head => ['Name', 'QTY'],
               rows => [['GTX 1070', 5], ['GTX 2080 ti', 1]],
               style => {width => 60 }
            })

Which produces a table like:

+-----------------------------+----------------------------+
|                         GPU list                         |
+-----------------------------+----------------------------+
| Name                        | QTY                        |
+-----------------------------+----------------------------+
| GTX 1070                    | 5                          |
| GTX 2080 ti                 | 1                          |
+-----------------------------+----------------------------+

Or with colors