Forge Home

bash_task_helper

A Bash helper library for use by Puppet Tasks.

14,092 downloads

720 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

  • 2.1.1 (latest)
  • 2.1.0
  • 2.0.0
  • 1.0.0
released Jul 11th 2022
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
  • Puppet >= 6.21.0 < 8.0.0
  • , , , , ,

Start using this module

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

Add this module to your Puppetfile:

mod 'puppetlabs-bash_task_helper', '2.0.0'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add puppetlabs-bash_task_helper
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install puppetlabs-bash_task_helper --version 2.0.0

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

puppetlabs/bash_task_helper — version 2.0.0 Jul 11th 2022

bash_task_helper

A Bash helper library for use by Puppet Tasks.

Table of Contents

  1. Description
  2. Requirements
  3. Setup - The basics of getting started with bash_task_helper
  4. Usage - Configuration options and additional functionality
  5. Development - Guide for contributing to the module

Description

This library handles producing a formatted error message for errors from stderr and uses indirection to munge PT_ environment variables.

Requirements

  • bash >= 4.0 on the primary Puppet server

Setup

To use this, include this module in a Puppetfile

mod 'puppetlabs-bash_task_helper'

Add it to your task metadata

{
  "files": ["bash_task_helper/files/task_helper.sh"],
  "input_method": "environment"
}

Usage

In your task, source the helper script and you can use the fail and sucess funtions. Sucess outputs your provided output and fail outputs any provided output and appends stderr if applicable.

mymodule/tasks/mytask.sh

#!/bin/bash

declare PT__installdir
source "$PT__installdir/bash_task_helper/files/task_helper.sh"


if puppet resource service puppet | grep -q stopped; then
    #Start the Puppet service
     puppet resource service puppet ensure=running || fail "Couldn't start puppet service"

else
  fail "Puppet is already running or not installed"
fi


success '{ "status": "success" }'

How to Report an issue or contribute to the module

If you are a PE user and need support using this module or are encountering issues, our Support team would be happy to help you resolve your issue and help reproduce any bugs. Just raise a ticket on the support portal.

If you have a reproducible bug or are a community user you can raise it directly on the Github issues page of the module here. We also welcome PR contributions to improve the module. Please see further details about contributing here.