Forge Home

windows_path

Manage individual entries in the Windows PATH variable as resources, that is, add and remove directories to the PATH in an idempotent manner.

33,045 downloads

32,584 latest version

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

Support the Puppet Community by contributing to this module

You are welcome to contribute to this module by suggesting new features, currency updates, or fixes. Every contribution is valuable to help ensure that the module remains compatible with the latest Puppet versions and continues to meet community needs. Complete the following steps:

  1. Review the module’s contribution guidelines and any licenses. Ensure that your planned contribution aligns with the author’s standards and any legal requirements.
  2. Fork the repository on GitHub, make changes on a branch of your fork, and submit a pull request. The pull request must clearly document your proposed change.

For questions about updating the module, contact the module’s author.

Version information

  • 0.1.1 (latest)
  • 0.1.0
released Aug 23rd 2013

Start using this module

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

Add this module to your Puppetfile:

mod 'basti1302-windows_path', '0.1.1'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add basti1302-windows_path
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install basti1302-windows_path --version 0.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

basti1302/windows_path — version 0.1.1 Aug 23rd 2013

puppet-windows-path

Manage individual entries in the Windows PATH variable as resources, that is, add and remove directories to the PATH in an idempotent manner.

There is already the excellent puppetlabs/registry module to manage registry entries. In the end, the Windows PATH is also a registry entry (or rather two, the system PATH and the user PATH of the current user), so you might wonder why this module exists. However, the registry module (or any other module I know of) does not offer the abstraction of managing a single entry in the PATH (like "C:\Program Files (x86)\puppetlabs\puppet\bin") as a resource. Thus adding specific directories to the PATH in an idempotent manner is a real headache. Naive attempts (for example, by using exec together with SET) might result in duplicated path entries or other issues.

This module solves this problem. Internally, it parses and splits the PATH up into individual entries (directories) and is thus able to check reliably if any given directory already is contained in the PATH or not.

The module is able to manage the system path as well as the user path. The default is to manage the system path.

Installation

Either install the latest release from puppet forge:

puppet module install basti1302/windows_path

or install the current head from the git repository by going to your puppet modules folder and do

git clone git@github.com:basti1302/puppet-windows-path.git windows_path

It is important that the folder where this module resisdes is named windows_path, not puppet-windows-path.

Usage

include windows_path

# Add an entry to the PATH or verify that it is already there.
windows_path {'add a PATH entry if it is not there yet':
  ensure      => present,
  directory   => 'C:\this\should\be\added',
}

# Remove an existing path entry or verify that the directory is not in the PATH.
windows_path {'remove a directory from PATH.':
  ensure      => absent,
  directory   => 'C:\this\should\be\removed',
}

# By specifying target => user you can manage the path of the current user.
# target => system (or omitting target) results in the sytem path being managed.
# Currently it is not possible to manage the path of an arbitrary user. Pull
# requests are welcome :-)
windows_path {'Manage the path of the current user.':
  ensure      => absent,
  directory   => 'C:\this\should\be\removed',
  target      => user,
}

# The namevar is, of course, the parameter directory.
windows_path {'C:\add\this\also\please':
    ensure      => present,
}