summaryrefslogtreecommitdiffstats
path: root/lib/puppet/type/computer.rb
blob: 0888325a8e98359212316b4afac5e62aa66896bd (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
57
58
59
60
61
62
Puppet::Type.newtype(:computer) do
    
    @doc = "Computer object management using DirectoryService
      on OS X.

      Note that these are distinctly different kinds of objects to 'hosts',
      as they require a MAC address and can have all sorts of policy attached to
      them.

      This provider only manages Computer objects in the local directory service
      domain, not in remote directories.

      If you wish to manage /etc/hosts on Mac OS X, then simply use the host
      type as per other platforms.

      This type primarily exists to create localhost Computer objects that MCX
      policy can then be attached to."
    
    # ensurable
    
    # We autorequire the computer object in case it is being managed at the
    # file level by Puppet.
    
    autorequire(:file) do
        if self[:name]
            "/var/db/dslocal/nodes/Default/computers/#{self[:name]}.plist"
        else
            nil
        end
    end
    
    newproperty(:ensure, :parent => Puppet::Property::Ensure) do
        desc "Control the existences of this computer record. Set this attribute to
            ``present`` to ensure the computer record exists.  Set it to ``absent``
            to delete any computer records with this name"
        newvalue(:present) do
            provider.create
        end

        newvalue(:absent) do
            provider.delete
        end
    end
    
    newparam(:name) do
        desc "The authoritative 'short' name of the computer record."
        isnamevar
    end
    
    newparam(:realname) do
        desc "The 'long' name of the computer record."
    end
        
    newproperty(:en_address) do
        desc "The MAC address of the primary network interface. Must match en0."
    end
    
    newproperty(:ip_address) do
        desc "The IP Address of the Computer object."
    end
    
end