X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=manifests%2Fsource.pp;h=3e6d0cb814870d0b30a4b3bd0fab11282d4e3935;hb=69edb0d6344a7c628c538219aa7b7b01ae131f6f;hp=ad80977c68cda73576dbf30b30c06bcd00bbcd54;hpb=4815fa1f5482814e1d1a7e1626277aa35e3fc67c;p=puppet-modules%2Fpuppetlabs-apt.git diff --git a/manifests/source.pp b/manifests/source.pp index ad80977..3e6d0cb 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -1,17 +1,17 @@ # source.pp # add an 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 = {}, - Optional[Variant[String, Hash]] $key = undef, - $pin = undef, - Optional[String] $architecture = undef, - Boolean $allow_unsigned = false, - Boolean $notify_update = true, + 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, ) { # This is needed for compat with 1.8.x @@ -19,7 +19,7 @@ define apt::source( $_before = Apt::Setting["list-${title}"] - if ! $release { + if !$release { if $facts['lsbdistcodename'] { $_release = $facts['lsbdistcodename'] } else { @@ -29,34 +29,40 @@ define apt::source( $_release = $release } - if $ensure == 'present' and ! $location { - fail('cannot create a source entry without specifying a location') + if $ensure == 'present' { + if ! $location { + fail('cannot create a source entry without specifying a location') + } elsif $_release == 'jessie' { + $method = split($location, '[:\/]+')[0] + if $method == 'https' { + ensure_packages('apt-transport-https') + } + } } $includes = merge($::apt::include_defaults, $include) if $key { - if is_hash($key) { + if $key =~ Hash { unless $key['id'] { fail('key hash must contain at least an id entry') } $_key = merge($::apt::source_key_defaults, $key) } else { - validate_legacy(String, 'validate_string', $key) - $_key = { 'id' => $key } + $_key = { 'id' => assert_type(String[1], $key) } } } $header = epp('apt/_header.epp') $sourcelist = epp('apt/source.list.epp', { - 'comment' => $comment, - 'includes' => $includes, - 'architecture' => $architecture, - 'allow_unsigned' => $allow_unsigned, - 'location' => $location, - 'release' => $_release, - 'repos' => $repos, + 'comment' => $comment, + 'includes' => $includes, + 'opt_architecture' => $architecture, + 'allow_unsigned' => $allow_unsigned, + 'location' => $location, + 'release' => $_release, + 'repos' => $repos, }) apt::setting { "list-${name}": @@ -66,9 +72,9 @@ define apt::source( } if $pin { - if is_hash($pin) { + if $pin =~ Hash { $_pin = merge($pin, { 'ensure' => $ensure, 'before' => $_before }) - } elsif (is_numeric($pin) or is_string($pin)) { + } elsif ($pin =~ Numeric or $pin =~ String) { $url_split = split($location, '[:\/]+') $host = $url_split[1] $_pin = { @@ -85,7 +91,7 @@ define apt::source( # We do not want to remove keys when the source is absent. if $key and ($ensure == 'present') { - if is_hash($_key) { + if $_key =~ Hash { apt::key { "Add key: ${$_key['id']} from Apt::Source ${title}": ensure => present, id => $_key['id'],