Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use fact() function for all os.distro.* facts #1017

Merged
merged 2 commits into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ Default value: ``undef``
Data type: `Optional[String]`

Specifies a distribution of the Apt repository containing the backports to manage. Used in populating the `source.list` configuration file.
Default: on Debian and Ubuntu, `${facts['os']['distro']['codename']}-backports`. We recommend keeping this default, except on other operating
Default: on Debian and Ubuntu, `${fact('os.distro.codename')}-backports`. We recommend keeping this default, except on other operating
systems.

Default value: ``undef``
Expand Down Expand Up @@ -814,7 +814,7 @@ Data type: `Optional[String]`
Specifies the operating system of your node. Valid options: a string containing a valid LSB distribution codename.
Optional if `puppet facts show os.distro.codename` returns your correct distribution release codename.

Default value: `$facts['os']['distro']['codename']`
Default value: `fact('os.distro.codename')`

##### <a name="dist"></a>`dist`

Expand Down Expand Up @@ -935,8 +935,8 @@ The following parameters are available in the `apt::source` defined type:
* [`pin`](#pin)
* [`architecture`](#architecture)
* [`allow_unsigned`](#allow_unsigned)
* [`allow_insecure`](#allow_insecure)
* [`notify_update`](#notify_update)
* [`allow_insecure`](#allow_insecure)

##### <a name="location"></a>`location`

Expand Down Expand Up @@ -1037,23 +1037,21 @@ Specifies whether to authenticate packages from this release, even if the Releas

Default value: ``false``

##### <a name="allow_insecure"></a>`allow_insecure`
##### <a name="notify_update"></a>`notify_update`

Data type: `Boolean`

Specifies whether to authenticate packages from this release, even if the Release file is not signed or the signature can't be checked.
Unlike the `allow_unsigned` (trusted=yes) option, this should throw a warning that the interaction is insecure.
See [this comment](https://unix.stackexchange.com/a/480550) for a brief discussion of the difference and why this option might be preferable to `allow_unsigned`.
Specifies whether to trigger an `apt-get update` run.

Default value: ``false``
Default value: ``true``

##### <a name="notify_update"></a>`notify_update`
##### <a name="allow_insecure"></a>`allow_insecure`

Data type: `Boolean`

Specifies whether to trigger an `apt-get update` run.

Default value: ``true``

Default value: ``false``

## Resource types

Expand Down
8 changes: 6 additions & 2 deletions manifests/backports.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#
# @param release
# Specifies a distribution of the Apt repository containing the backports to manage. Used in populating the `source.list` configuration file.
# Default: on Debian and Ubuntu, `${facts['os']['distro']['codename']}-backports`. We recommend keeping this default, except on other operating
# Default: on Debian and Ubuntu, `${fact('os.distro.codename')}-backports`. We recommend keeping this default, except on other operating
# systems.
#
# @param repos
Expand Down Expand Up @@ -79,7 +79,11 @@
$_location = $::apt::backports['location']
}
unless $release {
$_release = "${facts['os']['distro']['codename']}-backports"
if fact('os.distro.codename') {
$_release = "${fact('os.distro.codename')}-backports"
} else {
fail('os.distro.codename fact not available: release parameter required')
}
}
unless $repos {
$_repos = $::apt::backports['repos']
Expand Down
2 changes: 1 addition & 1 deletion manifests/ppa.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
define apt::ppa(
String $ensure = 'present',
Optional[String] $options = $::apt::ppa_options,
Optional[String] $release = $facts['os']['distro']['codename'],
Optional[String] $release = fact('os.distro.codename'),
Optional[String] $dist = $facts['os']['name'],
Optional[String] $package_name = $::apt::ppa_package,
Boolean $package_manage = false,
Expand Down
6 changes: 3 additions & 3 deletions manifests/source.pp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@
$_before = Apt::Setting["list-${title}"]

if !$release {
if $facts['os']['distro']['codename'] {
$_release = $facts['os']['distro']['codename']
if fact('os.distro.codename') {
$_release = fact('os.distro.codename')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very strictly speaking, this line doesn't need to be modified since at this point you know it's available. But it works too.

} else {
fail('os.distro.codename fact not available: release parameter required')
}
Expand All @@ -100,7 +100,7 @@
}
# Newer oses, do not need the package for HTTPS transport.
$_transport_https_releases = [ 'wheezy', 'jessie', 'stretch', 'trusty', 'xenial' ]
if ($facts['os']['distro']['codename'] in $_transport_https_releases) and $_location =~ /(?i:^https:\/\/)/ {
if (fact('os.distro.codename') in $_transport_https_releases) and $_location =~ /(?i:^https:\/\/)/ {
ensure_packages('apt-transport-https')
Package['apt-transport-https'] -> Class['apt::update']
}
Expand Down