Skip to content

Commit 2faa817

Browse files
committed
eliminate params.pp and create_resources()
params.pp and create_resources() are obsolete. This module was converted to non-params.pp style #667, but was reverted in #680. Using Hiera in modules and no params.pp are the preferred styles these days.
1 parent aa9e518 commit 2faa817

File tree

5 files changed

+124
-174
lines changed

5 files changed

+124
-174
lines changed

data/os/Debian.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
apt::backports:
2+
location: http://deb.debian.org/debian
3+
repos: main contrib non-free

data/os/Ubuntu.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apt::backports:
2+
location: http://archive.ubuntu.com/ubuntu
3+
repos: main universe multiverse restricted
4+
5+
apt::ppa_options:
6+
- -y
7+
apt::ppa_package: software-properties-common

manifests/init.pp

+106-62
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
# See apt::backports for documentation.
3232
#
3333
# @param confs
34-
# Creates new `apt::conf` resources. Valid options: a hash to be passed to the create_resources function linked above.
34+
# Hash of `apt::conf` resources.
3535
#
3636
# @param update
3737
# Configures various update settings. Valid options: a hash made up from the following keys:
@@ -85,22 +85,22 @@
8585
# The default proxy settings that are combined and merged with the passed `proxy` value
8686
#
8787
# @param sources
88-
# Creates new `apt::source` resources. Valid options: a hash to be passed to the create_resources function linked above.
88+
# Hash of `apt::source` resources.
8989
#
9090
# @param keys
91-
# Creates new `apt::key` resources. Valid options: a hash to be passed to the create_resources function linked above.
91+
# Hash of `apt::key` resources.
9292
#
9393
# @param keyrings
9494
# Hash of `apt::keyring` resources.
9595
#
9696
# @param ppas
97-
# Creates new `apt::ppa` resources. Valid options: a hash to be passed to the create_resources function linked above.
97+
# Hash of `apt::ppa` resources.
9898
#
9999
# @param pins
100-
# Creates new `apt::pin` resources. Valid options: a hash to be passed to the create_resources function linked above.
100+
# Hash of `apt::pin` resources.
101101
#
102102
# @param settings
103-
# Creates new `apt::setting` resources. Valid options: a hash to be passed to the create_resources function linked above.
103+
# Hash of `apt::setting` resources.
104104
#
105105
# @param manage_auth_conf
106106
# Specifies whether to manage the /etc/apt/auth.conf file. When true, the file will be overwritten with the entries specified in
@@ -113,7 +113,7 @@
113113
# password and no others. Specifying manage_auth_conf and not specifying this parameter will set /etc/apt/auth.conf to absent.
114114
#
115115
# @param auth_conf_owner
116-
# The owner of the file /etc/apt/auth.conf. Default: '_apt' or 'root' on old releases.
116+
# The owner of the file /etc/apt/auth.conf.
117117
#
118118
# @param root
119119
# Specifies root directory of Apt executable.
@@ -137,9 +137,10 @@
137137
# A hash made up of the various configuration files used by Apt.
138138
#
139139
# @param sources_list_force
140-
# Specifies whether to perform force purge or delete. Default false.
140+
# Specifies whether to perform force purge or delete.
141141
#
142142
# @param include_defaults
143+
# The package types to include by default.
143144
#
144145
# @param apt_conf_d
145146
# The path to the file `apt.conf.d`
@@ -148,47 +149,79 @@
148149
# The fault `source_key` settings
149150
#
150151
class apt (
151-
Hash $update_defaults = $apt::params::update_defaults,
152-
Hash $purge_defaults = $apt::params::purge_defaults,
153-
Hash $proxy_defaults = $apt::params::proxy_defaults,
154-
Hash $include_defaults = $apt::params::include_defaults,
155-
String $provider = $apt::params::provider,
156-
String $keyserver = $apt::params::keyserver,
157-
Optional[String] $key_options = $apt::params::key_options,
158-
Optional[Array[String]] $ppa_options = $apt::params::ppa_options,
159-
Optional[String] $ppa_package = $apt::params::ppa_package,
160-
Optional[Hash] $backports = $apt::params::backports,
161-
Hash $confs = $apt::params::confs,
162-
Hash $update = $apt::params::update,
163-
Hash $purge = $apt::params::purge,
164-
Apt::Proxy $proxy = $apt::params::proxy,
165-
Hash $sources = $apt::params::sources,
166-
Hash $keys = $apt::params::keys,
167-
Hash $keyrings = {},
168-
Hash $ppas = $apt::params::ppas,
169-
Hash $pins = $apt::params::pins,
170-
Hash $settings = $apt::params::settings,
171-
Boolean $manage_auth_conf = $apt::params::manage_auth_conf,
172-
Array[Apt::Auth_conf_entry] $auth_conf_entries = $apt::params::auth_conf_entries,
173-
String $auth_conf_owner = $apt::params::auth_conf_owner,
174-
String $root = $apt::params::root,
175-
String $sources_list = $apt::params::sources_list,
176-
String $sources_list_d = $apt::params::sources_list_d,
177-
String $conf_d = $apt::params::conf_d,
178-
String $preferences = $apt::params::preferences,
179-
String $preferences_d = $apt::params::preferences_d,
180-
String $apt_conf_d = $apt::params::apt_conf_d,
181-
Hash $config_files = $apt::params::config_files,
182-
Boolean $sources_list_force = $apt::params::sources_list_force,
183-
152+
Hash $update_defaults = {
153+
'frequency' => 'reluctantly',
154+
'loglevel' => undef,
155+
'timeout' => undef,
156+
'tries' => undef,
157+
},
158+
Hash $purge_defaults = {
159+
'sources.list' => false,
160+
'sources.list.d' => false,
161+
'preferences' => false,
162+
'preferences.d' => false,
163+
'apt.conf.d' => false,
164+
},
165+
Hash $proxy_defaults = {
166+
'ensure' => undef,
167+
'host' => undef,
168+
'port' => 8080,
169+
'https' => false,
170+
'https_acng' => false,
171+
'direct' => false,
172+
},
173+
Hash $include_defaults = {
174+
'deb' => true,
175+
'src' => false,
176+
},
177+
String $provider = '/usr/bin/apt-get',
178+
String $keyserver = 'keyserver.ubuntu.com',
179+
Optional[String] $key_options = undef,
180+
Optional[Array[String]] $ppa_options = undef,
181+
Optional[String] $ppa_package = undef,
182+
Optional[Hash] $backports = undef,
183+
Hash $confs = {},
184+
Hash $update = {},
185+
Hash $purge = {},
186+
Apt::Proxy $proxy = {},
187+
Hash $sources = {},
188+
Hash $keys = {},
189+
Hash $keyrings = {},
190+
Hash $ppas = {},
191+
Hash $pins = {},
192+
Hash $settings = {},
193+
Boolean $manage_auth_conf = true,
194+
Array[Apt::Auth_conf_entry] $auth_conf_entries = [],
195+
String $auth_conf_owner = '_apt',
196+
String $root = '/etc/apt',
197+
String $sources_list = "${root}/sources.list",
198+
String $sources_list_d = "${root}/sources.list.d",
199+
String $conf_d = "${root}/apt.conf.d",
200+
String $preferences = "${root}/preferences",
201+
String $preferences_d = "${root}/preferences.d",
202+
String $apt_conf_d = "${root}/apt.conf.d",
203+
Hash $config_files = {
204+
'conf' => {
205+
'path' => $conf_d,
206+
'ext' => '',
207+
},
208+
'pref' => {
209+
'path' => $preferences_d,
210+
'ext' => '.pref',
211+
},
212+
'list' => {
213+
'path' => $sources_list_d,
214+
'ext' => '.list',
215+
},
216+
},
217+
Boolean $sources_list_force = false,
184218
Hash $source_key_defaults = {
185219
'server' => $keyserver,
186220
'options' => undef,
187221
'content' => undef,
188222
'source' => undef,
189-
}
190-
191-
) inherits apt::params {
223+
},
224+
) {
192225
if $facts['os']['family'] != 'Debian' {
193226
fail('This module only works on Debian or derivatives like Ubuntu')
194227
}
@@ -342,30 +375,40 @@
342375
notify => Class['apt::update'],
343376
}
344377

345-
if $confs {
346-
create_resources('apt::conf', $confs)
378+
$confs.each |$key, $value| {
379+
apt::conf { $key:
380+
* => $value,
381+
}
347382
}
348-
# manage sources if present
349-
if $sources {
350-
create_resources('apt::source', $sources)
383+
384+
$sources.each |$key, $value| {
385+
apt::source { $key:
386+
* => $value,
387+
}
351388
}
352-
# manage keys if present
353-
if $keys {
354-
create_resources('apt::key', $keys)
389+
390+
$keys.each |$key, $value| {
391+
apt::key { $key:
392+
* => $value,
393+
}
355394
}
356-
# manage keyrings if present
395+
357396
$keyrings.each |$key, $data| {
358397
apt::keyring { $key:
359398
* => $data,
360399
}
361400
}
362-
# manage ppas if present
363-
if $ppas {
364-
create_resources('apt::ppa', $ppas)
401+
402+
$ppas.each |$key, $value| {
403+
apt::ppa { $key:
404+
* => $value,
405+
}
365406
}
366-
# manage settings if present
367-
if $settings {
368-
create_resources('apt::setting', $settings)
407+
408+
$settings.each |$key, $value| {
409+
apt::setting { $key:
410+
* => $value,
411+
}
369412
}
370413

371414
if $manage_auth_conf {
@@ -390,9 +433,10 @@
390433
}
391434
}
392435

393-
# manage pins if present
394-
if $pins {
395-
create_resources('apt::pin', $pins)
436+
$pins.each |$key, $value| {
437+
apt::pin { $key:
438+
* => $value,
439+
}
396440
}
397441

398442
case $facts['os']['name'] {

manifests/params.pp

-107
This file was deleted.

0 commit comments

Comments
 (0)