Skip to content

Commit

Permalink
Merge pull request #1053 from david22swan/GH-cat-9
Browse files Browse the repository at this point in the history
(GH-cat-9) Update module to match current syntax standard
  • Loading branch information
chelnak authored Aug 24, 2022
2 parents 5ce72ec + cb6e58c commit dad7d73
Show file tree
Hide file tree
Showing 14 changed files with 129 additions and 119 deletions.
7 changes: 0 additions & 7 deletions .puppet-lint.rc
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
--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
7 changes: 0 additions & 7 deletions .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,4 @@ spec/spec_helper.rb:
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
8 changes: 4 additions & 4 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ Data type: `Pattern[/\A((hkp|hkps|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+
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`

Expand All @@ -621,7 +621,7 @@ Data type: `Optional[String]`

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`

Expand Down Expand Up @@ -809,7 +809,7 @@ Data type: `Optional[Array[String]]`

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`

Expand All @@ -835,7 +835,7 @@ Data type: `Optional[String]`

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`

Expand Down
8 changes: 0 additions & 8 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,7 @@ def changelog_future_release
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|
Expand Down
6 changes: 3 additions & 3 deletions manifests/backports.pp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
}
}
unless $location {
$_location = $::apt::backports['location']
$_location = $apt::backports['location']
}
unless $release {
if fact('os.distro.codename') {
Expand All @@ -86,10 +86,10 @@
}
}
unless $repos {
$_repos = $::apt::backports['repos']
$_repos = $apt::backports['repos']
}
unless $key {
$_key = $::apt::backports['key']
$_key = $apt::backports['key']
}

if $pin =~ Hash {
Expand Down
47 changes: 34 additions & 13 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
# @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:
#
Expand All @@ -70,9 +73,15 @@
# @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.
#
Expand Down Expand Up @@ -125,6 +134,14 @@
# @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,
Expand Down Expand Up @@ -183,8 +200,8 @@
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'])
Expand All @@ -205,24 +222,28 @@
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 = {}
Expand Down Expand Up @@ -260,7 +281,7 @@
true => "# Repos managed by puppet.\n",
default => undef,
}
}
}

$preferences_ensure = $_purge['preferences'] ? {
true => absent,
Expand All @@ -274,7 +295,7 @@

file { 'sources.list':
ensure => $sources_list_ensure,
path => $::apt::sources_list,
path => $apt::sources_list,
owner => root,
group => root,
content => $sources_list_content,
Expand All @@ -283,7 +304,7 @@

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'],
Expand All @@ -293,15 +314,15 @@

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'],
Expand All @@ -311,7 +332,7 @@

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'],
Expand Down
8 changes: 4 additions & 4 deletions manifests/key.pp
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
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"]) {
Expand Down Expand Up @@ -82,7 +82,7 @@
}
}

absent: {
/^absent$/: {
if defined(Anchor["apt_key ${id} present"]) {
fail("key with id ${id} already ensured as present")
}
Expand Down
8 changes: 4 additions & 4 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@

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'
Expand Down
43 changes: 26 additions & 17 deletions manifests/pin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,29 @@
# @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
Expand Down Expand Up @@ -78,15 +87,15 @@
}

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')
}
}
Expand Down
19 changes: 10 additions & 9 deletions manifests/ppa.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
#
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 {
Expand Down Expand Up @@ -61,7 +61,7 @@
$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"
Expand All @@ -78,7 +78,7 @@
$_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']}"]
Expand All @@ -91,10 +91,11 @@

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',
Expand All @@ -118,7 +119,7 @@
}

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'],
}
}
Expand Down
Loading

0 comments on commit dad7d73

Please sign in to comment.