Report abuse

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
# Configure Apt for example repository

define apt::key($ensure) {
        # adding or deleting keys
        $apt_key_url = "http://apt.example.com/apt/keys"
        case $ensure {
                "present": {
                        exec { "apt-key present $name":
                                command => "/usr/bin/wget -q $apt_key_url/$name -O -|/usr/bin/apt-key add -",
                                unless => "/usr/bin/apt-key list|/bin/grep -c $name", 
                        }
                }
                "absent": {
                        exec { "apt-key absent $name":
                                command => "/usr/bin/apt-key del $name",
                                onlyif => "/usr/bin/apt-key list|/bin/grep -c $name", 
                        }
                }
                default: {
                        fail "Invalid 'ensure' value '$ensure' for apt::key"
                }
        }
}

class apt::examplekeys {
        # just a collection
        # define any key you want to be present or absent here
        apt::key{ "458F2AD8":
                # sysop demi god
                ensure => "present",
        }
}


class apt {
        include apt::examplekeys

        exec { "apt-get-update":
                # refreshonly => true,
                command => "/usr/bin/apt-get update",
                require => Class["apt::examplekeys"],
        }

        # Source Repositories
        file { "/etc/apt/sources.list":
                owner   => "root",
                group   => "root",
                mode    => 0444,
                ensure  => "present",
                content => template("apt/sources.list.erb"),
                notify => Exec["apt-get-update"],
        }
        file { "/etc/apt/apt.conf":
                owner  => "root",
                group  => "root",
                mode   => 0444,
                ensure => "present",
                source => "puppet:///apt/apt.conf",
                notify => Exec["apt-get-update"],
        }
}