Skip to content

Commit

Permalink
eliminate params.pp and create_resources()
Browse files Browse the repository at this point in the history
params.pp and create_resources() are obsolete.

This module was converted to non-params.pp style puppetlabs#667, but was
reverted in puppetlabs#680. Using Hiera in modules and no params.pp are the
preferred styles these days.
  • Loading branch information
kenyon committed Apr 9, 2024
1 parent aa9e518 commit 2faa817
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 174 deletions.
3 changes: 3 additions & 0 deletions data/os/Debian.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
apt::backports:
location: http://deb.debian.org/debian
repos: main contrib non-free
7 changes: 7 additions & 0 deletions data/os/Ubuntu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apt::backports:
location: http://archive.ubuntu.com/ubuntu
repos: main universe multiverse restricted

apt::ppa_options:
- -y
apt::ppa_package: software-properties-common
168 changes: 106 additions & 62 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,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:
Expand Down Expand Up @@ -85,22 +85,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
Expand All @@ -113,7 +113,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.
Expand All @@ -137,9 +137,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`
Expand All @@ -148,47 +149,79 @@
# 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 $provider = '/usr/bin/apt-get',
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')
}
Expand Down Expand Up @@ -342,30 +375,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 {
Expand All @@ -390,9 +433,10 @@
}
}

# manage pins if present
if $pins {
create_resources('apt::pin', $pins)
$pins.each |$key, $value| {
apt::pin { $key:
* => $value,
}
}

case $facts['os']['name'] {
Expand Down
107 changes: 0 additions & 107 deletions manifests/params.pp

This file was deleted.

Loading

0 comments on commit 2faa817

Please sign in to comment.