diff --git a/data/os/Debian.yaml b/data/os/Debian.yaml new file mode 100644 index 0000000000..e7cc38af75 --- /dev/null +++ b/data/os/Debian.yaml @@ -0,0 +1,3 @@ +apt::backports: + location: http://deb.debian.org/debian + repos: main contrib non-free diff --git a/data/os/Ubuntu.yaml b/data/os/Ubuntu.yaml new file mode 100644 index 0000000000..827c7235f8 --- /dev/null +++ b/data/os/Ubuntu.yaml @@ -0,0 +1,6 @@ +apt::backports: + location: http://archive.ubuntu.com/ubuntu + repos: main universe multiverse restricted + +apt::ppa_options: -y +apt::ppa_package: software-properties-common diff --git a/manifests/init.pp b/manifests/init.pp index 8de99d5fcb..70591ae327 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -2,9 +2,6 @@ # # @see https://docs.puppetlabs.com/references/latest/function.html#createresources for the create resource function # -# @param provider -# Specifies the provider that should be used by apt::update. -# # @param keyserver # Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://, or # hkp://). @@ -31,7 +28,7 @@ # See apt::backports for documentation. # # @param confs -# Creates new `apt::conf` resources. Valid options: a hash to be passed to the create_resources function linked above. +# Hash of `apt::conf` resources. # # @param update # Configures various update settings. Valid options: a hash made up from the following keys: @@ -85,22 +82,22 @@ # The default proxy settings that are combined and merged with the passed `proxy` value # # @param sources -# Creates new `apt::source` resources. Valid options: a hash to be passed to the create_resources function linked above. +# Hash of `apt::source` resources. # # @param keys -# Creates new `apt::key` resources. Valid options: a hash to be passed to the create_resources function linked above. +# Hash of `apt::key` resources. # # @param keyrings # Hash of `apt::keyring` resources. # # @param ppas -# Creates new `apt::ppa` resources. Valid options: a hash to be passed to the create_resources function linked above. +# Hash of `apt::ppa` resources. # # @param pins -# Creates new `apt::pin` resources. Valid options: a hash to be passed to the create_resources function linked above. +# Hash of `apt::pin` resources. # # @param settings -# Creates new `apt::setting` resources. Valid options: a hash to be passed to the create_resources function linked above. +# Hash of `apt::setting` resources. # # @param manage_auth_conf # Specifies whether to manage the /etc/apt/auth.conf file. When true, the file will be overwritten with the entries specified in @@ -113,7 +110,7 @@ # password and no others. Specifying manage_auth_conf and not specifying this parameter will set /etc/apt/auth.conf to absent. # # @param auth_conf_owner -# The owner of the file /etc/apt/auth.conf. Default: '_apt' or 'root' on old releases. +# The owner of the file /etc/apt/auth.conf. # # @param root # Specifies root directory of Apt executable. @@ -137,9 +134,10 @@ # A hash made up of the various configuration files used by Apt. # # @param sources_list_force -# Specifies whether to perform force purge or delete. Default false. +# Specifies whether to perform force purge or delete. # # @param include_defaults +# The package types to include by default. # # @param apt_conf_d # The path to the file `apt.conf.d` @@ -148,47 +146,78 @@ # The fault `source_key` settings # class apt ( - Hash $update_defaults = $apt::params::update_defaults, - Hash $purge_defaults = $apt::params::purge_defaults, - Hash $proxy_defaults = $apt::params::proxy_defaults, - 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[Array[String]] $ppa_options = $apt::params::ppa_options, - Optional[String] $ppa_package = $apt::params::ppa_package, - Optional[Hash] $backports = $apt::params::backports, - Hash $confs = $apt::params::confs, - Hash $update = $apt::params::update, - Hash $purge = $apt::params::purge, - Apt::Proxy $proxy = $apt::params::proxy, - Hash $sources = $apt::params::sources, - Hash $keys = $apt::params::keys, - Hash $keyrings = {}, - Hash $ppas = $apt::params::ppas, - Hash $pins = $apt::params::pins, - Hash $settings = $apt::params::settings, - Boolean $manage_auth_conf = $apt::params::manage_auth_conf, - Array[Apt::Auth_conf_entry] $auth_conf_entries = $apt::params::auth_conf_entries, - String $auth_conf_owner = $apt::params::auth_conf_owner, - String $root = $apt::params::root, - String $sources_list = $apt::params::sources_list, - String $sources_list_d = $apt::params::sources_list_d, - 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, - Boolean $sources_list_force = $apt::params::sources_list_force, - + Hash $update_defaults = { + 'frequency' => 'reluctantly', + 'loglevel' => undef, + 'timeout' => undef, + 'tries' => undef, + }, + Hash $purge_defaults = { + 'sources.list' => false, + 'sources.list.d' => false, + 'preferences' => false, + 'preferences.d' => false, + 'apt.conf.d' => false, + }, + Hash $proxy_defaults = { + 'ensure' => undef, + 'host' => undef, + 'port' => 8080, + 'https' => false, + 'https_acng' => false, + 'direct' => false, + }, + Hash $include_defaults = { + 'deb' => true, + 'src' => false, + }, + String $keyserver = 'keyserver.ubuntu.com', + Optional[String] $key_options = undef, + Optional[Array[String]] $ppa_options = undef, + Optional[String] $ppa_package = undef, + Optional[Hash] $backports = undef, + Hash $confs = {}, + Hash $update = {}, + Hash $purge = {}, + Apt::Proxy $proxy = {}, + Hash $sources = {}, + Hash $keys = {}, + Hash $keyrings = {}, + Hash $ppas = {}, + Hash $pins = {}, + Hash $settings = {}, + Boolean $manage_auth_conf = true, + Array[Apt::Auth_conf_entry] $auth_conf_entries = [], + String $auth_conf_owner = '_apt', + String $root = '/etc/apt', + String $sources_list = "${root}/sources.list", + String $sources_list_d = "${root}/sources.list.d", + String $conf_d = "${root}/apt.conf.d", + String $preferences = "${root}/preferences", + String $preferences_d = "${root}/preferences.d", + String $apt_conf_d = "${root}/apt.conf.d", + Hash $config_files = { + 'conf' => { + 'path' => $conf_d, + 'ext' => '', + }, + 'pref' => { + 'path' => $preferences_d, + 'ext' => '.pref', + }, + 'list' => { + 'path' => $sources_list_d, + 'ext' => '.list', + }, + }, + Boolean $sources_list_force = false, Hash $source_key_defaults = { 'server' => $keyserver, 'options' => undef, 'content' => undef, 'source' => undef, - } - -) inherits apt::params { + }, +) { if $facts['os']['family'] != 'Debian' { fail('This module only works on Debian or derivatives like Ubuntu') } @@ -342,30 +371,40 @@ notify => Class['apt::update'], } - if $confs { - create_resources('apt::conf', $confs) + $confs.each |$key, $value| { + apt::conf { $key: + * => $value, + } } - # manage sources if present - if $sources { - create_resources('apt::source', $sources) + + $sources.each |$key, $value| { + apt::source { $key: + * => $value, + } } - # manage keys if present - if $keys { - create_resources('apt::key', $keys) + + $keys.each |$key, $value| { + apt::key { $key: + * => $value, + } } - # manage keyrings if present + $keyrings.each |$key, $data| { apt::keyring { $key: * => $data, } } - # manage ppas if present - if $ppas { - create_resources('apt::ppa', $ppas) + + $ppas.each |$key, $value| { + apt::ppa { $key: + * => $value, + } } - # manage settings if present - if $settings { - create_resources('apt::setting', $settings) + + $settings.each |$key, $value| { + apt::setting { $key: + * => $value, + } } if $manage_auth_conf { @@ -390,9 +429,10 @@ } } - # manage pins if present - if $pins { - create_resources('apt::pin', $pins) + $pins.each |$key, $value| { + apt::pin { $key: + * => $value, + } } case $facts['os']['name'] { diff --git a/manifests/params.pp b/manifests/params.pp deleted file mode 100644 index c2fe0b48b1..0000000000 --- a/manifests/params.pp +++ /dev/null @@ -1,107 +0,0 @@ -# @summary Provides defaults for the Apt module parameters. -# -# @api private -# -class apt::params { - if $facts['os']['family'] != 'Debian' { - fail('This module only works on Debian or derivatives like Ubuntu') - } - - $root = '/etc/apt' - $provider = '/usr/bin/apt-get' - $sources_list = "${root}/sources.list" - $sources_list_force = false - $sources_list_d = "${root}/sources.list.d" - $trusted_gpg_d = "${root}/trusted.gpg.d" - $conf_d = "${root}/apt.conf.d" - $preferences = "${root}/preferences" - $preferences_d = "${root}/preferences.d" - $apt_conf_d = "${root}/apt.conf.d" - $keyserver = 'keyserver.ubuntu.com' - $key_options = undef - $confs = {} - $update = {} - $purge = {} - $proxy = {} - $sources = {} - $keys = {} - $ppas = {} - $pins = {} - $settings = {} - $manage_auth_conf = true - $auth_conf_entries = [] - - $config_files = { - 'conf' => { - 'path' => $conf_d, - 'ext' => '', - }, - 'pref' => { - 'path' => $preferences_d, - 'ext' => '.pref', - }, - 'list' => { - 'path' => $sources_list_d, - 'ext' => '.list', - }, - } - - $update_defaults = { - 'frequency' => 'reluctantly', - 'loglevel' => undef, - 'timeout' => undef, - 'tries' => undef, - } - - $proxy_defaults = { - 'ensure' => undef, - 'host' => undef, - 'port' => 8080, - 'https' => false, - 'https_acng' => false, - 'direct' => false, - } - - $purge_defaults = { - 'sources.list' => false, - 'sources.list.d' => false, - 'preferences' => false, - 'preferences.d' => false, - 'apt.conf.d' => false, - } - - $include_defaults = { - 'deb' => true, - 'src' => false, - } - - case $facts['os']['name'] { - 'Debian': { - $backports = { - 'location' => 'http://deb.debian.org/debian', - 'repos' => 'main contrib non-free', - } - $ppa_options = undef - $ppa_package = undef - $auth_conf_owner = '_apt' - } - 'Ubuntu': { - $backports = { - 'location' => 'http://archive.ubuntu.com/ubuntu', - 'repos' => 'main universe multiverse restricted', - } - $ppa_options = ['-y'] - $ppa_package = 'software-properties-common' - $auth_conf_owner = '_apt' - } - undef: { - fail('Unable to determine value for fact os[\"name\"]') - } - default: { - $ppa_options = undef - $ppa_package = undef - $backports = undef - $auth_conf_owner = 'root' - } - } -} diff --git a/manifests/source.pp b/manifests/source.pp index 70f78e17d0..776c5f7a43 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -28,7 +28,7 @@ # Supplies a comment for adding to the Apt source file. # # @param ensure -# Specifies whether the Apt source file should exist. Valid options: 'present' and 'absent'. +# Specifies whether the Apt source file should exist. # # @param release # Specifies a distribution of the Apt repository. @@ -40,10 +40,10 @@ # Configures include options. Valid options: a hash of available keys. # # @option include [Boolean] :deb -# Specifies whether to request the distribution's compiled binaries. Default true. +# Specifies whether to request the distribution's compiled binaries. # # @option include [Boolean] :src -# Specifies whether to request the distribution's uncompiled source code. Default false. +# Specifies whether to request the distribution's uncompiled source code. # # @param key # Creates an `apt::keyring` in `/etc/apt/keyrings` (or anywhere on disk given `filename`) Valid options: @@ -77,7 +77,7 @@ # Specifies whether to trigger an `apt-get update` run. # # @param check_valid_until -# Specifies whether to check if the package release date is valid. Defaults to `True`. +# Specifies whether to check if the package release date is valid. # define apt::source ( Optional[String] $location = undef, @@ -248,6 +248,9 @@ } else { fail('Received invalid value for pin parameter') } - create_resources('apt::pin', { "${name}" => $_pin }) + + apt::pin { $name: + * => $_pin, + } } }