From 6004f13a3a6c1baf4612316b71abff796914789b Mon Sep 17 00:00:00 2001 From: david22swan Date: Wed, 20 Apr 2022 14:07:49 +0100 Subject: [PATCH] (GH-cat-9) syntax:hiera:yaml fixes --- examples/builddep.pp | 2 +- examples/debian_testing.pp | 4 ++-- examples/debian_unstable.pp | 4 ++-- examples/disable_keys.pp | 2 +- examples/ppa.pp | 2 +- manifests/backports.pp | 4 ++-- manifests/conf.pp | 1 - manifests/init.pp | 11 ++++------- manifests/key.pp | 11 ++++++----- manifests/mark.pp | 1 - manifests/params.pp | 5 ++--- manifests/pin.pp | 5 ++--- manifests/ppa.pp | 2 +- manifests/setting.pp | 3 +-- manifests/source.pp | 18 +++++++++--------- manifests/update.pp | 2 +- 16 files changed, 35 insertions(+), 42 deletions(-) diff --git a/examples/builddep.pp b/examples/builddep.pp index deaaef8..8c23a94 100644 --- a/examples/builddep.pp +++ b/examples/builddep.pp @@ -1,3 +1,3 @@ -package{ 'glusterfs-server': +package { 'glusterfs-server': install_options => 'build-dep', } diff --git a/examples/debian_testing.pp b/examples/debian_testing.pp index 3ed98f2..bea2f08 100644 --- a/examples/debian_testing.pp +++ b/examples/debian_testing.pp @@ -1,9 +1,9 @@ package { 'debian-keyring': - ensure => present + ensure => present, } package { 'debian-archive-keyring': - ensure => present + ensure => present, } apt::source { 'debian_testing': diff --git a/examples/debian_unstable.pp b/examples/debian_unstable.pp index b1492cd..344f90c 100644 --- a/examples/debian_unstable.pp +++ b/examples/debian_unstable.pp @@ -1,9 +1,9 @@ package { 'debian-keyring': - ensure => present + ensure => present, } package { 'debian-archive-keyring': - ensure => present + ensure => present, } apt::source { 'debian_unstable': diff --git a/examples/disable_keys.pp b/examples/disable_keys.pp index 50d0ea8..a39b932 100644 --- a/examples/disable_keys.pp +++ b/examples/disable_keys.pp @@ -1,5 +1,5 @@ #Note: This is generally a bad idea. You should not disable verifying repository signatures. apt::conf { 'unauth': priority => 99, - content => 'APT::Get::AllowUnauthenticated 1;' + content => 'APT::Get::AllowUnauthenticated 1;', } diff --git a/examples/ppa.pp b/examples/ppa.pp index e728f6f..1dea2b4 100644 --- a/examples/ppa.pp +++ b/examples/ppa.pp @@ -1,4 +1,4 @@ class { 'apt': } # Example declaration of an Apt PPA -apt::ppa{ 'ppa:openstack-ppa/bleeding-edge': } +apt::ppa { 'ppa:openstack-ppa/bleeding-edge': } diff --git a/manifests/backports.pp b/manifests/backports.pp index 0dcecbe..1a9ea1b 100644 --- a/manifests/backports.pp +++ b/manifests/backports.pp @@ -53,8 +53,8 @@ class apt::backports ( 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 = {}, + Variant[Integer, String, Hash] $pin = 200, + Variant[Hash] $include = {}, ) { include apt diff --git a/manifests/conf.pp b/manifests/conf.pp index c27f0c1..0aec66d 100644 --- a/manifests/conf.pp +++ b/manifests/conf.pp @@ -19,7 +19,6 @@ define apt::conf ( Variant[String, Integer] $priority = 50, Optional[Boolean] $notify_update = undef, ) { - unless $ensure == 'absent' { unless $content { fail('Need to pass in content parameter') diff --git a/manifests/init.pp b/manifests/init.pp index 7e4b4c9..4aa4a68 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -143,7 +143,7 @@ class apt ( 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, + $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, @@ -163,7 +163,6 @@ class apt ( } ) inherits apt::params { - if $facts['os']['family'] != 'Debian' { fail('This module only works on Debian or derivatives like Ubuntu') } @@ -226,10 +225,10 @@ class apt ( $_perhost = {} } - $_proxy = merge($apt::proxy_defaults, $proxy, { 'perhost' => $_perhost } ) + $_proxy = merge($apt::proxy_defaults, $proxy, { 'perhost' => $_perhost }) $confheadertmp = epp('apt/_conf_header.epp') - $proxytmp = epp('apt/proxy.epp', {'proxies' => $_proxy}) + $proxytmp = epp('apt/proxy.epp', { 'proxies' => $_proxy }) $updatestamptmp = epp('apt/15update-stamp.epp') if $_proxy['ensure'] == 'absent' or $_proxy['host'] { @@ -249,9 +248,7 @@ class apt ( true => nil, default => undef, } - } - else - { + } else { $sources_list_ensure = $_purge['sources.list'] ? { true => file, default => file, diff --git a/manifests/key.pp b/manifests/key.pp index 4848763..e432f3c 100644 --- a/manifests/key.pp +++ b/manifests/key.pp @@ -44,10 +44,9 @@ define apt::key ( Boolean $weak_ssl = false, Optional[String] $options = $::apt::key_options, ) { - case $ensure { /^(refreshed|present)$/: { - if defined(Anchor["apt_key ${id} absent"]){ + if defined(Anchor["apt_key ${id} absent"]) { fail("key with id ${id} already ensured as absent") } @@ -76,17 +75,19 @@ define apt::key ( Apt::Key<| title == $title |> } } - default: { } + default: { + # Nothing in here + } } } } absent: { - if defined(Anchor["apt_key ${id} present"]){ + if defined(Anchor["apt_key ${id} present"]) { fail("key with id ${id} already ensured as present") } - if !defined(Anchor["apt_key ${id} absent"]){ + if !defined(Anchor["apt_key ${id} absent"]) { apt_key { $title: ensure => $ensure, id => $id, diff --git a/manifests/mark.pp b/manifests/mark.pp index dfad6b8..f4b7de0 100644 --- a/manifests/mark.pp +++ b/manifests/mark.pp @@ -21,4 +21,3 @@ define apt::mark ( unless => $unless_cmd, } } - diff --git a/manifests/params.pp b/manifests/params.pp index ae656db..5ef175b 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -3,7 +3,6 @@ # @api private # class apt::params { - if $facts['os']['family'] != 'Debian' { fail('This module only works on Debian or derivatives like Ubuntu') } @@ -44,7 +43,7 @@ class apt::params { 'list' => { 'path' => $sources_list_d, 'ext' => '.list', - } + }, } $update_defaults = { @@ -76,7 +75,7 @@ class apt::params { 'src' => false, } - case $facts['os']['name']{ + case $facts['os']['name'] { 'Debian': { $backports = { 'location' => 'http://deb.debian.org/debian', diff --git a/manifests/pin.pp b/manifests/pin.pp index 9310653..c8a45e9 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -33,8 +33,8 @@ # @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, +define apt::pin ( + Enum['file', 'present', 'absent'] $ensure = present, Optional[String] $explanation = undef, Variant[Integer] $order = 50, Variant[String, Array] $packages = '*', @@ -48,7 +48,6 @@ define apt::pin( Optional[String] $originator = '', # o= Optional[String] $label = '', # l= ) { - if $explanation { $_explanation = $explanation } else { diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 0d3c7b7..bab7b33 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -23,7 +23,7 @@ # @param package_manage # Specifies whether Puppet should manage the package that provides `apt-add-repository`. # -define apt::ppa( +define apt::ppa ( String $ensure = 'present', Optional[String] $options = $::apt::ppa_options, Optional[String] $release = fact('os.distro.codename'), diff --git a/manifests/setting.pp b/manifests/setting.pp index 6757f61..aa16161 100644 --- a/manifests/setting.pp +++ b/manifests/setting.pp @@ -21,12 +21,11 @@ # define apt::setting ( Variant[String, Integer, Array] $priority = 50, - Optional[Enum['file', 'present', 'absent']] $ensure = file, + Enum['file', 'present', 'absent'] $ensure = file, Optional[String] $source = undef, Optional[String] $content = undef, Boolean $notify_update = true, ) { - if $content and $source { fail('apt::setting cannot have both content and source') } diff --git a/manifests/source.pp b/manifests/source.pp index b24aa34..fcdc454 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -58,13 +58,13 @@ # @param notify_update # Specifies whether to trigger an `apt-get update` run. # -define apt::source( +define apt::source ( Optional[String] $location = undef, String $comment = $name, String $ensure = present, Optional[String] $release = undef, String $repos = 'main', - Optional[Variant[Hash]] $include = {}, + Variant[Hash] $include = {}, Optional[Variant[String, Hash]] $key = undef, Optional[Stdlib::AbsolutePath] $keyring = undef, Optional[Variant[Hash, Numeric, String]] $pin = undef, @@ -73,7 +73,6 @@ define apt::source( Boolean $allow_insecure = false, Boolean $notify_update = true, ) { - include ::apt $_before = Apt::Setting["list-${title}"] @@ -136,12 +135,13 @@ define apt::source( $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, - }), + 'options' => delete_undef_values( { + 'arch' => $architecture, + 'trusted' => $allow_unsigned ? { true => 'yes', false => undef }, + 'allow-insecure' => $allow_insecure ? { true => 'yes', false => undef }, + 'signed-by' => $keyring, + }, + ), 'location' => $_location, 'release' => $_release, 'repos' => $repos, diff --git a/manifests/update.pp b/manifests/update.pp index 1ea16af..256ea7d 100644 --- a/manifests/update.pp +++ b/manifests/update.pp @@ -63,6 +63,6 @@ class apt::update { refreshonly => $_refresh, timeout => $::apt::_update['timeout'], tries => $::apt::_update['tries'], - try_sleep => 1 + try_sleep => 1, } } -- 2.45.2