--relative
---no-top_scope_facts-check
---no-topscope_variable-check
---no-relative_classname_inclusion-check
---no-parameter_documentation-check
--no-anchor_resource-check
---no-strict_indent-check
---no-unquoted_string_in_case-check
---no-optional_default-check
changelog_since_tag: '5.0.1'
Rakefile:
extra_disabled_lint_checks:
- - top_scope_facts
- - topscope_variable
- - relative_classname_inclusion
- - parameter_documentation
- anchor_resource
- - strict_indent
- - unquoted_string_in_case
- - optional_default
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.
-Default value: `$::apt::keyserver`
+Default value: `$apt::keyserver`
##### <a name="weak_ssl"></a>`weak_ssl`
Passes additional options to `apt-key adv --keyserver-options`.
-Default value: `$::apt::key_options`
+Default value: `$apt::key_options`
### <a name="aptmark"></a>`apt::mark`
Supplies options to be passed to the `add-apt-repository` command. Default: '-y'.
-Default value: `$::apt::ppa_options`
+Default value: `$apt::ppa_options`
##### <a name="release"></a>`release`
Names the package that provides the `apt-add-repository` command. Default: 'software-properties-common'.
-Default value: `$::apt::ppa_package`
+Default value: `$apt::ppa_package`
##### <a name="package_manage"></a>`package_manage`
end
PuppetLint.configuration.send('disable_relative')
-PuppetLint.configuration.send('disable_top_scope_facts')
-PuppetLint.configuration.send('disable_topscope_variable')
-PuppetLint.configuration.send('disable_relative_classname_inclusion')
-PuppetLint.configuration.send('disable_parameter_documentation')
PuppetLint.configuration.send('disable_anchor_resource')
-PuppetLint.configuration.send('disable_strict_indent')
-PuppetLint.configuration.send('disable_unquoted_string_in_case')
-PuppetLint.configuration.send('disable_optional_default')
-
if Bundler.rubygems.find_name('github_changelog_generator').any?
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
}
}
unless $location {
- $_location = $::apt::backports['location']
+ $_location = $apt::backports['location']
}
unless $release {
if fact('os.distro.codename') {
}
}
unless $repos {
- $_repos = $::apt::backports['repos']
+ $_repos = $apt::backports['repos']
}
unless $key {
- $_key = $::apt::backports['key']
+ $_key = $apt::backports['key']
}
if $pin =~ Hash {
# @option update [Integer] :tries
# Specifies how many times to retry the update after receiving a DNS or HTTP error. Default: undef.
#
+# @param update_defaults
+# The default update settings that are combined and merged with the passed `update` value
+#
# @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] :preferences.d.
# Specifies whether to purge any unmanaged entries from preferences.d. Default false.
#
+# @param purge_defaults
+# The default purge settings that are combined and merged with the passed `purge` value
+#
# @param proxy
# Configures Apt to connect to a proxy server. Valid options: a hash matching the locally defined type apt::proxy.
#
+# @param proxy_defaults
+# The default proxy settings that are combined and merged with the passed `proxy` value
+#
# @param sources
# Creates new `apt::source` resources. Valid options: a hash to be passed to the create_resources function linked above.
#
# @param sources_list_force
# Specifies whether to perform force purge or delete. Default false.
#
+# @param include_defaults
+#
+# @param apt_conf_d
+# The path to the file `apt.conf.d`
+#
+# @param source_key_defaults
+# The fault `source_key` settings
+#
class apt (
Hash $update_defaults = $apt::params::update_defaults,
Hash $purge_defaults = $apt::params::purge_defaults,
assert_type(Integer, $update['tries'])
}
- $_update = merge($::apt::update_defaults, $update)
- include ::apt::update
+ $_update = merge($apt::update_defaults, $update)
+ include apt::update
if $purge['sources.list'] {
assert_type(Boolean, $purge['sources.list'])
assert_type(Boolean, $purge['apt.conf.d'])
}
- $_purge = merge($::apt::purge_defaults, $purge)
+ $_purge = merge($apt::purge_defaults, $purge)
if $proxy['perhost'] {
$_perhost = $proxy['perhost'].map |$item| {
$_item = merge($apt::proxy_defaults, $item)
$_scheme = $_item['https'] ? {
true => 'https',
- default => 'http' }
+ default => 'http',
+ }
$_port = $_item['port'] ? {
Integer => ":${_item['port']}",
default => ''
}
$_target = $_item['direct'] ? {
true => 'DIRECT',
- default => "${_scheme}://${_item['host']}${_port}/" }
+ default => "${_scheme}://${_item['host']}${_port}/",
+ }
merge($item, {
- 'scheme' => $_scheme,
- 'target' => $_target })
+ 'scheme' => $_scheme,
+ 'target' => $_target,
+ }
+ )
}
} else {
$_perhost = {}
true => "# Repos managed by puppet.\n",
default => undef,
}
- }
+ }
$preferences_ensure = $_purge['preferences'] ? {
true => absent,
file { 'sources.list':
ensure => $sources_list_ensure,
- path => $::apt::sources_list,
+ path => $apt::sources_list,
owner => root,
group => root,
content => $sources_list_content,
file { 'sources.list.d':
ensure => directory,
- path => $::apt::sources_list_d,
+ path => $apt::sources_list_d,
owner => root,
group => root,
purge => $_purge['sources.list.d'],
file { 'preferences':
ensure => $preferences_ensure,
- path => $::apt::preferences,
+ path => $apt::preferences,
owner => root,
group => root,
notify => Class['apt::update'],
file { 'preferences.d':
ensure => directory,
- path => $::apt::preferences_d,
+ path => $apt::preferences_d,
owner => root,
group => root,
purge => $_purge['preferences.d'],
file { 'apt.conf.d':
ensure => directory,
- path => $::apt::apt_conf_d,
+ path => $apt::apt_conf_d,
owner => root,
group => root,
purge => $_purge['apt.conf.d'],
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,
+ 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,
- ) {
+ Optional[String] $options = $apt::key_options,
+) {
case $ensure {
/^(refreshed|present)$/: {
if defined(Anchor["apt_key ${id} absent"]) {
}
}
- absent: {
+ /^absent$/: {
if defined(Anchor["apt_key ${id} present"]) {
fail("key with id ${id} already ensured as present")
}
case $facts['os']['name'] {
'Debian': {
- $backports = {
- 'location' => 'http://deb.debian.org/debian',
- 'repos' => 'main contrib non-free',
- }
+ $backports = {
+ 'location' => 'http://deb.debian.org/debian',
+ 'repos' => 'main contrib non-free',
+ }
$ppa_options = undef
$ppa_package = undef
$auth_conf_owner = '_apt'
# @param label
# Names the label of the packages in the directory tree of the Release file.
#
+# @param origin
+# The package origin
+#
+# @param version
+# The version of the package
+#
+# @param codename
+# The codename of the package
+#
define apt::pin (
- 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=
+ 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 = undef, # a=
+ Optional[String] $origin = undef,
+ Optional[String] $version = undef,
+ Optional[String] $codename = undef, # n=
+ Optional[String] $release_version = undef, # v=
+ Optional[String] $component = undef, # c=
+ Optional[String] $originator = undef, # o=
+ Optional[String] $label = undef, # l=
) {
if $explanation {
$_explanation = $explanation
}
if $packages_string != '*' { # specific form
- if ( $pin_release != '' and ( $origin != '' or $version != '' )) or
- ( $version != '' and ( $pin_release != '' or $origin != '' )) {
+ if ( $pin_release != '' and ( $origin or $version )) or
+ ( $version and ( $pin_release != '' or $origin )) {
fail('parameters release, origin, and version are mutually exclusive')
}
} else { # general form
- if $version != '' {
+ if $version {
fail('parameter version cannot be used in general form')
}
- if ( $pin_release != '' and $origin != '' ) {
+ if ( $pin_release != '' and $origin ) {
fail('parameters release and origin are mutually exclusive')
}
}
#
define apt::ppa (
String $ensure = 'present',
- Optional[Array[String]] $options = $::apt::ppa_options,
+ Optional[Array[String]] $options = $apt::ppa_options,
Optional[String] $release = fact('os.distro.codename'),
Optional[String] $dist = $facts['os']['name'],
- Optional[String] $package_name = $::apt::ppa_package,
+ Optional[String] $package_name = $apt::ppa_package,
Boolean $package_manage = false,
) {
unless $release {
$sources_list_d_filename = "${dash_filename_no_specialchars}-${release}.list"
if versioncmp($facts['os']['release']['full'], '15.10') >= 0 and
- versioncmp($facts['os']['release']['full'], '21.04') < 0 {
+ versioncmp($facts['os']['release']['full'], '21.04') < 0 {
$trusted_gpg_d_filename = "${underscore_filename_no_specialchars}.gpg"
} else {
$trusted_gpg_d_filename = "${dash_filename_no_specialchars}.gpg"
$_require = File['sources.list.d']
}
- $_proxy = $::apt::_proxy
+ $_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']}"]
unless $sources_list_d_filename in $facts['apt_sources'] {
$script_content = epp('apt/add-apt-repository.sh.epp', {
- command => ['/usr/bin/add-apt-repository', shell_join($options), $name],
- sources_list_d_path => $::apt::sources_list_d,
- sources_list_d_filename => $sources_list_d_filename,
- })
+ command => ['/usr/bin/add-apt-repository', shell_join($options), $name],
+ sources_list_d_path => $apt::sources_list_d,
+ sources_list_d_filename => $sources_list_d_filename,
+ }
+ )
file { "add-apt-repository-script-${name}":
ensure => 'file',
}
tidy { "remove-apt-repository-${name}":
- path => "${::apt::sources_list_d}/${sources_list_d_filename}",
+ path => "${apt::sources_list_d}/${sources_list_d_filename}",
notify => Class['apt::update'],
}
}
$_priority = $priority
}
- $_path = $::apt::config_files[$setting_type]['path']
- $_ext = $::apt::config_files[$setting_type]['ext']
+ $_path = $apt::config_files[$setting_type]['path']
+ $_ext = $apt::config_files[$setting_type]['ext']
if $notify_update {
$_notify = Class['apt::update']
Boolean $notify_update = true,
Boolean $check_valid_until = true,
) {
- include ::apt
+ include apt
$_before = Apt::Setting["list-${title}"]
if ! $location {
fail('cannot create a source entry without specifying a location')
}
- elsif ($::apt::proxy['https_acng']) and ($location =~ /(?i:^https:\/\/)/) {
+ elsif ($apt::proxy['https_acng']) and ($location =~ /(?i:^https:\/\/)/) {
$_location = regsubst($location, 'https://','http://HTTPS///')
}
else {
$_location = undef
}
- $includes = merge($::apt::include_defaults, $include)
+ $includes = merge($apt::include_defaults, $include)
if $key and $keyring {
fail('parameters key and keyring are mutualy exclusive')
unless $key['id'] {
fail('key hash must contain at least an id entry')
}
- $_key = merge($::apt::source_key_defaults, $key)
+ $_key = merge($apt::source_key_defaults, $key)
} else {
$_key = { 'id' => assert_type(String[1], $key) }
}
}
$sourcelist = epp('apt/source.list.epp', {
- 'comment' => $comment,
- 'includes' => $includes,
- 'options' => delete_undef_values( {
- 'arch' => $architecture,
- 'trusted' => $allow_unsigned ? { true => 'yes', false => undef },
- 'allow-insecure' => $allow_insecure ? { true => 'yes', false => undef },
- 'signed-by' => $keyring,
- 'check-valid-until' => $check_valid_until? { true => undef, false => 'false' },
- },
- ),
- 'location' => $_location,
- 'release' => $_release,
- 'repos' => $repos,
- })
+ 'comment' => $comment,
+ 'includes' => $includes,
+ 'options' => delete_undef_values( {
+ 'arch' => $architecture,
+ 'trusted' => $allow_unsigned ? { true => 'yes', false => undef },
+ 'allow-insecure' => $allow_insecure ? { true => 'yes', false => undef },
+ 'signed-by' => $keyring,
+ 'check-valid-until' => $check_valid_until? { true => undef, false => 'false' },
+ },
+ ),
+ 'location' => $_location,
+ 'release' => $_release,
+ 'repos' => $repos,
+ }
+ )
apt::setting { "list-${name}":
ensure => $ensure,
class apt::update {
assert_private()
- #TODO: to catch if $::apt_update_last_success has the value of -1 here. If we
+ #TODO: to catch if $apt_update_last_success has the value of -1 here. If we
#opt to do this, a info/warn would likely be all you'd need likely to happen
#on the first run, but if it's not run in awhile something is likely borked
#with apt and we'd want to know about it.
- case $::apt::_update['frequency'] {
+ case $apt::_update['frequency'] {
'always': {
$_kick_apt = true
}
#compare current date with the apt_update_last_success fact to determine
#if we should kick apt_update.
$daily_threshold = (Integer(Timestamp().strftime('%s')) - 86400)
- if $::apt_update_last_success {
- if $::apt_update_last_success + 0 < $daily_threshold {
+ if $apt::apt_update_last_success {
+ if $apt::apt_update_last_success + 0 < $daily_threshold {
$_kick_apt = true
} else {
$_kick_apt = false
#compare current date with the apt_update_last_success fact to determine
#if we should kick apt_update.
$weekly_threshold = (Integer(Timestamp().strftime('%s')) - 604800)
- if $::apt_update_last_success {
- if ( $::apt_update_last_success + 0 < $weekly_threshold ) {
+ if $apt::apt_update_last_success {
+ if ( $apt::apt_update_last_success + 0 < $weekly_threshold ) {
$_kick_apt = true
} else {
$_kick_apt = false
$_refresh = true
}
exec { 'apt_update':
- command => "${::apt::provider} update",
- loglevel => $::apt::_update['loglevel'],
+ command => "${apt::provider} update",
+ loglevel => $apt::_update['loglevel'],
logoutput => 'on_failure',
refreshonly => $_refresh,
- timeout => $::apt::_update['timeout'],
- tries => $::apt::_update['tries'],
+ timeout => $apt::_update['timeout'],
+ tries => $apt::_update['tries'],
try_sleep => 1,
}
}
'we are due for a run' => 1_406_660_561,
'the update-success-stamp file does not exist' => -1,
}.each_pair do |desc, factval|
- context "when $::apt_update_last_success indicates #{desc}" do
+ context "when $apt_update_last_success indicates #{desc}" do
let(:facts) do
{
os: {
id: 'Debian',
},
},
- apt_update_last_success: factval,
+ 'apt::apt_update_last_success': factval,
}
end
let(:pre_condition) do
end
end
end
- context 'when $::apt_update_last_success is nil' do
+ context 'when $apt_update_last_success is nil' do
let(:facts) do
{
os: {
id: 'Debian',
},
},
- apt_update_last_success: Time.now.to_i,
+ 'apt::apt_update_last_success': Time.now.to_i,
}
end
let(:pre_condition) do
'we are due for a run' => 1_406_660_561,
'the update-success-stamp file does not exist' => -1,
}.each_pair do |desc, factval|
- context "when $::apt_update_last_success indicates #{desc}" do
+ context "when $apt_update_last_success indicates #{desc}" do
let(:facts) do
{
os: {
id: 'Debian',
},
},
- apt_update_last_success: factval,
+ 'apt::apt_update_last_success': factval,
}
end
let(:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" }
end
end
end
- context 'when $::apt_update_last_success is nil' do
+ context 'when $apt_update_last_success is nil' do
let(:facts) do
{
os: {
['daily', 'weekly'].each do |update_frequency|
context "when apt::update['frequency'] has the value of #{update_frequency}" do
{ 'we are due for a run' => 1_406_660_561, 'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
- context "when $::apt_update_last_success indicates #{desc}" do
+ context "when $apt_update_last_success indicates #{desc}" do
let(:facts) do
{
os: {
id: 'Debian',
},
},
- apt_update_last_success: factval,
+ 'apt::apt_update_last_success': factval,
}
end
let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
end
end
end
- context 'when the $::apt_update_last_success fact has a recent value' do
+ context 'when the $apt_update_last_success fact has a recent value' do
let(:facts) do
{
os: {
id: 'Debian',
},
},
- apt_update_last_success: Time.now.to_i,
+ 'apt::apt_update_last_success': Time.now.to_i,
}
end
let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
is_expected.to contain_exec('apt_update').with('refreshonly' => true)
end
end
- context 'when $::apt_update_last_success is nil' do
+ context 'when $apt_update_last_success is nil' do
let(:facts) do
{
os: {
id: 'Debian',
},
},
- apt_update_last_success: nil,
+ 'apt::apt_update_last_success': nil,
}
end
let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }