define site::aptrepo ($key = undef, $keyid = undef, $template = undef, $config = undef, $ensure = present) {
+
case $ensure {
present: {
if $key {
}
} elsif $keyid {
exec { "apt-key-del-${keyid}":
- command => "apt-key del ${keyid}",
+ command => "apt-key del ${keyid}",
}
}
}
if ! ($config or $template) {
fail ( "No configuration found for ${name}" )
}
- if ($config and $template) {
- fail ( "Can't specify both config and template for ${name}" )
- }
}
- file { "/etc/apt/sources.list.d/${name}.list":
- ensure => $ensure,
- content => template($template),
- source => $config,
- notify => Exec['apt-get update'],
+ if $template {
+ file { "/etc/apt/sources.list.d/${name}.list":
+ ensure => $ensure,
+ content => template($template),
+ notify => Exec['apt-get update'],
+ }
+ } else {
+ file { "/etc/apt/sources.list.d/${name}.list":
+ ensure => $ensure,
+ source => $config,
+ notify => Exec['apt-get update'],
+ }
}
}