summaryrefslogtreecommitdiff
path: root/manifests/htpasswd_user.pp
blob: c4c5453594d87593d51c350db558c6f6897e9d78 (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
# 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 }
    }
    if $password_iscrypted {
        $real_password = $password
    } else {
        $real_password = htpasswd_sha1($password)
    }

    file_line{"htpasswd_for_${real_site}":
        ensure => $ensure,
        path => $path ? {
          'absent' => "/var/www/htpasswds/${real_site}",
          default => $path
        },
        line => "${username}:${real_password}",
    }
}