do not specify file modes unless relevant
[puppet-modules/puppetlabs-apt.git] / manifests / init.pp
index d95bbe60b2225c20e9c40b236f73a22ee7d1e5e9..d2aead96112f26cf31a8d11bb51c8d207317d367 100644 (file)
@@ -9,6 +9,9 @@
 #   Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://, or
 #   hkp://).
 #
+# @param key_options
+#   Specifies the default options for apt::key resources.
+#
 # @param ppa_options
 #   Supplies options to be passed to the `add-apt-repository` command.
 #
@@ -122,6 +125,7 @@ class apt (
   Hash $include_defaults        = $apt::params::include_defaults,
   String $provider              = $apt::params::provider,
   String $keyserver             = $apt::params::keyserver,
+  Optional[String] $key_options = $apt::params::key_options,
   Optional[String] $ppa_options = $apt::params::ppa_options,
   Optional[String] $ppa_package = $apt::params::ppa_package,
   Optional[Hash] $backports     = $apt::params::backports,
@@ -144,6 +148,7 @@ class apt (
   String $conf_d                = $apt::params::conf_d,
   String $preferences           = $apt::params::preferences,
   String $preferences_d         = $apt::params::preferences_d,
+  String $apt_conf_d            = $apt::params::apt_conf_d,
   Hash $config_files            = $apt::params::config_files,
   Hash $source_key_defaults     = $apt::params::source_key_defaults,
 ) inherits apt::params {
@@ -180,6 +185,9 @@ class apt (
   if $purge['preferences.d'] {
     assert_type(Boolean, $purge['preferences.d'])
   }
+  if $purge['apt.conf.d'] {
+    assert_type(Boolean, $purge['apt.conf.d'])
+  }
 
   $_purge = merge($::apt::purge_defaults, $purge)
   $_proxy = merge($apt::proxy_defaults, $proxy)
@@ -196,9 +204,9 @@ class apt (
     }
   }
 
-  $sources_list_content = $_purge['sources.list'] ? {
-    true    => "# Repos managed by puppet.\n",
-    default => undef,
+  $sources_list_ensure = $_purge['sources.list'] ? {
+    true    => absent,
+    default => file,
   }
 
   $preferences_ensure = $_purge['preferences'] ? {
@@ -218,13 +226,11 @@ class apt (
   }
 
   file { 'sources.list':
-    ensure  => file,
-    path    => $::apt::sources_list,
-    owner   => root,
-    group   => root,
-    mode    => '0644',
-    content => $sources_list_content,
-    notify  => Class['apt::update'],
+    ensure => $sources_list_ensure,
+    path   => $::apt::sources_list,
+    owner  => root,
+    group  => root,
+    notify => Class['apt::update'],
   }
 
   file { 'sources.list.d':
@@ -232,7 +238,6 @@ class apt (
     path    => $::apt::sources_list_d,
     owner   => root,
     group   => root,
-    mode    => '0644',
     purge   => $_purge['sources.list.d'],
     recurse => $_purge['sources.list.d'],
     notify  => Class['apt::update'],
@@ -243,7 +248,6 @@ class apt (
     path   => $::apt::preferences,
     owner  => root,
     group  => root,
-    mode   => '0644',
     notify => Class['apt::update'],
   }
 
@@ -252,12 +256,21 @@ class apt (
     path    => $::apt::preferences_d,
     owner   => root,
     group   => root,
-    mode    => '0644',
     purge   => $_purge['preferences.d'],
     recurse => $_purge['preferences.d'],
     notify  => Class['apt::update'],
   }
 
+  file { 'apt.conf.d':
+    ensure  => directory,
+    path    => $::apt::apt_conf_d,
+    owner   => root,
+    group   => root,
+    purge   => $_purge['apt.conf.d'],
+    recurse => $_purge['apt.conf.d'],
+    notify  => Class['apt::update'],
+  }
+
   if $confs {
     create_resources('apt::conf', $confs)
   }
@@ -302,5 +315,5 @@ class apt (
   }
 
   # required for adding GPG keys on Debian 9 (and derivatives)
-  ensure_packages(['dirmngr'])
+  ensure_packages(['gnupg'])
 }