Forge Home

htpasswd

Puppet module to manage htpasswd and htgroup files. Based upon https://github.com/leinaddm/puppet-htpasswd

7,593 downloads

154 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.0.3 (latest)
  • 1.0.2
  • 1.0.1
  • 1.0.0
released Oct 16th 2024
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, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x, 2018.1.x
  • Puppet >= 5.5.10 < 8.0.0
  • , , ,

Start using this module

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

Add this module to your Puppetfile:

mod 'citrin-htpasswd', '1.0.3'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add citrin-htpasswd
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install citrin-htpasswd --version 1.0.3

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

citrin/htpasswd — version 1.0.3 Oct 16th 2024

htpasswd

Puppet module to manage htpasswd and htgroup files.

Made for Users who need to be a bit more Flexible than the Apache module allows.

Adds Functions to generate Passwords for htpasswd file-line with different methods. Currently included are:

  • crypt
  • md5
  • sha1

The Apache Module currently uses sha1:

apache::pw_hash
  Currently uses SHA-hashes, because although this format is considered insecure, it's the most secure format supported by the most platforms.
  https://forge.puppet.com/puppetlabs/apache/reference#apachepw_hash

This module currently does not manage the owner/group/mode of the htpasswd and htgroup files you specify.

Module is a Fork of https://github.com/leinaddm/puppet-htpasswd.

tldr

Module does not manage existence of htpasswd file. You need to add this yourself

add a user

htpasswd { 'dan':
  cryptpasswd => 'MrC7Aq3qPKPaK',  # encrypted password
  target      => '/etc/httpd/conf/htpasswd',
}

add a second user with the same username to a different file

htpasswd { 'dan2':
  username    => 'dan',
  cryptpasswd => $password,  # encrypted password
  target      => '/etc/httpd/conf/htpasswd2',
}

remove a user

htpasswd { user:
  ensure => absent,
  target => '/etc/httpd/conf/htpasswd',
}

add a group

htgroup { groupname:
  users  => [ user1, user2, ],
  target => '/etc/httpd/conf/htgroup',
}

remove a group

htgroup { groupname:
  ensure => absent,
  target => '/etc/httpd/conf/htgroup',
}

Generate Random Password and export as file somewhere

Here is an example how you can use the module to generate random passwords based on host and user and export the password to somewhere; like a users workstation.

$user = 'username'
$htpasswd_charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@!'
$password = htpasswd::ht_md5(
  fqdn_rand_string('32', $htpasswd_charset, $user),
  fqdn_rand_string('8', $htpasswd_charset, "${user}_salt")
)

@@file {$facts['fqdn']:
  ensure  => present,
  content => $password,
  user    => $user,
  group   => $user,
  mode    => '0600',
  tag     => 'sometag',
}

htpasswd { $user:
  ensure => present,
  cryptpasswd => $password,
  target => '/path/to/htpasswd'
}

Credits