- $root = '/etc/apt'
- $provider = '/usr/bin/apt-get'
- $refresh_only_apt_update = $always_apt_update? {
- true => false,
- false => true
- }
-
- package { "python-software-properties": }
-
- file { "sources.list":
- name => "${root}/sources.list",
- ensure => present,
- owner => root,
- group => root,
- mode => 644,
- }
-
- file { "sources.list.d":
- name => "${root}/sources.list.d",
- ensure => directory,
- owner => root,
- group => root,
- }
-
- exec { "apt_update":
- command => "${apt::params::provider} update",
- subscribe => [ File["sources.list"], File["sources.list.d"] ],
- refreshonly => $refresh_only_apt_update,
- }
- if($disable_keys) {
- exec { 'make-apt-insecure':
- command => '/bin/echo "APT::Get::AllowUnauthenticated 1;" >> /etc/apt/apt.conf.d/99unauth',
- creates => '/etc/apt/apt.conf.d/99unauth'
+ if $::osfamily != 'Debian' {
+ fail('This module only works on Debian or derivatives like Ubuntu')
+ }
+
+ include apt::params
+ include apt::update
+
+ validate_bool($purge_sources_list, $purge_sources_list_d,
+ $purge_preferences, $purge_preferences_d)
+
+ $sources_list_content = $purge_sources_list ? {
+ false => undef,
+ true => "# Repos managed by puppet.\n",
+ }
+
+ if $always_apt_update == true {
+ Exec <| title=='apt_update' |> {
+ refreshonly => false,
+ }
+ }
+
+ $root = $apt::params::root
+ $apt_conf_d = $apt::params::apt_conf_d
+ $sources_list_d = $apt::params::sources_list_d
+ $preferences_d = $apt::params::preferences_d
+ $provider = $apt::params::provider
+
+ file { 'sources.list':
+ ensure => present,
+ path => "${root}/sources.list",
+ owner => root,
+ group => root,
+ mode => '0644',
+ content => $sources_list_content,
+ notify => Exec['apt_update'],
+ }
+
+ file { 'sources.list.d':
+ ensure => directory,
+ path => $sources_list_d,
+ owner => root,
+ group => root,
+ purge => $purge_sources_list_d,
+ recurse => $purge_sources_list_d,
+ notify => Exec['apt_update'],
+ }
+
+ if $purge_preferences {
+ file { 'apt-preferences':
+ ensure => absent,
+ path => "${root}/preferences",
+ }
+ }
+
+ file { 'preferences.d':
+ ensure => directory,
+ path => $preferences_d,
+ owner => root,
+ group => root,
+ purge => $purge_preferences_d,
+ recurse => $purge_preferences_d,
+ }
+
+ case $disable_keys {
+ true: {
+ file { '99unauth':
+ ensure => present,
+ content => "APT::Get::AllowUnauthenticated 1;\n",
+ path => "${apt_conf_d}/99unauth",
+ }