summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--manifests/defines/htpasswd.pp33
-rw-r--r--plugins/puppet/parser/functions/htpasswd_sha1.rb8
-rw-r--r--templates/vhosts/static/CentOS.erb1
3 files changed, 41 insertions, 1 deletions
diff --git a/manifests/defines/htpasswd.pp b/manifests/defines/htpasswd.pp
new file mode 100644
index 0000000..a24aa20
--- /dev/null
+++ b/manifests/defines/htpasswd.pp
@@ -0,0 +1,33 @@
+# manifests/defines/htpasswd.pp
+
+# ToDo: This should be rewritten as native type
+define apache::htpasswd_user(
+ $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 }
+ }
+ case $password_iscrypted {
+ 'false': { $real_password = htpasswd_sha1($password) }
+ default: { $real_password = $password }
+ }
+
+ line{"htpasswd_for_${real_site}":
+ file => $real_path,
+ line => "${username}:${real_password}",
+ }
+}
diff --git a/plugins/puppet/parser/functions/htpasswd_sha1.rb b/plugins/puppet/parser/functions/htpasswd_sha1.rb
new file mode 100644
index 0000000..937621d
--- /dev/null
+++ b/plugins/puppet/parser/functions/htpasswd_sha1.rb
@@ -0,0 +1,8 @@
+require 'digest/sha1'
+require 'base64'
+
+module Puppet::Parser::Functions
+ newfunction(:htpasswd_sha1, :type => :rvalue) do |args|
+ "{SHA}" + Base64.encode64(Digest::SHA1.digest(args[0]))
+ end
+end
diff --git a/templates/vhosts/static/CentOS.erb b/templates/vhosts/static/CentOS.erb
index 6739e7b..1e93756 100644
--- a/templates/vhosts/static/CentOS.erb
+++ b/templates/vhosts/static/CentOS.erb
@@ -21,7 +21,6 @@
<%- unless additional_options == 'absent' then -%>
<%= additional_options %>
<%- end -%>
-
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F