Forge Home

chown_r

chown -R files you need to

20,997 downloads

4,490 latest version

2.3 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.2 (latest)
  • 1.1.1
  • 1.1.0
  • 1.0.1
  • 1.0.0 (deleted)
  • 0.2.0
  • 0.1.4
  • 0.1.3
  • 0.1.2
  • 0.1.1
  • 0.1.0 (deleted)
released Apr 17th 2020

Start using this module

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

Add this module to your Puppetfile:

mod 'geoffwilliams-chown_r', '1.1.2'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add geoffwilliams-chown_r
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install geoffwilliams-chown_r --version 1.1.2

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

geoffwilliams/chown_r — version 1.1.2 Apr 17th 2020

Build Status

chown_r

Table of Contents

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

Description

This module provides a handy way to run the chown -R command to perform bulk directory ownership/group changes where required.

While the equivalent result is also possible using a file resource in recursive mode, doing so can create a huge number of resources, placing an unnecessary load on the Puppet Master.

This module achieves the same result at the cost of reduced change reporting granularity: A maximum of one change per resource will ever be reported no matter how many underlying files need to have their ownership fixed. This is inline with the default behavior of the underlying chown system command.

Usage

Notes

  • Directories referred to must already exist on the system
  • If creating these directories with Puppet, you should not specify owner or group information as this could conflict with the changes made by this module
  • Any groups and users required must be declared
  • You can pass an array of directories to check and fix recursively for permissions to save typing as long as the want_user and want_group fields are identical
  • Both want_user and want_group are mandatory parameters

Check permissions every puppet run

If your happy for Puppet to update and fix permissions as required, the following code would ensure that /foo and all its children are owned by user foo and group foo:

chown_r { "/foo":
  want_user   => "foo",
  want_group  => "foo",
}

Check permissions when watched resource changes

If your only ever want to perform fixes in response to a Package update AND observed incorrect ownership, the following code would ensure all /bar and all its children will be set to owner bar, group bar if required after a change to the foobar package. If the package is unchanged, then ownership will not be checked/fixed.

chown_r { "/bar":
  want_user   => "bar",
  want_group  => "bar",
  watch       => Package["foobar"],
}

Checking and fixing permissions on several directories at once

If you have several directories to check/fix, you can use Puppet's built in array syntax as follows to reduce the amount of typing needed. You may also specify a resource to watch for changes as desired.

chown_r { ["/somedir/appdir-1.2.3", "/shared/conf/", "/shared/data/", "/shared/log"]:
  want_user   => "app",
  want_group  => "app",
}

Limitations

  • Only works on Unix-like OS's
  • It's possible to write code that will result in race conditions using this module, please test your code thoroughly
  • Overlapping chown_r resources are not detected by the module and must be avoided by the user
  • This module is not supported by Puppet

Development

Pull Requests accepted