summaryrefslogtreecommitdiff
path: root/puppet/modules/apache/manifests/htpasswd_user.pp
blob: 82fbce451a2db679feac9cbc76843b3e72037a3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# ToDo: This should be rewritten as native type
define apache::htpasswd_user(
    $password,
    $password_iscrypted = false,
    $ensure   = 'present',
    $site     = 'absent',
    $username = 'absent',
    $path     = 'absent'
){
    case $username {
        'absent': { $real_username = $name }
        default: { $real_username = $username }
    }
    case $site {
        'absent': { $real_site = $name }
        default: { $real_site = $site }
    }
    if $password_iscrypted {
        $real_password = $password
    } else {
        $real_password = htpasswd_sha1($password)
    }

    case $path {
        'absent': { $real_path = "/var/www/htpasswds/${real_site}" }
        default:  { $real_path = $path }
    }

    file_line{"htpasswd_for_${real_site}":
        ensure => $ensure,
        path   => $real_path,
        line   => "${username}:${real_password}",
    }
}