summaryrefslogtreecommitdiff
path: root/manifests/htpasswd_user.pp
blob: 5a7c41326a2716b25fe2e038f2dfb8bf9170bbe6 (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(
    $ensure = present,
    $site = 'absent',
    $username = 'absent',
    $password,
    $password_iscrypted = false,
    $ensure = 'present',
    $path = 'absent'
){
    case $username {
        'absent': { $real_username = $name }
        default: { $real_username = $username }
    }
    case $site {
        'absent': { $real_site = $name }
        default: { $real_site = $site }
    }
    case $path {
        'absent': { $real_path = "/var/www/htpasswds/${real_site}" }
        default: { $real_path = $path }
    }
    if $password_iscrypted {
        $real_password = $password
    } else {
        $real_password = htpasswd_sha1($password)
    }

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