diff options
author | Micah <micah@leap.se> | 2016-05-24 10:19:22 -0400 |
---|---|---|
committer | Micah <micah@leap.se> | 2016-05-24 10:19:22 -0400 |
commit | d5e5d2f82a403fe507e7c58a6373d693f0906a1e (patch) | |
tree | 6ce4341b8b4c7fc78e53abab365afe069bf0d8ca /puppet/modules/apt/manifests/sources_list.pp | |
parent | 8166111831b79d426964440cd355d57ee33878f7 (diff) | |
parent | aba291e2de1682620b6dc22446b30fe870b62956 (diff) |
Merge commit 'aba291e2de1682620b6dc22446b30fe870b62956' as 'puppet/modules/apt'
Diffstat (limited to 'puppet/modules/apt/manifests/sources_list.pp')
-rw-r--r-- | puppet/modules/apt/manifests/sources_list.pp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/puppet/modules/apt/manifests/sources_list.pp b/puppet/modules/apt/manifests/sources_list.pp new file mode 100644 index 00000000..0ee068d1 --- /dev/null +++ b/puppet/modules/apt/manifests/sources_list.pp @@ -0,0 +1,40 @@ +define apt::sources_list ( + $ensure = 'present', + $source = '', + $content = undef +) { + + if $ensure == 'present' { + if $source == '' and $content == undef { + fail("One of \$source or \$content must be specified for apt_sources_snippet ${name}") + } + if $source != '' and $content != undef { + fail("Only one of \$source or \$content must specified for apt_sources_snippet ${name}") + } + } + + include apt::dot_d_directories + + $realname = regsubst($name, '\.list$', '') + + # One would expect the 'file' resource on sources.list.d to trigger an + # apt-get update when files are added or modified in the directory, but it + # apparently doesn't. + file { "/etc/apt/sources.list.d/${realname}.list": + ensure => $ensure, + owner => root, group => 0, mode => '0644', + notify => Exec['apt_updated'], + } + + if $source { + File["/etc/apt/sources.list.d/${realname}.list"] { + source => $source, + } + } + else { + File["/etc/apt/sources.list.d/${realname}.list"] { + content => $content, + } + } +} + |