diff --git a/.fixtures.yml b/.fixtures.yml index 2d55ecf..0157d6a 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,11 +1,9 @@ fixtures: repositories: "stdlib": "repo": "https://github.com/puppetlabs/puppetlabs-stdlib.git" - "translate": - "repo": "https://github.com/puppetlabs/puppetlabs-translate" facts: 'https://github.com/puppetlabs/puppetlabs-facts.git' puppet_agent: 'https://github.com/puppetlabs/puppetlabs-puppet_agent.git' provision: 'https://github.com/puppetlabs/provision.git' symlinks: "apt": "#{source_dir}" diff --git a/locales/config.yaml b/locales/config.yaml deleted file mode 100644 index 3f64263..0000000 --- a/locales/config.yaml +++ /dev/null @@ -1,26 +0,0 @@ ---- -# This is the project-specific configuration file for setting up -# fast_gettext for your project. -gettext: - # This is used for the name of the .pot and .po files; they will be - # called .pot? - project_name: puppetlabs-apt - # This is used in comments in the .pot and .po files to indicate what - # project the files belong to and should bea little more desctiptive than - # - package_name: puppetlabs-apt - # The locale that the default messages in the .pot file are in - default_locale: en - # The email used for sending bug reports. - bugs_address: docs@puppet.com - # The holder of the copyright. - copyright_holder: Puppet, Inc. - # This determines which comments in code should be eligible for translation. - # Any comments that start with this string will be externalized. (Leave - # empty to include all.) - comments_tag: TRANSLATOR - # Patterns for +Dir.glob+ used to find all files that might contain - # translatable content, relative to the project root directory - source_files: - - './lib/**/*.rb' - diff --git a/locales/ja/puppetlabs-apt.po b/locales/ja/puppetlabs-apt.po deleted file mode 100644 index 1fe9d1d..0000000 --- a/locales/ja/puppetlabs-apt.po +++ /dev/null @@ -1,155 +0,0 @@ -# #-#-#-#-# puppetlabs-apt.pot (puppetlabs-apt 6.0.0-27-gbb0f842) #-#-#-#-# -# SOME DESCRIPTIVE TITLE. -# 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 "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-09-21T09:17:39+01:00\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: Eriko Kashiwagi , 2018\n" -"Language-Team: Japanese (Japan) (https://www.transifex.com/puppet/teams/41915/ja_JP/)\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Language: ja_JP\n" -"Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Translate Toolkit 2.0.0\n" - -#. ./manifests/backports.pp:69 -msgid "" -"If not on Debian or Ubuntu, you must explicitly pass location, release, " -"repos, and key" -msgstr "DebianまたはUbuntu以外の場合、場所、リリース、リポジトリ、およびキーを明示的に渡す必要があります。" - -#. ./manifests/backports.pp:95 -msgid "pin must be either a string, number or hash" -msgstr "pinは、文字列、数値またはハッシュのいずれかである必要があります。" - -#. ./manifests/conf.pp:25 -msgid "Need to pass in content parameter" -msgstr "contentパラメータを渡す必要があります。" - -#. ./manifests/init.pp:143 ./manifests/params.pp:8 -msgid "This module only works on Debian or derivatives like Ubuntu" -msgstr "本モジュールは、DebianまたはUbuntuなどの派生OSでのみ動作します。" - -#. ./manifests/key.pp:47 -msgid "key with id %{_id} already ensured as absent" -msgstr "id %{_id}のキーは、存在しないことが既に確認されています。" - -#. ./manifests/key.pp:81 -msgid "key with id %{_id} already ensured as present" -msgstr "id %{_id}のキーは、存在することが既に確認されています。" - -#. ./manifests/key.pp:97 -msgid "Invalid 'ensure' value '%{_ensure}' for apt::key" -msgstr "apt::keyの'%{_ensure}'の'ensure'の値が無効です。" - -#. ./manifests/params.pp:100 -msgid "Unable to determine value for fact os[\"name\"]" -msgstr "fact os[\"name\"]の値を特定できません。" - -#. ./manifests/pin.pp:84 -msgid "parameters release, origin, and version are mutually exclusive" -msgstr "パラメータrelease、origin、versionは相互に排他的です。" - -#. ./manifests/pin.pp:88 -msgid "parameter version cannot be used in general form" -msgstr "パラメータのバージョンは、一般的な形式では使用できません" - -#. ./manifests/pin.pp:91 -msgid "parameters release and origin are mutually exclusive" -msgstr "パラメータreleaseとoriginは相互に排他的です。" - -#. ./manifests/ppa.pp:30 ./manifests/source.pp:79 -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." -msgstr "apt::ppaは、現在Debianではサポートされていません。" - -#. ./manifests/setting.pp:31 -msgid "apt::setting cannot have both content and source" -msgstr "apt::settingがcontentとsourceの両方を持つことはできません。" - -#. ./manifests/setting.pp:35 -msgid "apt::setting needs either of content or source" -msgstr "apt::settingには、contentまたはsourceのいずれかが必要です。" - -#. ./manifests/setting.pp:43 -msgid "" -"apt::setting resource name/title must start with either 'conf-', 'pref-' or " -"'list-'" -msgstr "apt::settingのリソース名/タイトルの先頭は、'conf-'、'pref-'、'list-'にする必要があります。" - -#. ./manifests/setting.pp:49 -msgid "apt::setting priority must be an integer or a zero-padded integer" -msgstr "apt::settingのpriorityは、整数またはゼロパディングされた整数にする必要があります。" - -#. ./manifests/source.pp:87 -msgid "cannot create a source entry without specifying a location" -msgstr "場所を指定せずにソースエントリを作成することはできません。" - -#. ./manifests/source.pp:101 -msgid "key hash must contain at least an id entry" -msgstr "キーハッシュには、少なくともidエントリを含める必要があります。" - -#. ./manifests/source.pp:140 -msgid "Received invalid value for pin parameter" -msgstr "pinパラメータに無効な値を受信しました。" - -#: ../lib/puppet/provider/apt_key/apt_key.rb:124 -msgid "The file %{_value} does not exist" -msgstr "ファイル%{_value}が存在しません。" - -#: ../lib/puppet/provider/apt_key/apt_key.rb:144 -msgid "%{_e} for %{_resource}" -msgstr "%{_resource}の%{_e}" - -#: ../lib/puppet/provider/apt_key/apt_key.rb:146 -msgid "could not resolve %{_resource}" -msgstr "%{_resource}を解決できませんでした。" - -#: ../lib/puppet/provider/apt_key/apt_key.rb:173 -msgid "" -"The id in your manifest %{_resource} and the fingerprint from content/source" -" don't match. Check for an error in the id and content/source is legitimate." -msgstr "" -"マニフェスト%{_resource}に含まれるidと、content/sourceのフィンガープリントが一致しません。idに間違いがないか、content/sourceが正当であるかを確認してください。" - -#: ../lib/puppet/provider/apt_key/apt_key.rb:191 -#: ../lib/puppet/provider/apt_key/apt_key.rb:227 -msgid "" -"an unexpected condition occurred while trying to add the key: %{_resource}" -msgstr "キー%{_resource}の追加中に、予期しない状況が発生しました。" - -#: ../lib/puppet/provider/apt_key/apt_key.rb:243 -msgid "This is a read-only property." -msgstr "これは、読み込み専用のプロパティです。" - -#: ../lib/puppet/type/apt_key.rb:27 -msgid "ensure => absent and refresh => true are mutually exclusive" -msgstr "ensure => absentとrefresh => trueは相互に排他的です。" - -#: ../lib/puppet/type/apt_key.rb:30 -msgid "The properties content and source are mutually exclusive." -msgstr "プロパティcontentとsourceは相互に排他的です。 are mutually exclusive." - -#: ../lib/puppet/type/apt_key.rb:33 -msgid "The id should be a full fingerprint (40 characters), see README." -msgstr "idは完全なフィンガープリント(40文字)である必要があります。READMEを参照してください。" - -#. metadata.json -#: .summary -msgid "" -"Provides an interface for managing Apt source, key, and definitions with " -"Puppet" -msgstr "Aptソース、キー、および定義をPuppetで管理するためのインターフェースを提供します。" diff --git a/locales/puppetlabs-apt.pot b/locales/puppetlabs-apt.pot deleted file mode 100644 index 5fa70e2..0000000 --- a/locales/puppetlabs-apt.pot +++ /dev/null @@ -1,177 +0,0 @@ -# #-#-#-#-# puppetlabs-apt.pot (puppetlabs-apt 6.0.0-27-gbb0f842) #-#-#-#-# -# SOME DESCRIPTIVE TITLE. -# 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 "" -"#-#-#-#-# puppet.pot (PACKAGE VERSION) #-#-#-#-#\n" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-09-21 09:17:33 +0100\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Translate Toolkit 2.0.0\n" -"#-#-#-#-# puppetlabs-apt.pot (puppetlabs-apt 6.0.0-27-gbb0f842) #-#-#-#-#\n" -"Project-Id-Version: puppetlabs-apt 6.0.0-27-gbb0f842\n" -"\n" -"Report-Msgid-Bugs-To: docs@puppet.com\n" -"POT-Creation-Date: 2018-09-21 09:27+0100\n" -"PO-Revision-Date: 2018-09-21 09:27+0100\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" -"#-#-#-#-# puppetlabs-apt_metadata.pot (PACKAGE VERSION) #-#-#-#-#\n" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To:\n" -"POT-Creation-Date: 2018-09-21T09:17:39+01:00\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Translate Toolkit 2.0.0\n" - -#. ./manifests/backports.pp:69 -msgid "" -"If not on Debian or Ubuntu, you must explicitly pass location, release, " -"repos, and key" -msgstr "" - -#. ./manifests/backports.pp:95 -msgid "pin must be either a string, number or hash" -msgstr "" - -#. ./manifests/conf.pp:25 -msgid "Need to pass in content parameter" -msgstr "" - -#. ./manifests/init.pp:143 ./manifests/params.pp:8 -msgid "This module only works on Debian or derivatives like Ubuntu" -msgstr "" - -#. ./manifests/key.pp:47 -msgid "key with id %{_id} already ensured as absent" -msgstr "" - -#. ./manifests/key.pp:81 -msgid "key with id %{_id} already ensured as present" -msgstr "" - -#. ./manifests/key.pp:97 -msgid "Invalid 'ensure' value '%{_ensure}' for apt::key" -msgstr "" - -#. ./manifests/params.pp:100 -msgid "Unable to determine value for fact os[\"name\"]" -msgstr "" - -#. ./manifests/pin.pp:84 -msgid "parameters release, origin, and version are mutually exclusive" -msgstr "" - -#. ./manifests/pin.pp:88 -msgid "parameter version cannot be used in general form" -msgstr "" - -#. ./manifests/pin.pp:91 -msgid "parameters release and origin are mutually exclusive" -msgstr "" - -#. ./manifests/ppa.pp:30 ./manifests/source.pp:79 -msgid "os.distro.codename fact not available: release parameter required" -msgstr "" - -#. ./manifests/ppa.pp:34 -msgid "apt::ppa is not currently supported on Debian." -msgstr "" - -#. ./manifests/setting.pp:31 -msgid "apt::setting cannot have both content and source" -msgstr "" - -#. ./manifests/setting.pp:35 -msgid "apt::setting needs either of content or source" -msgstr "" - -#. ./manifests/setting.pp:43 -msgid "" -"apt::setting resource name/title must start with either 'conf-', 'pref-' or " -"'list-'" -msgstr "" - -#. ./manifests/setting.pp:49 -msgid "apt::setting priority must be an integer or a zero-padded integer" -msgstr "" - -#. ./manifests/source.pp:87 -msgid "cannot create a source entry without specifying a location" -msgstr "" - -#. ./manifests/source.pp:101 -msgid "key hash must contain at least an id entry" -msgstr "" - -#. ./manifests/source.pp:140 -msgid "Received invalid value for pin parameter" -msgstr "" - -#: ../lib/puppet/provider/apt_key/apt_key.rb:124 -msgid "The file %{_value} does not exist" -msgstr "" - -#: ../lib/puppet/provider/apt_key/apt_key.rb:144 -msgid "%{_e} for %{_resource}" -msgstr "" - -#: ../lib/puppet/provider/apt_key/apt_key.rb:146 -msgid "could not resolve %{_resource}" -msgstr "" - -#: ../lib/puppet/provider/apt_key/apt_key.rb:173 -msgid "" -"The id in your manifest %{_resource} and the fingerprint from content/source " -"don't match. Check for an error in the id and content/source is legitimate." -msgstr "" - -#: ../lib/puppet/provider/apt_key/apt_key.rb:191 -#: ../lib/puppet/provider/apt_key/apt_key.rb:227 -msgid "" -"an unexpected condition occurred while trying to add the key: %{_resource}" -msgstr "" - -#: ../lib/puppet/provider/apt_key/apt_key.rb:243 -msgid "This is a read-only property." -msgstr "" - -#: ../lib/puppet/type/apt_key.rb:27 -msgid "ensure => absent and refresh => true are mutually exclusive" -msgstr "" - -#: ../lib/puppet/type/apt_key.rb:30 -msgid "The properties content and source are mutually exclusive." -msgstr "" - -#: ../lib/puppet/type/apt_key.rb:33 -msgid "The id should be a full fingerprint (40 characters), see README." -msgstr "" - -#. metadata.json -#: .summary -msgid "" -"Provides an interface for managing Apt source, key, and definitions with " -"Puppet" -msgstr "" diff --git a/manifests/backports.pp b/manifests/backports.pp index 5949905..39e6f6c 100644 --- a/manifests/backports.pp +++ b/manifests/backports.pp @@ -1,112 +1,112 @@ # @summary Manages backports. # # @example Set up a backport source for Linux Mint qiana # class { 'apt::backports': # location => 'http://us.archive.ubuntu.com/ubuntu', # release => 'trusty-backports', # repos => 'main universe multiverse restricted', # key => { # id => '630239CC130E1A7FD81A27B140976EAF437D05B5', # server => 'hkps.pool.sks-keyservers.net', # }, # } # # @param location # 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' # # - 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, `${facts['os']['distro']['codename']}-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. # 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 # 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: # # - Debian: 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553' # # - 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 # type, or a hash of `parameter => value` pairs to be passed to `apt::pin`'s corresponding parameters. # # @param include # Specifies whether to include 'deb' or 'src', or both. # class apt::backports ( Optional[String] $location = undef, Optional[String] $release = undef, Optional[String] $repos = undef, Optional[Variant[String, Hash]] $key = undef, Optional[Variant[Integer, String, Hash]] $pin = 200, Optional[Variant[Hash]] $include = {}, ) { include apt if $location { $_location = $location } if $release { $_release = $release } if $repos { $_repos = $repos } if $key { $_key = $key } 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')) + fail('If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key') } } unless $location { $_location = $::apt::backports['location'] } unless $release { $_release = "${facts['os']['distro']['codename']}-backports" } unless $repos { $_repos = $::apt::backports['repos'] } unless $key { $_key = $::apt::backports['key'] } if $pin =~ Hash { $_pin = $pin } elsif $pin =~ Numeric or $pin =~ String { # apt::source defaults to pinning to origin, but we should pin to release # for backports $_pin = { 'priority' => $pin, 'release' => $_release, } } else { - fail(translate('pin must be either a string, number or hash')) + fail('pin must be either a string, number or hash') } apt::source { 'backports': location => $_location, release => $_release, repos => $_repos, include => $include, key => $_key, pin => $_pin, } } diff --git a/manifests/conf.pp b/manifests/conf.pp index 9c1a59e..c27f0c1 100644 --- a/manifests/conf.pp +++ b/manifests/conf.pp @@ -1,36 +1,36 @@ # @summary Specifies a custom Apt configuration file. # # @param content # Required unless `ensure` is set to 'absent'. Directly supplies content for the configuration file. # # @param ensure # Specifies whether the configuration file should exist. Valid options: 'present' and 'absent'. # # @param priority # Determines the order in which Apt processes the configuration file. Files with lower priority numbers are loaded first. # Valid options: a string containing an integer or an integer. # # @param notify_update # Specifies whether to trigger an `apt-get update` run. # define apt::conf ( Optional[String] $content = undef, Enum['present', 'absent'] $ensure = present, Variant[String, Integer] $priority = 50, Optional[Boolean] $notify_update = undef, ) { unless $ensure == 'absent' { unless $content { - fail(translate('Need to pass in content parameter')) + fail('Need to pass in content parameter') } } $confheadertmp = epp('apt/_conf_header.epp') apt::setting { "conf-${name}": ensure => $ensure, priority => $priority, content => "${confheadertmp}${content}", notify_update => $notify_update, } } diff --git a/manifests/init.pp b/manifests/init.pp index a20748f..3c96de8 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,344 +1,344 @@ # @summary Main class, includes all other classes. # # @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://). # # @param key_options # Specifies the default options for apt::key resources. # # @param ppa_options # Supplies options to be passed to the `add-apt-repository` command. # # @param ppa_package # Names the package that provides the `apt-add-repository` command. # # @param backports # Specifies some of the default parameters used by apt::backports. Valid options: a hash made up from the following keys: # # @option backports [String] :location # See apt::backports for documentation. # # @option backports [String] :repos # See apt::backports for documentation. # # @option backports [String] :key # 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. # # @param update # Configures various update settings. Valid options: a hash made up from the following keys: # # @option update [String] :frequency # Specifies how often to run `apt-get update`. If the exec resource `apt_update` is notified, `apt-get update` runs regardless of this value. # Valid options: 'always' (at every Puppet run); 'daily' (if the value of `apt_update_last_success` is less than current epoch time minus 86400); # 'weekly' (if the value of `apt_update_last_success` is less than current epoch time minus 604800); and 'reluctantly' (only if the exec resource # `apt_update` is notified). Default: 'reluctantly'. # # @option update [Integer] :loglevel # Specifies the log level of logs outputted to the console. Default: undef. # # @option update [Integer] :timeout # Specifies how long to wait for the update to complete before canceling it. Valid options: an integer, in seconds. Default: undef. # # @option update [Integer] :tries # Specifies how many times to retry the update after receiving a DNS or HTTP error. Default: undef. # # @param purge # Specifies whether to purge any existing settings that aren't managed by Puppet. Valid options: a hash made up from the following keys: # # @option purge [Boolean] :sources.list # Specifies whether to purge any unmanaged entries from sources.list. Default false. # # @option purge [Boolean] :sources.list.d # Specifies whether to purge any unmanaged entries from sources.list.d. Default false. # # @option purge [Boolean] :preferences # Specifies whether to purge any unmanaged entries from preferences. Default false. # # @option purge [Boolean] :preferences.d. # Specifies whether to purge any unmanaged entries from preferences.d. Default false. # # @param proxy # Configures Apt to connect to a proxy server. Valid options: a hash matching the locally defined type apt::proxy. # # @param sources # Creates new `apt::source` resources. Valid options: a hash to be passed to the create_resources function linked above. # # @param keys # Creates new `apt::key` resources. Valid options: a hash to be passed to the create_resources function linked above. # # @param ppas # Creates new `apt::ppa` resources. Valid options: a hash to be passed to the create_resources function linked above. # # @param pins # Creates new `apt::pin` resources. Valid options: a hash to be passed to the create_resources function linked above. # # @param settings # Creates new `apt::setting` resources. Valid options: a hash to be passed to the create_resources function linked above. # # @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 # the auth_conf_entries parameter. When false, the file will be ignored (note that this does not set the file to absent. # # @param auth_conf_entries # An optional array of login configuration settings (hashes) that are recorded in the file /etc/apt/auth.conf. This file has a netrc-like # format (similar to what curl uses) and contains the login configuration for APT sources and proxies that require authentication. See # https://manpages.debian.org/testing/apt/apt_auth.conf.5.en.html for details. If specified each hash must contain the keys machine, login and # 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. # # @param root # Specifies root directory of Apt executable. # # @param sources_list # Specifies the path of the sources_list file to use. # # @param sources_list_d # Specifies the path of the sources_list.d file to use. # # @param conf_d # Specifies the path of the conf.d file to use. # # @param preferences # Specifies the path of the preferences file to use. # # @param preferences_d # Specifies the path of the preferences.d file to use. # # @param config_files # 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. # 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[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 $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, Hash $source_key_defaults = $apt::params::source_key_defaults, Boolean $sources_list_force = $apt::params::sources_list_force, ) inherits apt::params { if $facts['os']['family'] != 'Debian' { - fail(translate('This module only works on Debian or derivatives like Ubuntu')) + fail('This module only works on Debian or derivatives like Ubuntu') } if $update['frequency'] { assert_type( Enum['always','daily','weekly','reluctantly'], $update['frequency'], ) } if $update['timeout'] { assert_type(Integer, $update['timeout']) } if $update['tries'] { assert_type(Integer, $update['tries']) } $_update = merge($::apt::update_defaults, $update) include ::apt::update if $purge['sources.list'] { assert_type(Boolean, $purge['sources.list']) } if $purge['sources.list.d'] { assert_type(Boolean, $purge['sources.list.d']) } if $purge['preferences'] { assert_type(Boolean, $purge['preferences']) } if $purge['preferences.d'] { assert_type(Boolean, $purge['preferences.d']) } if $sources_list_force { assert_type(Boolean, $sources_list_force) } if $purge['apt.conf.d'] { assert_type(Boolean, $purge['apt.conf.d']) } $_purge = merge($::apt::purge_defaults, $purge) $_proxy = merge($apt::proxy_defaults, $proxy) $confheadertmp = epp('apt/_conf_header.epp') $proxytmp = epp('apt/proxy.epp', {'proxies' => $_proxy}) $updatestamptmp = epp('apt/15update-stamp.epp') if $_proxy['ensure'] == 'absent' or $_proxy['host'] { apt::setting { 'conf-proxy': ensure => $_proxy['ensure'], priority => '01', content => "${confheadertmp}${proxytmp}", } } if $sources_list_force { $sources_list_ensure = $_purge['sources.list'] ? { true => absent, default => file, } $sources_list_content = $_purge['sources.list'] ? { true => nil, default => undef, } } else { $sources_list_ensure = $_purge['sources.list'] ? { true => file, default => file, } $sources_list_content = $_purge['sources.list'] ? { true => "# Repos managed by puppet.\n", default => undef, } } $preferences_ensure = $_purge['preferences'] ? { true => absent, default => file, } if $_update['frequency'] == 'always' { Exec <| title=='apt_update' |> { refreshonly => false, } } apt::setting { 'conf-update-stamp': priority => 15, content => "${confheadertmp}${updatestamptmp}", } file { 'sources.list': ensure => $sources_list_ensure, path => $::apt::sources_list, owner => root, group => root, content => $sources_list_content, notify => Class['apt::update'], } file { 'sources.list.d': ensure => directory, path => $::apt::sources_list_d, owner => root, group => root, purge => $_purge['sources.list.d'], recurse => $_purge['sources.list.d'], notify => Class['apt::update'], } file { 'preferences': ensure => $preferences_ensure, path => $::apt::preferences, owner => root, group => root, notify => Class['apt::update'], } file { 'preferences.d': ensure => directory, path => $::apt::preferences_d, owner => root, group => root, purge => $_purge['preferences.d'], recurse => $_purge['preferences.d'], notify => Class['apt::update'], } file { 'apt.conf.d': ensure => directory, path => $::apt::apt_conf_d, owner => root, group => root, purge => $_purge['apt.conf.d'], recurse => $_purge['apt.conf.d'], notify => Class['apt::update'], } if $confs { create_resources('apt::conf', $confs) } # manage sources if present if $sources { create_resources('apt::source', $sources) } # manage keys if present if $keys { create_resources('apt::key', $keys) } # manage ppas if present if $ppas { create_resources('apt::ppa', $ppas) } # manage settings if present if $settings { create_resources('apt::setting', $settings) } if $manage_auth_conf { $auth_conf_ensure = $auth_conf_entries ? { [] => 'absent', default => 'present', } $auth_conf_tmp = epp('apt/auth_conf.epp') file { '/etc/apt/auth.conf': ensure => $auth_conf_ensure, owner => $auth_conf_owner, group => 'root', mode => '0600', content => Sensitive("${confheadertmp}${auth_conf_tmp}"), notify => Class['apt::update'], } } # manage pins if present if $pins { create_resources('apt::pin', $pins) } # required for adding GPG keys on Debian 9 (and derivatives) ensure_packages(['gnupg']) } diff --git a/manifests/key.pp b/manifests/key.pp index 87fe4e3..77e6095 100644 --- a/manifests/key.pp +++ b/manifests/key.pp @@ -1,106 +1,106 @@ # @summary Manages the GPG keys that Apt uses to authenticate packages. # # @note # The apt::key defined type makes use of the apt_key type, but includes extra functionality to help prevent duplicate keys. # # @example Declare Apt key for apt.puppetlabs.com source # apt::key { 'puppetlabs': # id => '6F6B15509CF8E59E6E469F327F438280EF8D349F', # server => 'hkps.pool.sks-keyservers.net', # options => 'http-proxy="http://proxyuser:proxypass@example.org:3128"', # } # # @param id # Specifies a GPG key to authenticate Apt package signatures. Valid options: a string containing a key ID (8 or 16 hexadecimal # characters, optionally prefixed with "0x") or a full key fingerprint (40 hexadecimal characters). # # @param ensure # Specifies whether the key should exist. Valid options: 'present', 'absent' or 'refreshed'. Using 'refreshed' will make keys auto # update when they have expired (assuming a new key exists on the key server). # # @param content # Supplies the entire GPG key. Useful in case the key can't be fetched from a remote location and using a file resource is inconvenient. # # @param source # Specifies the location of an existing GPG key file to copy. Valid options: a string containing a URL (ftp://, http://, or https://) or # an absolute path. # # @param server # Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://, # hkp:// or hkps://). The hkps:// protocol is currently only supported on Ubuntu 18.04. # # @param weak_ssl # Specifies whether strict SSL verification on a https URL should be disabled. Valid options: true or false. # # @param options # Passes additional options to `apt-key adv --keyserver-options`. # define apt::key ( Pattern[/\A(0x)?[0-9a-fA-F]{8}\Z/, /\A(0x)?[0-9a-fA-F]{16}\Z/, /\A(0x)?[0-9a-fA-F]{40}\Z/] $id = $title, Enum['present', 'absent', 'refreshed'] $ensure = present, Optional[String] $content = undef, Optional[Pattern[/\Ahttps?:\/\//, /\Aftp:\/\//, /\A\/\w+/]] $source = undef, Pattern[/\A((hkp|hkps|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?(\/[a-zA-Z\d\-_.]+)*\/?$/] $server = $::apt::keyserver, Boolean $weak_ssl = false, Optional[String] $options = $::apt::key_options, ) { case $ensure { /^(refreshed|present)$/: { if defined(Anchor["apt_key ${id} absent"]){ - fail(translate('key with id %{_id} already ensured as absent'), {'_id' => id}) + fail("key with id ${id} already ensured as absent") } if !defined(Anchor["apt_key ${id} present"]) { apt_key { $title: ensure => present, refresh => $ensure == 'refreshed', id => $id, source => $source, content => $content, server => $server, weak_ssl => $weak_ssl, options => $options, } -> anchor { "apt_key ${id} present": } case $facts['os']['name'] { 'Debian': { if versioncmp($facts['os']['release']['major'], '9') >= 0 { ensure_packages(['gnupg']) Apt::Key<| title == $title |> } } 'Ubuntu': { if versioncmp($facts['os']['release']['full'], '17.04') >= 0 { ensure_packages(['gnupg']) Apt::Key<| title == $title |> } } default: { } } } } absent: { if defined(Anchor["apt_key ${id} present"]){ - fail(translate('key with id %{_id} already ensured as present', {'_id' => id})) + fail("key with id ${id} already ensured as present") } if !defined(Anchor["apt_key ${id} absent"]){ apt_key { $title: ensure => $ensure, id => $id, source => $source, content => $content, server => $server, weak_ssl => $weak_ssl, options => $options, } -> anchor { "apt_key ${id} absent": } } } default: { - fail translate('Invalid \'ensure\' value \'%{_ensure}\' for apt::key', {'_ensure' => ensure}) + fail("Invalid \'ensure\' value \'${ensure}\' for apt::key") } } } diff --git a/manifests/params.pp b/manifests/params.pp index 9a92577..6167ea5 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,124 +1,124 @@ # @summary Provides defaults for the Apt module parameters. # # @api private # class apt::params { if $facts['os']['family'] != 'Debian' { - fail(translate('This module only works on Debian or derivatives like Ubuntu')) + 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, } $source_key_defaults = { 'server' => $keyserver, 'options' => undef, 'content' => undef, 'source' => undef, } $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 if versioncmp($facts['os']['release']['major'], '9') >= 0 { $auth_conf_owner = '_apt' } else { $auth_conf_owner = 'root' } } 'Ubuntu': { $backports = { 'location' => 'http://archive.ubuntu.com/ubuntu', 'key' => '630239CC130E1A7FD81A27B140976EAF437D05B5', 'repos' => 'main universe multiverse restricted', } $ppa_options = '-y' $ppa_package = 'software-properties-common' if versioncmp($facts['os']['release']['full'], '16.04') >= 0 { $auth_conf_owner = '_apt' } else { $auth_conf_owner = 'root' } } undef: { - fail(translate('Unable to determine value for fact os[\"name\"]')) + 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/pin.pp b/manifests/pin.pp index 8145b7d..9310653 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -1,128 +1,128 @@ # @summary Manages Apt pins. Does not trigger an apt-get update run. # # @see http://linux.die.net/man/5/apt_preferences for context on these parameters # # @param ensure # Specifies whether the pin should exist. Valid options: 'file', 'present', and 'absent'. # # @param explanation # Supplies a comment to explain the pin. Default: "${caller_module_name}: ${name}". # # @param order # Determines the order in which Apt processes the pin file. Files with lower order numbers are loaded first. # # @param packages # Specifies which package(s) to pin. # # @param priority # Sets the priority of the package. If multiple versions of a given package are available, `apt-get` installs the one with the highest # priority number (subject to dependency constraints). Valid options: an integer. # # @param release # Tells APT to prefer packages that support the specified release. Typical values include 'stable', 'testing', and 'unstable'. # # @param release_version # Tells APT to prefer packages that support the specified operating system release version (such as Debian release version 7). # # @param component # Names the licensing component associated with the packages in the directory tree of the Release file. # # @param originator # Names the originator of the packages in the directory tree of the Release file. # # @param label # Names the label of the packages in the directory tree of the Release file. # define apt::pin( Optional[Enum['file', 'present', 'absent']] $ensure = present, Optional[String] $explanation = undef, Variant[Integer] $order = 50, Variant[String, Array] $packages = '*', Variant[Numeric, String] $priority = 0, Optional[String] $release = '', # a= Optional[String] $origin = '', Optional[String] $version = '', Optional[String] $codename = '', # n= Optional[String] $release_version = '', # v= Optional[String] $component = '', # c= Optional[String] $originator = '', # o= Optional[String] $label = '', # l= ) { if $explanation { $_explanation = $explanation } else { if defined('$caller_module_name') { # strict vars check $_explanation = "${caller_module_name}: ${name}" } else { $_explanation = ": ${name}" } } $pin_release_array = [ $release, $codename, $release_version, $component, $originator, $label, ] $pin_release = join($pin_release_array, '') # Read the manpage 'apt_preferences(5)', especially the chapter # 'The Effect of APT Preferences' to understand the following logic # and the difference between specific and general form if $packages =~ Array { $packages_string = join($packages, ' ') } else { $packages_string = $packages } if $packages_string != '*' { # specific form if ( $pin_release != '' and ( $origin != '' or $version != '' )) or ( $version != '' and ( $pin_release != '' or $origin != '' )) { - fail(translate('parameters release, origin, and version are mutually exclusive')) + fail('parameters release, origin, and version are mutually exclusive') } } else { # general form if $version != '' { - fail(translate('parameter version cannot be used in general form')) + fail('parameter version cannot be used in general form') } if ( $pin_release != '' and $origin != '' ) { - fail(translate('parameters release and origin are mutually exclusive')) + fail('parameters release and origin are mutually exclusive') } } # According to man 5 apt_preferences: # The files have either no or "pref" as filename extension # and only contain alphanumeric, hyphen (-), underscore (_) and period # (.) characters. Otherwise APT will print a notice that it has ignored a # file, unless that file matches a pattern in the # Dir::Ignore-Files-Silently configuration list - in which case it will # be silently ignored. $file_name = regsubst($title, '[^0-9a-z\-_\.]', '_', 'IG') $headertmp = epp('apt/_header.epp') $pinpreftmp = epp('apt/pin.pref.epp', { 'name' => $name, 'pin_release' => $pin_release, 'release' => $release, 'codename' => $codename, 'release_version' => $release_version, 'component' => $component, 'originator' => $originator, 'label' => $label, 'version' => $version, 'origin' => $origin, 'explanation' => $_explanation, 'packages_string' => $packages_string, 'priority' => $priority, }) apt::setting { "pref-${file_name}": ensure => $ensure, priority => $order, content => "${headertmp}${pinpreftmp}", notify_update => false, } } diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 6a874ce..311f81d 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -1,104 +1,104 @@ # @summary Manages PPA repositories using `add-apt-repository`. Not supported on Debian. # # @example Example declaration of an Apt PPA # apt::ppa{ 'ppa:openstack-ppa/bleeding-edge': } # # @param ensure # 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 # 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 # 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'. # # @param package_manage # Specifies whether Puppet should manage the package that provides `apt-add-repository`. # define apt::ppa( String $ensure = 'present', Optional[String] $options = $::apt::ppa_options, 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('os.distro.codename fact not available: release parameter required')) + fail('os.distro.codename fact not available: release parameter required') } if $dist == 'Debian' { - fail(translate('apt::ppa is not currently supported on Debian.')) + fail('apt::ppa is not currently supported on Debian.') } 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") } else { $dash_filename = regsubst($name, '^ppa:([^/]+)/(.+)$', "\\1-\\2") $underscore_filename = regsubst($name, '^ppa:([^/]+)/(.+)$', "\\1_\\2") } $dash_filename_no_slashes = regsubst($dash_filename, '/', '-', 'G') $dash_filename_no_specialchars = regsubst($dash_filename_no_slashes, '[\.\+]', '_', 'G') $underscore_filename_no_slashes = regsubst($underscore_filename, '/', '-', 'G') $underscore_filename_no_specialchars = regsubst($underscore_filename_no_slashes, '[\.\+]', '_', 'G') $sources_list_d_filename = "${dash_filename_no_specialchars}-${release}.list" 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" } if $ensure == 'present' { if $package_manage { ensure_packages($package_name) $_require = [File['sources.list.d'], Package[$package_name]] } else { $_require = File['sources.list.d'] } $_proxy = $::apt::_proxy if $_proxy['host'] { if $_proxy['https'] { $_proxy_env = ["http_proxy=http://${$_proxy['host']}:${$_proxy['port']}", "https_proxy=https://${$_proxy['host']}:${$_proxy['port']}"] } else { $_proxy_env = ["http_proxy=http://${$_proxy['host']}:${$_proxy['port']}"] } } else { $_proxy_env = [] } exec { "add-apt-repository-${name}": environment => $_proxy_env, command => "/usr/bin/add-apt-repository ${options} ${name} || (rm ${::apt::sources_list_d}/${sources_list_d_filename} && false)", unless => "/usr/bin/test -f ${::apt::sources_list_d}/${sources_list_d_filename} && /usr/bin/test -f ${::apt::trusted_gpg_d}/${trusted_gpg_d_filename}", user => 'root', logoutput => 'on_failure', notify => Class['apt::update'], require => $_require, } file { "${::apt::sources_list_d}/${sources_list_d_filename}": ensure => file, require => Exec["add-apt-repository-${name}"], } } else { file { "${::apt::sources_list_d}/${sources_list_d_filename}": ensure => 'absent', notify => Class['apt::update'], } } } diff --git a/manifests/setting.pp b/manifests/setting.pp index 16124c3..6757f61 100644 --- a/manifests/setting.pp +++ b/manifests/setting.pp @@ -1,76 +1,76 @@ # @summary Manages Apt configuration files. # # @see https://docs.puppetlabs.com/references/latest/type.html#file-attributes for more information on source and content parameters # # @param priority # Determines the order in which Apt processes the configuration file. Files with higher priority numbers are loaded first. # # @param ensure # Specifies whether the file should exist. Valid options: 'present', 'absent', and 'file'. # # @param source # Required, unless `content` is set. Specifies a source file to supply the content of the configuration file. Cannot be used in combination # with `content`. Valid options: see link above for Puppet's native file type source attribute. # # @param content # Required, unless `source` is set. Directly supplies content for the configuration file. Cannot be used in combination with `source`. Valid # options: see link above for Puppet's native file type content attribute. # # @param notify_update # Specifies whether to trigger an `apt-get update` run. # define apt::setting ( Variant[String, Integer, Array] $priority = 50, Optional[Enum['file', 'present', 'absent']] $ensure = file, Optional[String] $source = undef, Optional[String] $content = undef, Boolean $notify_update = true, ) { if $content and $source { - fail(translate('apt::setting cannot have both content and source')) + fail('apt::setting cannot have both content and source') } if !$content and !$source { - fail(translate('apt::setting needs either of content or source')) + fail('apt::setting needs either of content or source') } $title_array = split($title, '-') $setting_type = $title_array[0] $base_name = join(delete_at($title_array, 0), '-') assert_type(Pattern[/\Aconf\z/, /\Apref\z/, /\Alist\z/], $setting_type) |$a, $b| { - fail(translate("apt::setting resource name/title must start with either 'conf-', 'pref-' or 'list-'")) + fail("apt::setting resource name/title must start with either 'conf-', 'pref-' or 'list-'") } if $priority !~ Integer { # need this to allow zero-padded priority. assert_type(Pattern[/^\d+$/], $priority) |$a, $b| { - fail(translate('apt::setting priority must be an integer or a zero-padded integer')) + fail('apt::setting priority must be an integer or a zero-padded integer') } } if ($setting_type == 'list') or ($setting_type == 'pref') { $_priority = '' } else { $_priority = $priority } $_path = $::apt::config_files[$setting_type]['path'] $_ext = $::apt::config_files[$setting_type]['ext'] if $notify_update { $_notify = Class['apt::update'] } else { $_notify = undef } file { "${_path}/${_priority}${base_name}${_ext}": ensure => $ensure, owner => 'root', group => 'root', content => $content, source => $source, notify => $_notify, } } diff --git a/manifests/source.pp b/manifests/source.pp index 2c3d4b8..bc4675b 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -1,173 +1,173 @@ # @summary Manages the Apt sources in /etc/apt/sources.list.d/. # # @example Install the puppetlabs apt source # apt::source { 'puppetlabs': # location => 'http://apt.puppetlabs.com', # repos => 'main', # key => { # id => '6F6B15509CF8E59E6E469F327F438280EF8D349F', # server => 'hkps.pool.sks-keyservers.net', # }, # } # # @param location # Required, unless ensure is set to 'absent'. Specifies an Apt repository. Valid options: a string containing a repository URL. # # @param comment # 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'. # # @param release # Specifies a distribution of the Apt repository. # # @param repos # Specifies a component of the Apt repository. # # @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. # # @option include [Boolean] :src # 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 # `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 # `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 # defined in the Apt::Architectures option). # # @param allow_unsigned # Specifies whether to authenticate packages from this release, even if the Release file is not signed or the signature can't be checked. # # @param notify_update # Specifies whether to trigger an `apt-get update` run. # define apt::source( Optional[String] $location = undef, String $comment = $name, String $ensure = present, Optional[String] $release = undef, String $repos = 'main', Optional[Variant[Hash]] $include = {}, Optional[Variant[String, Hash]] $key = undef, Optional[Variant[Hash, Numeric, String]] $pin = undef, Optional[String] $architecture = undef, Boolean $allow_unsigned = false, Boolean $notify_update = true, ) { include ::apt $_before = Apt::Setting["list-${title}"] if !$release { if $facts['os']['distro']['codename'] { $_release = $facts['os']['distro']['codename'] } else { - fail(translate('os.distro.codename fact not available: release parameter required')) + fail('os.distro.codename fact not available: release parameter required') } } else { $_release = $release } if $ensure == 'present' { if ! $location { - fail(translate('cannot create a source entry without specifying a location')) + fail('cannot create a source entry without specifying a location') } elsif ($::apt::proxy['https_acng']) and ($location =~ /(?i:^https:\/\/)/) { $_location = regsubst($location, 'https://','http://HTTPS///') } else { $_location = $location } # 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:\/\/)/ { ensure_packages('apt-transport-https') } } else { $_location = undef } $includes = merge($::apt::include_defaults, $include) if $key { if $key =~ Hash { unless $key['id'] { - fail(translate('key hash must contain at least an id entry')) + fail('key hash must contain at least an id entry') } $_key = merge($::apt::source_key_defaults, $key) } else { $_key = { 'id' => assert_type(String[1], $key) } } } $header = epp('apt/_header.epp') $sourcelist = epp('apt/source.list.epp', { 'comment' => $comment, 'includes' => $includes, 'opt_architecture' => $architecture, 'allow_unsigned' => $allow_unsigned, 'location' => $_location, 'release' => $_release, 'repos' => $repos, }) apt::setting { "list-${name}": ensure => $ensure, content => "${header}${sourcelist}", notify_update => $notify_update, } if $pin { if $pin =~ Hash { $_pin = merge($pin, { 'ensure' => $ensure, 'before' => $_before }) } elsif ($pin =~ Numeric or $pin =~ String) { $url_split = split($location, '[:\/]+') $host = $url_split[1] $_pin = { 'ensure' => $ensure, 'priority' => $pin, 'before' => $_before, 'origin' => $host, } } else { - fail(translate('Received invalid value for pin parameter')) + fail('Received invalid value for pin parameter') } create_resources('apt::pin', { "${name}" => $_pin }) } # We do not want to remove keys when the source is absent. if $key and ($ensure == 'present') { if $_key =~ Hash { if $_key['ensure'] != undef { $_ensure = $_key['ensure'] } else { $_ensure = $ensure } apt::key { "Add key: ${$_key['id']} from Apt::Source ${title}": ensure => $_ensure, id => $_key['id'], server => $_key['server'], content => $_key['content'], source => $_key['source'], options => $_key['options'], before => $_before, } } } } diff --git a/metadata.json b/metadata.json index 1dfa5d5..2bb036f 100644 --- a/metadata.json +++ b/metadata.json @@ -1,48 +1,44 @@ { "name": "puppetlabs-apt", "version": "8.0.1", "author": "puppetlabs", "summary": "Provides an interface for managing Apt source, key, and definitions with Puppet", "license": "Apache-2.0", "source": "https://github.com/puppetlabs/puppetlabs-apt", "project_page": "https://github.com/puppetlabs/puppetlabs-apt", "issues_url": "https://tickets.puppetlabs.com/browse/MODULES", "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": ">= 4.16.0 < 8.0.0" - }, - { - "name": "puppetlabs/translate", - "version_requirement": ">= 1.0.0 < 3.0.0" } ], "operatingsystem_support": [ { "operatingsystem": "Debian", "operatingsystemrelease": [ "8", "9", "10" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "14.04", "16.04", "18.04", "20.04" ] } ], "requirements": [ { "name": "puppet", "version_requirement": ">= 6.0.0 < 8.0.0" } ], "template-url": "https://github.com/puppetlabs/pdk-templates.git#main", "template-ref": "heads/main-0-g7be43a3", "pdk-version": "1.18.1" }