From 39dfae9463b9c1287278fce87b6ee726ae1a7378 Mon Sep 17 00:00:00 2001 From: Kenyon Ralph Date: Sat, 19 Dec 2020 21:14:38 -0800 Subject: [PATCH 1/8] whitespace cleanup --- locales/ja/puppetlabs-apt.po | 4 ++-- manifests/backports.pp | 17 ++++++++--------- manifests/ppa.pp | 6 +++--- manifests/source.pp | 12 ++++++------ 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/locales/ja/puppetlabs-apt.po b/locales/ja/puppetlabs-apt.po index b5f4765141..aa6b266486 100644 --- a/locales/ja/puppetlabs-apt.po +++ b/locales/ja/puppetlabs-apt.po @@ -3,9 +3,9 @@ # Copyright (C) 2018 Puppet, Inc. # This file is distributed under the same license as the puppetlabs-apt package. # FIRST AUTHOR , 2018. -# +# # #-#-#-#-# puppetlabs-apt_metadata.pot (PACKAGE VERSION) #-#-#-#-# -# +# #, fuzzy msgid "" msgstr "" diff --git a/manifests/backports.pp b/manifests/backports.pp index 21f1251ea7..b3cb74b522 100644 --- a/manifests/backports.pp +++ b/manifests/backports.pp @@ -12,7 +12,7 @@ # } # # @param location -# Specifies an Apt repository containing the backports to manage. Valid options: a string containing a URL. Default value for Debian and +# Specifies an Apt repository containing the backports to manage. Valid options: a string containing a URL. Default value for Debian and # Ubuntu varies: # # - Debian: 'http://deb.debian.org/debian' @@ -20,20 +20,20 @@ # - Ubuntu: 'http://archive.ubuntu.com/ubuntu' # # @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, '${lsbdistcodename}-backports'. We recommend keeping this default, except on other operating +# 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, '${lsbdistcodename}-backports'. We recommend keeping this default, except on other operating # systems. # # @param repos -# Specifies a component of the Apt repository containing the backports to manage. Used in populating the `source.list` configuration file. +# Specifies a component of the Apt repository containing the backports to manage. Used in populating the `source.list` configuration file. # Default value for Debian and Ubuntu varies: -# +# # - Debian: 'main contrib non-free' # # - Ubuntu: 'main universe multiverse restricted' # # @param key -# Specifies a key to authenticate the backports. Valid options: a string to be passed to the id parameter of the apt::key defined type, or a +# Specifies a key to authenticate the backports. Valid options: a string to be passed to the id parameter of the apt::key defined type, or a # hash of parameter => value pairs to be passed to apt::key's id, server, content, source, and/or options parameters. Default value # for Debian and Ubuntu varies: # @@ -42,7 +42,7 @@ # - Ubuntu: '630239CC130E1A7FD81A27B140976EAF437D05B5' # # @param pin -# Specifies a pin priority for the backports. Valid options: a number or string to be passed to the `id` parameter of the `apt::pin` defined +# Specifies a pin priority for the backports. Valid options: a number or string to be passed to the `id` parameter of the `apt::pin` defined # type, or a hash of `parameter => value` pairs to be passed to `apt::pin`'s corresponding parameters. # # @param include @@ -55,8 +55,7 @@ Optional[Variant[String, Hash]] $key = undef, Optional[Variant[Integer, String, Hash]] $pin = 200, Optional[Variant[Hash]] $include = {}, -){ - +) { include apt if $location { diff --git a/manifests/ppa.pp b/manifests/ppa.pp index ba05485c31..f7c78fc820 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -4,17 +4,17 @@ # apt::ppa{ 'ppa:openstack-ppa/bleeding-edge': } # # @param ensure -# Specifies whether the PPA should exist. Valid options: 'present' and 'absent'. +# Specifies whether the PPA should exist. Valid options: 'present' and 'absent'. # # @param options # Supplies options to be passed to the `add-apt-repository` command. Default: '-y'. # # @param release -# Optional if lsb-release is installed (unless you're using a different release than indicated by lsb-release, e.g., Linux Mint). +# Optional if lsb-release is installed (unless you're using a different release than indicated by lsb-release, e.g., Linux Mint). # Specifies the operating system of your node. Valid options: a string containing a valid LSB distribution codename. # # @param dist -# Optional if lsb-release is installed (unless you're using a different release than indicated by lsb-release, e.g., Linux Mint). +# Optional if lsb-release is installed (unless you're using a different release than indicated by lsb-release, e.g., Linux Mint). # Specifies the distribution of your node. Valid options: a string containing a valid distribution codename. # # @param package_name diff --git a/manifests/source.pp b/manifests/source.pp index 365ba13ded..8cbde99ee8 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -27,7 +27,7 @@ # # @param include # 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. # @@ -35,17 +35,17 @@ # Specifies whether to request the distribution's uncompiled source code. Default false. # # @param key -# Creates a declaration of the apt::key defined type. Valid options: a string to be passed to the `id` parameter of the `apt::key` -# defined type, or a hash of `parameter => value` pairs to be passed to `apt::key`'s `id`, `server`, `content`, `source`, and/or +# Creates a declaration of the apt::key defined type. Valid options: a string to be passed to the `id` parameter of the `apt::key` +# defined type, or a hash of `parameter => value` pairs to be passed to `apt::key`'s `id`, `server`, `content`, `source`, and/or # `options` parameters. # # @param pin -# Creates a declaration of the apt::pin defined type. Valid options: a number or string to be passed to the `id` parameter of the +# Creates a declaration of the apt::pin defined type. Valid options: a number or string to be passed to the `id` parameter of the # `apt::pin` defined type, or a hash of `parameter => value` pairs to be passed to `apt::pin`'s corresponding parameters. # # @param architecture -# Tells Apt to only download information for specified architectures. Valid options: a string containing one or more architecture names, -# separated by commas (e.g., 'i386' or 'i386,alpha,powerpc'). Default: undef (if unspecified, Apt downloads information for all architectures +# Tells Apt to only download information for specified architectures. Valid options: a string containing one or more architecture names, +# separated by commas (e.g., 'i386' or 'i386,alpha,powerpc'). Default: undef (if unspecified, Apt downloads information for all architectures # defined in the Apt::Architectures option). # # @param allow_unsigned From 7e31732abd277c852564c10011099bdf6967dc4f Mon Sep 17 00:00:00 2001 From: Kenyon Ralph Date: Sat, 19 Dec 2020 22:31:48 -0800 Subject: [PATCH 2/8] manifests: use modern os facts --- README.md | 36 +++-- REFERENCE.md | 10 +- examples/source.pp | 2 +- locales/ja/puppetlabs-apt.po | 4 +- locales/puppetlabs-apt.pot | 2 +- manifests/backports.pp | 6 +- manifests/init.pp | 2 +- manifests/params.pp | 4 +- manifests/ppa.pp | 14 +- manifests/source.pp | 8 +- readmes/README_ja_JP.md | 15 +- spec/classes/apt_backports_spec.rb | 100 ++++++++---- spec/classes/apt_spec.rb | 241 +++++++++++++++++++++-------- spec/classes/apt_update_spec.rb | 112 ++++++++++---- spec/defines/conf_spec.rb | 16 +- spec/defines/key_compat_spec.rb | 15 +- spec/defines/key_spec.rb | 16 +- spec/defines/mark_spec.rb | 16 +- spec/defines/pin_spec.rb | 16 +- spec/defines/ppa_spec.rb | 200 ++++++++++++++++-------- spec/defines/setting_spec.rb | 34 ++-- spec/defines/source_compat_spec.rb | 31 +++- spec/defines/source_spec.rb | 80 +++++++--- 23 files changed, 689 insertions(+), 291 deletions(-) diff --git a/README.md b/README.md index 53f0228cba..19b50adb1c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ #### Table of Contents - 1. [Module Description - What the module does and why it is useful](#module-description) 1. [Setup - The basics of getting started with apt](#setup) * [What apt affects](#what-apt-affects) @@ -20,6 +19,7 @@ 1. [Development - Guide for contributing to the module](#development) + ## Module Description The apt module lets you use Puppet to manage APT (Advanced Package Tool) sources, keys, and other configuration options. @@ -29,9 +29,11 @@ APT is a package manager available on Debian, Ubuntu, and several other operatin **Note**: For this module to correctly autodetect which version of Debian/Ubuntu (or derivative) you're running, you need to make sure the 'lsb-release' package is installed. We highly recommend you either make this part of your provisioning layer, if you run many Debian or derivative systems, or ensure that you have Facter 2.2.0 or later installed, which will pull this dependency in for you. + ## Setup + ### What apt affects * Your system's `preferences` file and `preferences.d` directory @@ -43,6 +45,7 @@ APT is a package manager available on Debian, Ubuntu, and several other operatin **Note:** This module offers `purge` parameters which, if set to `true`, **destroy** any configuration on the node's `sources.list(.d)`, `preferences(.d)` and `apt.conf.d` that you haven't declared through Puppet. The default for these parameters is `false`. + ### Beginning with apt To use the apt module with default parameters, declare the `apt` class. @@ -54,9 +57,11 @@ include apt **Note:** The main `apt` class is required by all other classes, types, and defined types in this module. You must declare it whenever you use the module. + ## Usage + ### Add GPG keys **Warning:** Using short key IDs presents a serious security issue, potentially leaving you open to collision attacks. We recommend you always use full fingerprints to identify your GPG keys. This module allows short keys, but issues a security warning if you use them. @@ -72,6 +77,7 @@ apt::key { 'puppetlabs': ``` + ### Prioritize backports ```puppet @@ -85,9 +91,10 @@ By default, the `apt::backports` class drops a pin file for backports, pinning i If you raise the priority through the `pin` parameter to 500, normal policy goes into effect and Apt installs or upgrades to the newest version. This means that if a package is available from backports, it and its dependencies are pulled in from backports unless you explicitly set the `ensure` attribute of the `package` resource to `installed`/`present` or a specific version. + ### Update the list of packages -By default, Puppet runs `apt-get update` on the first Puppet run after you include the `apt` class, and anytime `notify => Exec['apt_update']` occurs; i.e., whenever config files get updated or other relevant changes occur. If you set `update['frequency']` to 'always', the update runs on every Puppet run. You can also set `update['frequency']` to 'daily' or 'weekly': +By default, Puppet runs `apt-get update` on the first Puppet run after you include the `apt` class, and anytime `notify => Exec['apt_update']` occurs; i.e., whenever config files get updated or other relevant changes occur. If you set `update['frequency']` to 'always', the update runs on every Puppet run. You can also set `update['frequency']` to 'daily' or 'weekly': ```puppet class { 'apt': @@ -96,6 +103,7 @@ class { 'apt': }, } ``` + When `Exec['apt_update']` is triggered, it generates a `notice`-level message. Because the default [logging level for agents](https://puppet.com/docs/puppet/latest/configuration.html#loglevel) is `notice`, this causes the repository update to appear in agent logs. To silence these updates from the default log output, set the [loglevel](https://puppet.com/docs/puppet/latest/metaparameter.html#loglevel) metaparameter for `Exec['apt_update']` above the agent logging level: ```puppet @@ -110,6 +118,7 @@ class { 'apt': > **NOTE:** Every `Exec['apt_update']` run will generate a corrective change, even if the apt caches are not updated. For example, setting an update frequency of `always` can result in every Puppet run resulting in a corrective change. This is a known issue. For details, see [MODULES-10763](https://tickets.puppetlabs.com/browse/MODULES-10763). + ### Pin a specific release ```puppet @@ -133,6 +142,7 @@ apt::pin { 'stable': To pin multiple packages, pass them to the `packages` parameter as an array or a space-delimited string. + ### Add a Personal Package Archive (PPA) repository ```puppet @@ -173,6 +183,7 @@ apt::source { 'puppetlabs': ``` + ### Configure Apt from Hiera Instead of specifying your sources directly as resources, you can instead just include the `apt` class, which will pick up the values automatically from hiera. @@ -201,36 +212,37 @@ apt::sources: ``` + ### Replace the default `sources.list` file The following example replaces the default `/etc/apt/sources.list`. Along with this code, be sure to use the `purge` parameter, or you might get duplicate source warnings when running Apt. ```puppet -apt::source { "archive.ubuntu.com-${lsbdistcodename}": +apt::source { "archive.ubuntu.com-${facts['os']['distro']['codename']}": location => 'http://archive.ubuntu.com/ubuntu', key => '630239CC130E1A7FD81A27B140976EAF437D05B5', repos => 'main universe multiverse restricted', } -apt::source { "archive.ubuntu.com-${lsbdistcodename}-security": +apt::source { "archive.ubuntu.com-${facts['os']['distro']['codename']}-security": location => 'http://archive.ubuntu.com/ubuntu', key => '630239CC130E1A7FD81A27B140976EAF437D05B5', repos => 'main universe multiverse restricted', - release => "${lsbdistcodename}-security" + release => "${facts['os']['distro']['codename']}-security" } -apt::source { "archive.ubuntu.com-${lsbdistcodename}-updates": +apt::source { "archive.ubuntu.com-${facts['os']['distro']['codename']}-updates": location => 'http://archive.ubuntu.com/ubuntu', key => '630239CC130E1A7FD81A27B140976EAF437D05B5', repos => 'main universe multiverse restricted', - release => "${lsbdistcodename}-updates" + release => "${facts['os']['distro']['codename']}-updates" } -apt::source { "archive.ubuntu.com-${lsbdistcodename}-backports": +apt::source { "archive.ubuntu.com-${facts['os']['distro']['codename']}-backports": location => 'http://archive.ubuntu.com/ubuntu', key => '630239CC130E1A7FD81A27B140976EAF437D05B5', repos => 'main universe multiverse restricted', - release => "${lsbdistcodename}-backports" + release => "${facts['os']['distro']['codename']}-backports" } ``` @@ -264,6 +276,7 @@ class { 'apt': ``` + ## Reference ### Facts @@ -288,7 +301,8 @@ class { 'apt': See [REFERENCE.md](https://github.com/puppetlabs/puppetlabs-apt/blob/main/REFERENCE.md) for all other reference documentation. - + + ## Limitations This module is not designed to be split across [run stages](https://docs.puppetlabs.com/puppet/latest/reference/lang_run_stages.html). @@ -306,7 +320,7 @@ Class['apt::update'] -> Package <| provider == 'apt' |> ## Development Acceptance tests for this module leverage [puppet_litmus](https://github.com/puppetlabs/puppet_litmus). -To run the acceptance tests follow the instructions [here](https://github.com/puppetlabs/puppet_litmus/wiki/Tutorial:-use-Litmus-to-execute-acceptance-tests-with-a-sample-module-(MoTD)#install-the-necessary-gems-for-the-module). +To run the acceptance tests follow the instructions [here](). You can also find a tutorial and walkthrough of using Litmus and the PDK on [YouTube](https://www.youtube.com/watch?v=FYfR7ZEGHoE). If you run into an issue with this module, or if you would like to request a feature, please [file a ticket](https://tickets.puppetlabs.com/browse/MODULES/). diff --git a/REFERENCE.md b/REFERENCE.md index dc1e5edd7a..13f5f9ae5e 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -386,7 +386,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, '${lsbdistcodename}-backports'. We recommend keeping this default, except on other operating +Default: on Debian and Ubuntu, `${facts['os']['distro']['codename']}-backports`. We recommend keeping this default, except on other operating systems. Default value: ``undef`` @@ -729,19 +729,19 @@ Default value: `$::apt::ppa_options` Data type: `Optional[String]` -Optional if lsb-release is installed (unless you're using a different release than indicated by lsb-release, e.g., Linux Mint). 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['lsbdistcodename']` +Default value: `$facts['os']['distro']['codename']` ##### `dist` Data type: `Optional[String]` -Optional if lsb-release is installed (unless you're using a different release than indicated by lsb-release, e.g., Linux Mint). Specifies the distribution of your node. Valid options: a string containing a valid distribution codename. +Optional if `puppet facts show os.name` returns your correct distribution name. -Default value: `$facts['lsbdistid']` +Default value: `$facts['os']['name']` ##### `package_name` diff --git a/examples/source.pp b/examples/source.pp index a3648c3efb..3e381266f3 100644 --- a/examples/source.pp +++ b/examples/source.pp @@ -2,7 +2,7 @@ class { 'apt': } # Install the puppetlabs apt source -# Release is automatically obtained from lsbdistcodename fact if available. +# Release is automatically obtained from facts. apt::source { 'puppetlabs': location => 'http://apt.puppetlabs.com', repos => 'main', diff --git a/locales/ja/puppetlabs-apt.po b/locales/ja/puppetlabs-apt.po index aa6b266486..1fe9d1d840 100644 --- a/locales/ja/puppetlabs-apt.po +++ b/locales/ja/puppetlabs-apt.po @@ -69,8 +69,8 @@ msgid "parameters release and origin are mutually exclusive" msgstr "パラメータreleaseとoriginは相互に排他的です。" #. ./manifests/ppa.pp:30 ./manifests/source.pp:79 -msgid "lsbdistcodename fact not available: release parameter required" -msgstr "lsbdistcodenameのfactが使用できません。releaseパラメータが必要です。" +msgid "os.distro.codename fact not available: release parameter required" +msgstr "os.distro.codenameのfactが使用できません。releaseパラメータが必要です。" #. ./manifests/ppa.pp:34 msgid "apt::ppa is not currently supported on Debian." diff --git a/locales/puppetlabs-apt.pot b/locales/puppetlabs-apt.pot index 5701be9422..5fa70e28e9 100644 --- a/locales/puppetlabs-apt.pot +++ b/locales/puppetlabs-apt.pot @@ -92,7 +92,7 @@ msgid "parameters release and origin are mutually exclusive" msgstr "" #. ./manifests/ppa.pp:30 ./manifests/source.pp:79 -msgid "lsbdistcodename fact not available: release parameter required" +msgid "os.distro.codename fact not available: release parameter required" msgstr "" #. ./manifests/ppa.pp:34 diff --git a/manifests/backports.pp b/manifests/backports.pp index b3cb74b522..5949905c5e 100644 --- a/manifests/backports.pp +++ b/manifests/backports.pp @@ -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, '${lsbdistcodename}-backports'. We recommend keeping this default, except on other operating +# Default: on Debian and Ubuntu, `${facts['os']['distro']['codename']}-backports`. We recommend keeping this default, except on other operating # systems. # # @param repos @@ -70,7 +70,7 @@ if $key { $_key = $key } - if (!($facts['lsbdistid'] == 'Debian' or $facts['lsbdistid'] == 'Ubuntu')) { + if (!($facts['os']['name'] == 'Debian' or $facts['os']['name'] == 'Ubuntu')) { unless $location and $release and $repos and $key { fail(translate('If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key')) } @@ -79,7 +79,7 @@ $_location = $::apt::backports['location'] } unless $release { - $_release = "${facts['lsbdistcodename']}-backports" + $_release = "${facts['os']['distro']['codename']}-backports" } unless $repos { $_repos = $::apt::backports['repos'] diff --git a/manifests/init.pp b/manifests/init.pp index ea4e828267..a20748f436 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -157,7 +157,7 @@ Boolean $sources_list_force = $apt::params::sources_list_force, ) inherits apt::params { - if $facts['osfamily'] != 'Debian' { + if $facts['os']['family'] != 'Debian' { fail(translate('This module only works on Debian or derivatives like Ubuntu')) } diff --git a/manifests/params.pp b/manifests/params.pp index c648c4ef99..9a9257702a 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,10 +1,10 @@ # @summary Provides defaults for the Apt module parameters. -# +# # @api private # class apt::params { - if $::osfamily != 'Debian' { + if $facts['os']['family'] != 'Debian' { fail(translate('This module only works on Debian or derivatives like Ubuntu')) } diff --git a/manifests/ppa.pp b/manifests/ppa.pp index f7c78fc820..6a874ce3dc 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -10,12 +10,12 @@ # Supplies options to be passed to the `add-apt-repository` command. Default: '-y'. # # @param release -# Optional if lsb-release is installed (unless you're using a different release than indicated by lsb-release, e.g., Linux Mint). # 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. # # @param dist -# Optional if lsb-release is installed (unless you're using a different release than indicated by lsb-release, e.g., Linux Mint). # Specifies the distribution of your node. Valid options: a string containing a valid distribution codename. +# Optional if `puppet facts show os.name` returns your correct distribution name. # # @param package_name # Names the package that provides the `apt-add-repository` command. Default: 'software-properties-common'. @@ -26,20 +26,20 @@ define apt::ppa( String $ensure = 'present', Optional[String] $options = $::apt::ppa_options, - Optional[String] $release = $facts['lsbdistcodename'], - Optional[String] $dist = $facts['lsbdistid'], + Optional[String] $release = $facts['os']['distro']['codename'], + Optional[String] $dist = $facts['os']['name'], Optional[String] $package_name = $::apt::ppa_package, Boolean $package_manage = false, ) { unless $release { - fail(translate('lsbdistcodename fact not available: release parameter required')) + fail(translate('os.distro.codename fact not available: release parameter required')) } if $dist == 'Debian' { fail(translate('apt::ppa is not currently supported on Debian.')) } - if versioncmp($facts['lsbdistrelease'], '14.10') >= 0 { + if versioncmp($facts['os']['release']['full'], '14.10') >= 0 { $distid = downcase($dist) $dash_filename = regsubst($name, '^ppa:([^/]+)/(.+)$', "\\1-${distid}-\\2") $underscore_filename = regsubst($name, '^ppa:([^/]+)/(.+)$', "\\1_${distid}_\\2") @@ -55,7 +55,7 @@ $sources_list_d_filename = "${dash_filename_no_specialchars}-${release}.list" - if versioncmp($facts['lsbdistrelease'], '15.10') >= 0 { + if versioncmp($facts['os']['release']['full'], '15.10') >= 0 { $trusted_gpg_d_filename = "${underscore_filename_no_specialchars}.gpg" } else { $trusted_gpg_d_filename = "${dash_filename_no_specialchars}.gpg" diff --git a/manifests/source.pp b/manifests/source.pp index 8cbde99ee8..2c3d4b84cb 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -73,10 +73,10 @@ $_before = Apt::Setting["list-${title}"] if !$release { - if $facts['lsbdistcodename'] { - $_release = $facts['lsbdistcodename'] + if $facts['os']['distro']['codename'] { + $_release = $facts['os']['distro']['codename'] } else { - fail(translate('lsbdistcodename fact not available: release parameter required')) + fail(translate('os.distro.codename fact not available: release parameter required')) } } else { $_release = $release @@ -94,7 +94,7 @@ } # Newer oses, do not need the package for HTTPS transport. $_transport_https_releases = [ 'wheezy', 'jessie', 'stretch', 'trusty', 'xenial' ] - if ($facts['lsbdistcodename'] in $_transport_https_releases) and $_location =~ /(?i:^https:\/\/)/ { + if ($facts['os']['distro']['codename'] in $_transport_https_releases) and $_location =~ /(?i:^https:\/\/)/ { ensure_packages('apt-transport-https') } } else { diff --git a/readmes/README_ja_JP.md b/readmes/README_ja_JP.md index eb0803c781..cf8f6b4157 100644 --- a/readmes/README_ja_JP.md +++ b/readmes/README_ja_JP.md @@ -2,7 +2,6 @@ #### 目次 - 1. [説明 - モジュールの機能とその有益性](#module-description) 1. [セットアップ - apt導入の基本](#setup) * [aptが影響を与えるもの](#what-apt-affects) @@ -191,31 +190,31 @@ apt::sources: デフォルトの`/etc/apt/sources.list`を置き換える例を以下に示します。以下のコードと合わせて、`purge`パラメータを必ず使用してください。使用しない場合、Apt実行時にソース重複の警告が出ます。 ```puppet -apt::source { "archive.ubuntu.com-${lsbdistcodename}": +apt::source { "archive.ubuntu.com-${facts['os']['distro']['codename']}": location => 'http://archive.ubuntu.com/ubuntu', key => '630239CC130E1A7FD81A27B140976EAF437D05B5', repos => 'main universe multiverse restricted', } -apt::source { "archive.ubuntu.com-${lsbdistcodename}-security": +apt::source { "archive.ubuntu.com-${facts['os']['distro']['codename']}-security": location => 'http://archive.ubuntu.com/ubuntu', key => '630239CC130E1A7FD81A27B140976EAF437D05B5', repos => 'main universe multiverse restricted', - release => "${lsbdistcodename}-security" + release => "${facts['os']['distro']['codename']}-security" } -apt::source { "archive.ubuntu.com-${lsbdistcodename}-updates": +apt::source { "archive.ubuntu.com-${facts['os']['distro']['codename']}-updates": location => 'http://archive.ubuntu.com/ubuntu', key => '630239CC130E1A7FD81A27B140976EAF437D05B5', repos => 'main universe multiverse restricted', - release => "${lsbdistcodename}-updates" + release => "${facts['os']['distro']['codename']}-updates" } -apt::source { "archive.ubuntu.com-${lsbdistcodename}-backports": +apt::source { "archive.ubuntu.com-${facts['os']['distro']['codename']}-backports": location => 'http://archive.ubuntu.com/ubuntu', key => '630239CC130E1A7FD81A27B140976EAF437D05B5', repos => 'main universe multiverse restricted', - release => "${lsbdistcodename}-backports" + release => "${facts['os']['distro']['codename']}-backports" } ``` diff --git a/spec/classes/apt_backports_spec.rb b/spec/classes/apt_backports_spec.rb index 57e8a060a2..795344001f 100644 --- a/spec/classes/apt_backports_spec.rb +++ b/spec/classes/apt_backports_spec.rb @@ -9,10 +9,18 @@ context 'with defaults on deb' do let(:facts) do { - os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, - lsbdistid: 'Debian', - osfamily: 'Debian', - lsbdistcodename: 'jessie', + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '8', + full: '8.0', + }, + distro: { + codename: 'jessie', + id: 'Debian', + }, + }, } end @@ -26,11 +34,18 @@ context 'with defaults on ubuntu' do let(:facts) do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, - lsbdistid: 'Ubuntu', - osfamily: 'Debian', - lsbdistcodename: 'xenial', - lsbdistrelease: '16.04', + os: { + family: 'Debian', + name: 'Ubuntu', + release: { + major: '16', + full: '16.04', + }, + distro: { + codename: 'xenial', + id: 'Ubuntu', + }, + }, } end @@ -45,11 +60,18 @@ context 'with everything set' do let(:facts) do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, - lsbdistid: 'Ubuntu', - osfamily: 'Debian', - lsbdistcodename: 'xenial', - lsbdistrelease: '16.04', + os: { + family: 'Debian', + name: 'Ubuntu', + release: { + major: '16', + full: '16.04', + }, + distro: { + codename: 'xenial', + id: 'Ubuntu', + }, + }, } end let(:params) do @@ -73,11 +95,18 @@ context 'when set things with hashes' do let(:facts) do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, - lsbdistid: 'Ubuntu', - osfamily: 'Debian', - lsbdistcodename: 'xenial', - lsbdistrelease: '16.04', + os: { + family: 'Debian', + name: 'Ubuntu', + release: { + major: '16', + full: '16.04', + }, + distro: { + codename: 'xenial', + id: 'Ubuntu', + }, + }, } end let(:params) do @@ -100,10 +129,18 @@ describe 'mint tests' do let(:facts) do { - os: { family: 'Debian', name: 'Linuxmint', release: { major: '17', full: '17' } }, - lsbdistid: 'linuxmint', - osfamily: 'Debian', - lsbdistcodename: 'qiana', + os: { + family: 'Debian', + name: 'Linuxmint', + release: { + major: '17', + full: '17', + }, + distro: { + codename: 'qiana', + id: 'linuxmint', + }, + }, } end @@ -181,11 +218,18 @@ describe 'validation' do let(:facts) do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, - lsbdistid: 'Ubuntu', - osfamily: 'Debian', - lsbdistcodename: 'xenial', - lsbdistrelease: '16.04', + os: { + family: 'Debian', + name: 'Ubuntu', + release: { + major: '16', + full: '16.04', + }, + distro: { + codename: 'xenial', + id: 'Ubuntu', + }, + }, } end diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index f7ab7bcaa3..ca23563f21 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -41,10 +41,18 @@ describe 'apt' do let(:facts) do { - os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, - lsbdistid: 'Debian', - osfamily: 'Debian', - lsbdistcodename: 'jessie', + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '8', + full: '8.0', + }, + distro: { + codename: 'jessie', + id: 'Debian', + }, + }, } end @@ -273,49 +281,102 @@ context 'with entries for /etc/apt/auth.conf' do facts_hash = { 'Ubuntu 14.04' => { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } }, - osfamily: 'Debian', - lsbdistcodename: 'trusty', - lsbdistid: 'Ubuntu', - lsbdistrelease: '14.04', + os: { + family: 'Debian', + name: 'Ubuntu', + release: { + major: '14', + full: '14.04', + }, + distro: { + codename: 'trusty', + id: 'Ubuntu', + }, + }, }, 'Ubuntu 16.04' => { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, - osfamily: 'Debian', - lsbdistcodename: 'xenial', - lsbdistid: 'Ubuntu', - lsbdistrelease: '16.04', + os: { + family: 'Debian', + name: 'Ubuntu', + release: { + major: '16', + full: '16.04', + }, + distro: { + codename: 'xenial', + id: 'Ubuntu', + }, + }, }, 'Ubuntu 18.04' => { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '18', full: '18.04' } }, - osfamily: 'Debian', - lsbdistcodename: 'bionic', - lsbdistid: 'Ubuntu', - lsbdistrelease: '18.04', + os: { + family: 'Debian', + name: 'Ubuntu', + release: { + major: '18', + full: '18.04', + }, + distro: { + codename: 'bionic', + id: 'Ubuntu', + }, + }, }, 'Debian 7.0' => { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, - lsbdistid: 'Debian', - osfamily: 'Debian', - lsbdistcodename: 'wheezy', + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '7', + full: '7.0', + }, + distro: { + codename: 'wheezy', + id: 'Debian', + }, + }, }, 'Debian 8.0' => { - os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, - lsbdistid: 'Debian', - osfamily: 'Debian', - lsbdistcodename: 'jessie', + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '8', + full: '8.0', + }, + distro: { + codename: 'jessie', + id: 'Debian', + }, + }, }, 'Debian 9.0' => { - os: { family: 'Debian', name: 'Debian', release: { major: '9', full: '9.0' } }, - lsbdistid: 'Debian', - osfamily: 'Debian', - lsbdistcodename: 'stretch', + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '9', + full: '9.0', + }, + distro: { + codename: 'stretch', + id: 'Debian', + }, + }, }, 'Debian 10.0' => { - os: { family: 'Debian', name: 'Debian', release: { major: '10', full: '10.0' } }, - lsbdistid: 'Debian', - osfamily: 'Debian', - lsbdistcodename: 'buster', + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '10', + full: '10.0', + }, + distro: { + codename: 'buster', + id: 'Debian', + }, + }, }, } @@ -405,14 +466,21 @@ end end - context 'with sources defined on valid osfamily' do + context 'with sources defined on valid os.family' do let :facts do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, - osfamily: 'Debian', - lsbdistcodename: 'xenial', - lsbdistid: 'Ubuntu', - lsbdistrelease: '16.04', + os: { + family: 'Debian', + name: 'Ubuntu', + release: { + major: '16', + full: '16.04', + }, + distro: { + codename: 'xenial', + id: 'Ubuntu', + }, + }, } end let(:params) do @@ -447,13 +515,21 @@ it { is_expected.to contain_file('/etc/apt/sources.list.d/puppetlabs.list').with_content(%r{^deb http://apt.puppetlabs.com xenial main$}) } end - context 'with confs defined on valid osfamily' do + context 'with confs defined on valid os.family' do let :facts do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, - osfamily: 'Debian', - lsbdistcodename: 'xenial', - lsbdistid: 'Ubuntu', + os: { + family: 'Debian', + name: 'Ubuntu', + release: { + major: '16', + full: '16.04', + }, + distro: { + codename: 'xenial', + id: 'Ubuntu', + }, + }, } end let(:params) do @@ -476,13 +552,21 @@ } end - context 'with keys defined on valid osfamily' do + context 'with keys defined on valid os.family' do let :facts do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, - osfamily: 'Debian', - lsbdistcodename: 'xenial', - lsbdistid: 'Ubuntu', + os: { + family: 'Debian', + name: 'Ubuntu', + release: { + major: '16', + full: '16.04', + }, + distro: { + codename: 'xenial', + id: 'Ubuntu', + }, + }, } end let(:params) do @@ -505,14 +589,21 @@ } end - context 'with ppas defined on valid osfamily' do + context 'with ppas defined on valid os.family' do let :facts do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, - osfamily: 'Debian', - lsbdistcodename: 'xenial', - lsbdistid: 'Ubuntu', - lsbdistrelease: '16.04', + os: { + family: 'Debian', + name: 'Ubuntu', + release: { + major: '16', + full: '16.04', + }, + distro: { + codename: 'xenial', + id: 'Ubuntu', + }, + }, } end let(:params) do @@ -526,13 +617,21 @@ it { is_expected.to contain_apt__ppa('ppa:nginx/stable') } end - context 'with settings defined on valid osfamily' do + context 'with settings defined on valid os.family' do let :facts do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, - osfamily: 'Debian', - lsbdistcodename: 'xenial', - lsbdistid: 'Ubuntu', + os: { + family: 'Debian', + name: 'Ubuntu', + release: { + major: '16', + full: '16.04', + }, + distro: { + codename: 'xenial', + id: 'Ubuntu', + }, + }, } end let(:params) do @@ -546,13 +645,21 @@ it { is_expected.to contain_apt__setting('pref-banana') } end - context 'with pins defined on valid osfamily' do + context 'with pins defined on valid os.family' do let :facts do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, - osfamily: 'Debian', - lsbdistcodename: 'xenial', - lsbdistid: 'Ubuntu', + os: { + family: 'Debian', + name: 'Ubuntu', + release: { + major: '16', + full: '16.04', + }, + distro: { + codename: 'xenial', + id: 'Ubuntu', + }, + }, } end let(:params) do diff --git a/spec/classes/apt_update_spec.rb b/spec/classes/apt_update_spec.rb index 463566b986..c6336a9151 100644 --- a/spec/classes/apt_update_spec.rb +++ b/spec/classes/apt_update_spec.rb @@ -12,11 +12,19 @@ context "when $::apt_update_last_success indicates #{desc}" do let(:facts) do { - os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, - lsbdistid: 'Debian', - osfamily: 'Debian', + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '8', + full: '8.0', + }, + distro: { + codename: 'jessie', + id: 'Debian', + }, + }, apt_update_last_success: factval, - lsbdistcodename: 'jessie', } end let(:pre_condition) do @@ -32,10 +40,18 @@ context 'when $::apt_update_last_success is nil' do let(:facts) do { - os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, - lsbdistid: 'Debian', - osfamily: 'Debian', - lsbdistcodename: 'jessie', + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '8', + full: '8.0', + }, + distro: { + codename: 'jessie', + id: 'Debian', + }, + }, } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => 'always' },}" } @@ -55,11 +71,19 @@ context "when $::apt_update_last_success indicates #{desc}" do let(:facts) do { - os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, - lsbdistid: 'Debian', - osfamily: 'Debian', + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '8', + full: '8.0', + }, + distro: { + codename: 'jessie', + id: 'Debian', + }, + }, apt_update_last_success: factval, - lsbdistcodename: 'jessie', } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" } @@ -73,10 +97,18 @@ context 'when $::apt_update_last_success is nil' do let(:facts) do { - os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, - lsbdistid: 'Debian', - osfamily: 'Debian', - lsbdistcodename: 'jessie', + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '8', + full: '8.0', + }, + distro: { + codename: 'jessie', + id: 'Debian', + }, + }, } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" } @@ -93,11 +125,19 @@ context "when $::apt_update_last_success indicates #{desc}" do let(:facts) do { - os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, - lsbdistid: 'Debian', - osfamily: 'Debian', + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '8', + full: '8.0', + }, + distro: { + codename: 'jessie', + id: 'Debian', + }, + }, apt_update_last_success: factval, - lsbdistcodename: 'jessie', } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" } @@ -111,10 +151,18 @@ context 'when the $::apt_update_last_success fact has a recent value' do let(:facts) do { - os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, - lsbdistid: 'Debian', - osfamily: 'Debian', - lsbdistcodename: 'jessie', + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '8', + full: '8.0', + }, + distro: { + codename: 'jessie', + id: 'Debian', + }, + }, apt_update_last_success: Time.now.to_i, } end @@ -128,10 +176,18 @@ context 'when $::apt_update_last_success is nil' do let(:facts) do { - os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, - lsbdistid: 'Debian', - osfamily: 'Debian', - lsbdistcodename: 'jessie', + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '8', + full: '8.0', + }, + distro: { + codename: 'jessie', + id: 'Debian', + }, + }, apt_update_last_success: nil, } end diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb index 3158c16ef4..310e15ad5e 100644 --- a/spec/defines/conf_spec.rb +++ b/spec/defines/conf_spec.rb @@ -7,10 +7,18 @@ end let(:facts) do { - os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, - lsbdistid: 'Debian', - osfamily: 'Debian', - lsbdistcodename: 'jessie', + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '8', + full: '8.0', + }, + distro: { + codename: 'jessie', + id: 'Debian', + }, + }, } end let :title do diff --git a/spec/defines/key_compat_spec.rb b/spec/defines/key_compat_spec.rb index fc401ba592..e2a76e0b00 100644 --- a/spec/defines/key_compat_spec.rb +++ b/spec/defines/key_compat_spec.rb @@ -25,9 +25,18 @@ def apt_key_example(title) let(:facts) do { - os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, - lsbdistid: 'Debian', - osfamily: 'Debian', + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '8', + full: '8.0', + }, + distro: { + codename: 'jessie', + id: 'Debian', + }, + }, } end diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index 6ad0978ca5..fc40a8632d 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -46,10 +46,18 @@ def absent_apt_key(title) let(:facts) do { - os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, - lsbdistid: 'Debian', - osfamily: 'Debian', - lsbdistcodename: 'jessie', + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '8', + full: '8.0', + }, + distro: { + codename: 'jessie', + id: 'Debian', + }, + }, } end diff --git a/spec/defines/mark_spec.rb b/spec/defines/mark_spec.rb index 922851047f..0d059a5173 100644 --- a/spec/defines/mark_spec.rb +++ b/spec/defines/mark_spec.rb @@ -9,10 +9,18 @@ let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, - lsbdistid: 'Debian', - lsbdistcodename: 'jessie', - osfamily: 'Debian', + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '8', + full: '8.0', + }, + distro: { + codename: 'jessie', + id: 'Debian', + }, + }, } end diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index fd56dbfa1c..1b6ac33c28 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -7,10 +7,18 @@ end let(:facts) do { - os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, - lsbdistid: 'Debian', - osfamily: 'Debian', - lsbdistcodename: 'jessie', + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '8', + full: '8.0', + }, + distro: { + codename: 'jessie', + id: 'Debian', + }, + }, } end let(:title) { 'my_pin' } diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index b0e689e236..43ee7541d7 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -9,12 +9,18 @@ describe 'defaults' do let :facts do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '41.04' } }, - lsbdistrelease: '14.04', - lsbdistcodename: 'trusty', - operatingsystem: 'Ubuntu', - osfamily: 'Debian', - lsbdistid: 'Ubuntu', + os: { + family: 'Debian', + name: 'Ubuntu', + release: { + major: '14', + full: '14.04', + }, + distro: { + codename: 'trusty', + id: 'Ubuntu', + }, + }, } end @@ -33,12 +39,18 @@ describe 'Ubuntu 15.10 sources.list filename' do let :facts do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '15', full: '15.10' } }, - lsbdistrelease: '15.10', - lsbdistcodename: 'wily', - operatingsystem: 'Ubuntu', - osfamily: 'Debian', - lsbdistid: 'Ubuntu', + os: { + family: 'Debian', + name: 'Ubuntu', + release: { + major: '15', + full: '15.10', + }, + distro: { + codename: 'wily', + id: 'Ubuntu', + }, + }, } end @@ -65,12 +77,18 @@ end let :facts do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } }, - lsbdistrelease: '14.04', - lsbdistcodename: 'trusty', - operatingsystem: 'Ubuntu', - osfamily: 'Debian', - lsbdistid: 'Ubuntu', + os: { + family: 'Debian', + name: 'Ubuntu', + release: { + major: '14', + full: '14.04', + }, + distro: { + codename: 'trusty', + id: 'Ubuntu', + }, + }, } end @@ -96,12 +114,18 @@ end let :facts do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } }, - lsbdistrelease: '14.04', - lsbdistcodename: 'trusty', - operatingsystem: 'Ubuntu', - osfamily: 'Debian', - lsbdistid: 'Ubuntu', + os: { + family: 'Debian', + name: 'Ubuntu', + release: { + major: '14', + full: '14.04', + }, + distro: { + codename: 'trusty', + id: 'Ubuntu', + }, + }, } end let :params do @@ -134,12 +158,18 @@ end let :facts do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } }, - lsbdistrelease: '14.04', - lsbdistcodename: 'trusty', - operatingsystem: 'Ubuntu', - lsbdistid: 'Ubuntu', - osfamily: 'Debian', + os: { + family: 'Debian', + name: 'Ubuntu', + release: { + major: '14', + full: '14.04', + }, + distro: { + codename: 'trusty', + id: 'Ubuntu', + }, + }, } end let :params do @@ -170,12 +200,18 @@ end let :facts do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } }, - lsbdistrelease: '14.04', - lsbdistcodename: 'trusty', - operatingsystem: 'Ubuntu', - lsbdistid: 'Ubuntu', - osfamily: 'Debian', + os: { + family: 'Debian', + name: 'Ubuntu', + release: { + major: '14', + full: '14.04', + }, + distro: { + codename: 'trusty', + id: 'Ubuntu', + }, + }, } end let :params do @@ -204,12 +240,18 @@ end let :facts do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } }, - lsbdistrelease: '14.04', - lsbdistcodename: 'trusty', - operatingsystem: 'Ubuntu', - lsbdistid: 'Ubuntu', - osfamily: 'Debian', + os: { + family: 'Debian', + name: 'Ubuntu', + release: { + major: '14', + full: '14.04', + }, + distro: { + codename: 'trusty', + id: 'Ubuntu', + }, + }, } end let :params do @@ -238,12 +280,18 @@ end let :facts do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } }, - lsbdistrelease: '14.04', - lsbdistcodename: 'trusty', - operatingsystem: 'Ubuntu', - lsbdistid: 'Ubuntu', - osfamily: 'Debian', + os: { + family: 'Debian', + name: 'Ubuntu', + release: { + major: '14', + full: '14.04', + }, + distro: { + codename: 'trusty', + id: 'Ubuntu', + }, + }, } end let :params do @@ -270,12 +318,18 @@ end let :facts do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } }, - lsbdistrelease: '14.04', - lsbdistcodename: 'trusty', - operatingsystem: 'Ubuntu', - lsbdistid: 'Ubuntu', - osfamily: 'Debian', + os: { + family: 'Debian', + name: 'Ubuntu', + release: { + major: '14', + full: '14.04', + }, + distro: { + codename: 'trusty', + id: 'Ubuntu', + }, + }, } end let(:title) { 'ppa:user/foo' } @@ -294,30 +348,42 @@ describe 'no release' do let :facts do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } }, - lsbdistrelease: '14.04', - operatingsystem: 'Ubuntu', - lsbdistid: 'Ubuntu', - osfamily: 'Debian', - lsbdistcodeanme: nil, + os: { + family: 'Debian', + name: 'Ubuntu', + release: { + major: '14', + full: '14.04', + }, + distro: { + codename: nil, + id: 'Ubuntu', + }, + }, } end let(:title) { 'ppa:user/foo' } it do - is_expected.to raise_error(Puppet::Error, %r{lsbdistcodename fact not available: release parameter required}) + is_expected.to raise_error(Puppet::Error, %r{os.distro.codename fact not available: release parameter required}) end end describe 'not ubuntu' do let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '6', full: '6.0.7' } }, - lsbdistrelease: '6.0.7', - lsbdistcodename: 'wheezy', - operatingsystem: 'Debian', - lsbdistid: 'debian', - osfamily: 'Debian', + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '6', + full: '6.0.7', + }, + distro: { + codename: 'wheezy', + id: 'Debian', + }, + }, } end let(:title) { 'ppa:user/foo' } diff --git a/spec/defines/setting_spec.rb b/spec/defines/setting_spec.rb index 09cb922d21..a2fef2e24a 100644 --- a/spec/defines/setting_spec.rb +++ b/spec/defines/setting_spec.rb @@ -6,12 +6,18 @@ let(:pre_condition) { 'class { "apt": }' } let :facts do { - os: { distro: { codename: 'jessie' }, family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, - lsbdistrelease: '8.0', - lsbdistcodename: 'jessie', - operatingsystem: 'Debian', - osfamily: 'Debian', - lsbdistid: 'Debian', + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '8', + full: '8.0', + }, + distro: { + codename: 'jessie', + id: 'Debian', + }, + }, } end let(:title) { 'conf-teddybear' } @@ -76,10 +82,18 @@ end let(:facts) do { - os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, - lsbdistid: 'Debian', - osfamily: 'Debian', - lsbdistcodename: 'jessie', + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '8', + full: '8.0', + }, + distro: { + codename: 'jessie', + id: 'Debian', + }, + }, } end let(:title) { 'conf-teddybear' } diff --git a/spec/defines/source_compat_spec.rb b/spec/defines/source_compat_spec.rb index 0c42ef1393..c35b630d04 100644 --- a/spec/defines/source_compat_spec.rb +++ b/spec/defines/source_compat_spec.rb @@ -11,10 +11,18 @@ let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, - lsbdistid: 'Debian', - lsbdistcodename: 'jessie', - osfamily: 'Debian', + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '8', + full: '8.0', + }, + distro: { + codename: 'jessie', + id: 'Debian', + }, + }, } end @@ -104,13 +112,22 @@ context 'with no release' do let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, - osfamily: 'Debian', + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '8', + full: '8.0', + }, + distro: { + id: 'Debian', + }, + }, } end it do - is_expected.to raise_error(Puppet::Error, %r{lsbdistcodename fact not available: release parameter required}) + is_expected.to raise_error(Puppet::Error, %r{os.distro.codename fact not available: release parameter required}) end end end diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 0adcaadf34..94446bfa9f 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -15,11 +15,18 @@ let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, - lsbdistid: 'Debian', - lsbdistcodename: 'jessie', - operatingsystem: 'Debian', - osfamily: 'Debian', + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '8', + full: '8.0', + }, + distro: { + codename: 'jessie', + id: 'Debian', + }, + }, } end @@ -163,10 +170,18 @@ context 'with a https location and custom release, install apt-transport-https' do let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, - lsbdistid: 'Debian', - lsbdistcodename: 'jessie', - osfamily: 'Debian', + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '8', + full: '8.0', + }, + distro: { + codename: 'jessie', + id: 'Debian', + }, + }, puppetversion: Puppet.version, } end @@ -186,10 +201,18 @@ context 'with a https location, do not install apt-transport-https on oses not in list eg buster' do let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '10', full: '10.0' } }, - lsbdistid: 'Debian', - lsbdistcodename: 'buster', - osfamily: 'Debian', + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '10', + full: '10.0', + }, + distro: { + codename: 'buster', + id: 'Debian', + }, + }, } end let :params do @@ -207,10 +230,18 @@ context 'with architecture equals x86_64' do let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, - lsbdistid: 'Debian', - lsbdistcodename: 'wheezy', - osfamily: 'Debian', + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '7', + full: '7.0', + }, + distro: { + codename: 'wheezy', + id: 'Debian', + }, + }, } end let :params do @@ -299,14 +330,23 @@ context 'with no release' do let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, - osfamily: 'Debian', + os: { + family: 'Debian', + name: 'Debian', + release: { + major: '8', + full: '8.0', + }, + distro: { + id: 'Debian', + }, + }, } end let(:params) { { location: 'hello.there' } } it do - is_expected.to raise_error(Puppet::Error, %r{lsbdistcodename fact not available: release parameter required}) + is_expected.to raise_error(Puppet::Error, %r{os.distro.codename fact not available: release parameter required}) end end From 76718ebdae90cc61ecfb61a35cf2e98e7cebddb7 Mon Sep 17 00:00:00 2001 From: Kenyon Ralph Date: Sun, 20 Dec 2020 00:11:41 -0800 Subject: [PATCH 3/8] add an acceptance test for apt::backports --- spec/acceptance/apt_backports_spec.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 spec/acceptance/apt_backports_spec.rb diff --git a/spec/acceptance/apt_backports_spec.rb b/spec/acceptance/apt_backports_spec.rb new file mode 100644 index 0000000000..5c4dcceb29 --- /dev/null +++ b/spec/acceptance/apt_backports_spec.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +require 'spec_helper_acceptance' + +describe 'apt::backports' do + context 'when using defaults' do + let(:pp) do + <<-MANIFEST + include apt::backports + MANIFEST + end + + it 'applies idempotently' do + idempotent_apply(pp) + end + + it 'provides backports apt sources' do + run_shell('apt policy | grep --quiet backports') + end + end +end From cd983e6048e30045e66e5958278a98d61f9f0959 Mon Sep 17 00:00:00 2001 From: Kenyon Ralph Date: Sat, 19 Dec 2020 22:28:04 -0800 Subject: [PATCH 4/8] spec_helper_acceptance_local.rb: improve comment about lsb-release --- spec/spec_helper_acceptance_local.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/spec_helper_acceptance_local.rb b/spec/spec_helper_acceptance_local.rb index d5339aeb8d..cc3fc3f99c 100644 --- a/spec/spec_helper_acceptance_local.rb +++ b/spec/spec_helper_acceptance_local.rb @@ -5,7 +5,8 @@ RETRY_WAIT = 3 ERROR_MATCHER = %r{(no valid OpenPGP data found|keyserver timed out|keyserver receive failed)}.freeze -# this is needed for puppet facts / apply +# lsb-release is needed for facter 3 (puppet 6) to resolve os.distro facts. Not needed with facter +# 4 (puppet 7). lsb_package = <<-MANIFEST package { 'lsb-release': ensure => installed, From 3b43221bb9efe05baac55ffaf88a67d3ddd12a8b Mon Sep 17 00:00:00 2001 From: Kenyon Ralph Date: Sun, 20 Dec 2020 01:03:15 -0800 Subject: [PATCH 5/8] README: fix link to litmus tutorial --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 19b50adb1c..c3cea66d1c 100644 --- a/README.md +++ b/README.md @@ -320,7 +320,7 @@ Class['apt::update'] -> Package <| provider == 'apt' |> ## Development Acceptance tests for this module leverage [puppet_litmus](https://github.com/puppetlabs/puppet_litmus). -To run the acceptance tests follow the instructions [here](). +To run the acceptance tests follow the instructions [here](https://puppetlabs.github.io/litmus/Running-acceptance-tests.html). You can also find a tutorial and walkthrough of using Litmus and the PDK on [YouTube](https://www.youtube.com/watch?v=FYfR7ZEGHoE). If you run into an issue with this module, or if you would like to request a feature, please [file a ticket](https://tickets.puppetlabs.com/browse/MODULES/). From b9234a1f5aebe85503ca1a931d9a29818978521c Mon Sep 17 00:00:00 2001 From: Kenyon Ralph Date: Sun, 20 Dec 2020 01:18:36 -0800 Subject: [PATCH 6/8] examples/backports.pp: fix class usage It's a class, not a defined type. I missed this in https://github.com/puppetlabs/puppetlabs-apt/pull/962 --- examples/backports.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/backports.pp b/examples/backports.pp index 5f1f1ee18d..66e08e34c2 100644 --- a/examples/backports.pp +++ b/examples/backports.pp @@ -1,6 +1,6 @@ -# Set up a backport for linuxmint qiana +# Set up a backport for Linux Mint qiana class { 'apt': } -apt::backports { 'qiana': +class { 'apt::backports': location => 'http://us.archive.ubuntu.com/ubuntu', release => 'trusty-backports', repos => 'main universe multiverse restricted', From 5403a6eb9197e4da64d0ef7d4d1f91e0e6bf4a3f Mon Sep 17 00:00:00 2001 From: Kenyon Ralph Date: Sun, 20 Dec 2020 01:19:48 -0800 Subject: [PATCH 7/8] spec/classes/apt_backports_spec.rb: fix Mint case Per https://github.com/camptocamp/facterdb/blob/master/facts/3.14/linuxmint-19-x86_64.facts#L324 (assuming LinuxMint 17 used the same capitalization as newer versions). --- spec/classes/apt_backports_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/classes/apt_backports_spec.rb b/spec/classes/apt_backports_spec.rb index 795344001f..2f3865bc32 100644 --- a/spec/classes/apt_backports_spec.rb +++ b/spec/classes/apt_backports_spec.rb @@ -131,14 +131,14 @@ { os: { family: 'Debian', - name: 'Linuxmint', + name: 'LinuxMint', release: { major: '17', full: '17', }, distro: { codename: 'qiana', - id: 'linuxmint', + id: 'LinuxMint', }, }, } From 45341aeddd9548230c084993d6ec491475136cdc Mon Sep 17 00:00:00 2001 From: Kenyon Ralph Date: Sun, 20 Dec 2020 02:50:26 -0800 Subject: [PATCH 8/8] readmes: update note about lsb-release for Puppet 7 --- README.md | 4 +++- readmes/README_ja_JP.md | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c3cea66d1c..c37101f07b 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,9 @@ The apt module lets you use Puppet to manage APT (Advanced Package Tool) sources APT is a package manager available on Debian, Ubuntu, and several other operating systems. The apt module provides a series of classes, defines, types, and facts to help you automate APT package management. -**Note**: For this module to correctly autodetect which version of Debian/Ubuntu (or derivative) you're running, you need to make sure the 'lsb-release' package is installed. We highly recommend you either make this part of your provisioning layer, if you run many Debian or derivative systems, or ensure that you have Facter 2.2.0 or later installed, which will pull this dependency in for you. +**Note**: Prior to Puppet 7, for this module to correctly autodetect which version of +Debian/Ubuntu (or derivative) you're running, you need to make sure the `lsb-release` package is +installed. With Puppet 7 the `lsb-release` package is not needed. diff --git a/readmes/README_ja_JP.md b/readmes/README_ja_JP.md index cf8f6b4157..be8ac75f52 100644 --- a/readmes/README_ja_JP.md +++ b/readmes/README_ja_JP.md @@ -24,7 +24,9 @@ aptモジュールを導入すると、Puppetを使用してAPT (Advanced Packag APTとは、Debian、Ubuntu、およびその他いくつかのオペレーティングシステムで利用可能なパッケージマネージャです。aptモジュールは、APTのパッケージ管理を自動化するのに役立つ一連のクラス、定義型、およびfactsを提供します。 -**注意**: このモジュールが実行中のDebian/Ubuntu (もしくは派生OS)のバージョンを正しく自動検出するためには、'lsb-release'パッケージがインストールされていることを確認する必要があります。これをプロビジョニングレイヤの一部にするか(多くのDebianシステムまたは派生OSシステムを実行する場合はこちらを推奨)、この依存関係を自動的に取得する機能をもつFacter 2.2.0以降をインストールしておくことを強くお勧めします。 +**注**:Puppet 7 より前は、このモジュールがどのバージョンのを正しく自動検出するか +実行している Debian / Ubuntu(または派生物)、 `lsb-release`パッケージが +インストールされています。 Puppet 7 では、 `lsb-release`パッケージは必要ありません。 ## セットアップ