Ignore:
Timestamp:
Aug 1, 2017, 3:45:14 PM (9 years ago)
Author:
Joachim Langenbach <joachim.langenbach@…>
Branches:
debian/bullseye, debian/jessie
Children:
ce0f6a4
Parents:
bcf0be5 (diff), cd0f9cc (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into debian/jessie

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/puppetcode/environments/gnuboat/modules/apt/manifests/init.pp

    rbcf0be5 rad28f83  
     1# == Class: apt
    12#
    2 class apt(
    3   $update   = {},
    4   $purge    = {},
    5   $proxy    = {},
    6   $sources  = {},
    7   $keys     = {},
    8   $ppas     = {},
    9   $pins     = {},
    10   $settings = {},
    11 ) inherits ::apt::params {
     3# Manage APT (Advanced Packaging Tool)
     4#
     5class apt (
     6  Hash $update_defaults         = $apt::params::update_defaults,
     7  Hash $purge_defaults          = $apt::params::purge_defaults,
     8  Hash $proxy_defaults          = $apt::params::proxy_defaults,
     9  Hash $include_defaults        = $apt::params::include_defaults,
     10  String $provider              = $apt::params::provider,
     11  String $keyserver             = $apt::params::keyserver,
     12  Optional[String] $ppa_options = $apt::params::ppa_options,
     13  Optional[String] $ppa_package = $apt::params::ppa_package,
     14  Optional[Hash] $backports     = $apt::params::backports,
     15  Hash $confs                   = $apt::params::confs,
     16  Hash $update                  = $apt::params::update,
     17  Hash $purge                   = $apt::params::purge,
     18  Hash $proxy                   = $apt::params::proxy,
     19  Hash $sources                 = $apt::params::sources,
     20  Hash $keys                    = $apt::params::keys,
     21  Hash $ppas                    = $apt::params::ppas,
     22  Hash $pins                    = $apt::params::pins,
     23  Hash $settings                = $apt::params::settings,
     24  String $root                  = $apt::params::root,
     25  String $sources_list          = $apt::params::sources_list,
     26  String $sources_list_d        = $apt::params::sources_list_d,
     27  String $conf_d                = $apt::params::conf_d,
     28  String $preferences           = $apt::params::preferences,
     29  String $preferences_d         = $apt::params::preferences_d,
     30  Hash $config_files            = $apt::params::config_files,
     31  Hash $source_key_defaults     = $apt::params::source_key_defaults
     32) inherits apt::params {
     33
     34  if $facts['osfamily'] != 'Debian' {
     35    fail('This module only works on Debian or derivatives like Ubuntu')
     36  }
    1237
    1338  $frequency_options = ['always','daily','weekly','reluctantly']
    14   validate_hash($update)
     39
    1540  if $update['frequency'] {
    1641    validate_re($update['frequency'], $frequency_options)
    1742  }
    1843  if $update['timeout'] {
    19     unless is_integer($update['timeout']) {
    20       fail('timeout value for update must be an integer')
    21     }
     44    assert_type(Integer, $update['timeout'])
    2245  }
    2346  if $update['tries'] {
    24     unless is_integer($update['tries']) {
    25       fail('tries value for update must be an integer')
    26     }
     47    assert_type(Integer, $update['tries'])
    2748  }
    2849
    … …  
    3051  include ::apt::update
    3152
    32   validate_hash($purge)
    3353  if $purge['sources.list'] {
    34     validate_bool($purge['sources.list'])
     54    assert_type(Boolean, $purge['sources.list'])
    3555  }
    3656  if $purge['sources.list.d'] {
    37     validate_bool($purge['sources.list.d'])
     57    assert_type(Boolean, $purge['sources.list.d'])
    3858  }
    3959  if $purge['preferences'] {
    40     validate_bool($purge['preferences'])
     60    assert_type(Boolean, $purge['preferences'])
    4161  }
    4262  if $purge['preferences.d'] {
    43     validate_bool($purge['preferences.d'])
     63    assert_type(Boolean, $purge['preferences.d'])
    4464  }
    4565
    4666  $_purge = merge($::apt::purge_defaults, $purge)
    4767
    48   validate_hash($proxy)
    4968  if $proxy['ensure'] {
    5069    validate_re($proxy['ensure'], ['file', 'present', 'absent'])
    5170  }
    5271  if $proxy['host'] {
    53     validate_string($proxy['host'])
     72    assert_type(String, $proxy['host'])
    5473  }
    5574  if $proxy['port'] {
    56     unless is_integer($proxy['port']) {
    57       fail('$proxy port must be an integer')
    58     }
     75    assert_type(Integer, $proxy['port'])
    5976  }
    60   if $proxy['https'] {
    61     validate_bool($proxy['https'])
     77  if $proxy['https']{
     78    assert_type(Boolean, $proxy['https'])
    6279  }
    6380
    6481  $_proxy = merge($apt::proxy_defaults, $proxy)
    6582
    66   validate_hash($sources)
    67   validate_hash($keys)
    68   validate_hash($settings)
    69   validate_hash($ppas)
    70   validate_hash($pins)
     83  $confheadertmp = epp('apt/_conf_header.epp')
     84  $proxytmp = epp('apt/proxy.epp', {'proxies' => $_proxy})
     85  $updatestamptmp = epp('apt/15update-stamp.epp')
    7186
    7287  if $_proxy['ensure'] == 'absent' or $_proxy['host'] {
    … …  
    7489      ensure   => $_proxy['ensure'],
    7590      priority => '01',
    76       content  => template('apt/_conf_header.erb', 'apt/proxy.erb'),
     91      content  => "${confheadertmp}${proxytmp}",
    7792    }
    7893  }
    … …  
    96111  apt::setting { 'conf-update-stamp':
    97112    priority => 15,
    98     content  => template('apt/_conf_header.erb', 'apt/15update-stamp.erb'),
     113    content  => "${confheadertmp}${updatestamptmp}",
    99114  }
    100115
    … …  
    140155  }
    141156
     157  if $confs {
     158    create_resources('apt::conf', $confs)
     159  }
    142160  # manage sources if present
    143161  if $sources {
Note: See TracChangeset for help on using the changeset viewer.