Add the prosody module
[mirror/dsa-puppet.git] / 3rdparty / modules / prosody / templates / virtualhost.cfg.erb
diff --git a/3rdparty/modules/prosody/templates/virtualhost.cfg.erb b/3rdparty/modules/prosody/templates/virtualhost.cfg.erb
new file mode 100644 (file)
index 0000000..ffb369d
--- /dev/null
@@ -0,0 +1,56 @@
+VirtualHost "<%= @name %>"
+<% if @ensure == 'present' -%>
+  enabled = true
+<% else -%>
+  enabled = false
+<% end -%>
+
+<% if (@ssl_key != 'UNSET') && (@ssl_cert != 'UNSET') -%>
+  -- Assign this host a certificate for TLS, otherwise it would use the one
+  -- set in the global section (if any).
+  -- Note that old-style SSL on port 5223 only supports one certificate, and will always
+  -- use the global one.
+  ssl = {
+    key = "<%= @prosody_ssl_key %>";
+    certificate = "<%= @prosody_ssl_cert %>";
+  }
+<% end -%>
+
+<%- if @custom_options != {} -%>
+<%-
+def print_recursive(object, indentation = 0)
+  case object
+  when Array
+    '{ "' + object.join('"; "') + '" }'
+  when Hash
+    "{\n" + ' ' * (indentation + 2) + object.map {|k,v| + "#{k} = " + print_recursive(v, indentation + 2)}.join(";\n" + ' ' * (indentation + 2)) + ";\n" + (' ' * indentation) + '}'
+  when TrueClass, FalseClass
+    object.to_s
+  else
+    '"' + object.to_s + '"'
+  end
+end
+-%>
+------ Custom config options ------
+<%- @custom_options.sort.each do |option, value| -%>
+<%= option %> = <%= print_recursive(value) %>
+<%- end; end -%>
+
+<%- if @components != {} -%>
+------ Components ------
+-- You can specify components to add hosts that provide special services,
+-- like multi-user conferences, and transports.
+-- For more information on components, see http://prosody.im/doc/components
+
+<% @components.sort.each do |name, component| %>
+Component "<%= name %>" <% if component.include?('type') then %>"<%= component['type'] %>"<% end %>
+  <%- if component.include?('secret') -%>
+  component_secret = "<%= component['secret'] %>"
+  <%- end -%>
+  <%- if component.include?('options') -%>
+    <%- component['options'].sort.each do |k, v| -%>
+  <%= k %> = <%= v %>;
+    <%- end -%>
+  <%- end -%>
+<% end -%>
+<% end -%>