summaryrefslogtreecommitdiffstats
path: root/lib/puppet/type/maillist.rb
blob: 088004a1cb2b388dd65fab6627bb7683d71fd8c4 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
module Puppet
    newtype(:maillist) do
        @doc = "Manage email lists.  This resource type currently can only create
            and remove lists, it cannot reconfigure them."
        
        ensurable do
            defaultvalues

            newvalue(:purged) do
                provider.purge
            end
        end

        newparam(:name, :namevar => true) do
            desc "The name of the email list."
        end

        newparam(:description) do
            desc "The description of the mailing list."
        end

        newparam(:password) do
            desc "The admin password."
        end

        newparam(:webserver) do
            desc "The name of the host providing web archives and the administrative interface."
        end

        newparam(:mailserver) do
            desc "The name of the host handling email for the list."
        end

        newparam(:admin) do
            desc "The email address of the administrator."
        end

        def generate
            if provider.respond_to?(:aliases)
                should = self.should(:ensure) || :present
                if should == :purged
                    should = :absent
                end
                atype = Puppet::Type.type(:mailalias)
                return provider.aliases.collect do |name, recipient|
                    if atype[name]
                        nil
                    else
                        malias = Puppet::Type.type(:mailalias).new(:name => name, :recipient => recipient, :ensure => should)
                    end
                end.compact
            end
        end
    end
end