X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=manifests%2Finit.pp;h=48c4f53050e8c8baaac5e3a86c307fbc0a38dc36;hb=93f40ca8928109956f3ecebbe8077414c5b52a29;hp=ea546dc55ef8badde4921cf4b5a77715d8571186;hpb=fe228435b1c9219b7fe61e6faafe810b117fd5e4;p=puppet-modules%2Fpuppetlabs-apt.git diff --git a/manifests/init.pp b/manifests/init.pp index ea546dc..48c4f53 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,20 +1,19 @@ # class apt( - $update = {}, - $purge = {}, - $proxy = {}, - $sources = undef, + $update = {}, + $purge = {}, + $proxy = {}, + $sources = {}, + $keys = {}, + $ppas = {}, + $settings = {}, ) inherits ::apt::params { - $frequency_options = ['always','daily','weekly','reluctantly'] validate_hash($update) if $update['frequency'] { validate_re($update['frequency'], $frequency_options) } - if $update['always'] { - validate_bool($update['always']) - } if $update['timeout'] { unless is_integer($update['timeout']) { fail('timeout value for update must be an integer') @@ -60,24 +59,29 @@ class apt( $_proxy = merge($apt::proxy_defaults, $proxy) + validate_hash($sources) + validate_hash($keys) + validate_hash($settings) + validate_hash($ppas) + if $proxy['host'] { apt::setting { 'conf-proxy': priority => '01', - content => template('apt/_header.erb', 'apt/proxy.erb'), + content => template('apt/_conf_header.erb', 'apt/proxy.erb'), } } $sources_list_content = $_purge['sources.list'] ? { - false => undef, - true => "# Repos managed by puppet.\n", + true => "# Repos managed by puppet.\n", + default => undef, } $preferences_ensure = $_purge['preferences'] ? { - false => file, - true => absent, + true => absent, + default => file, } - if $_update['always'] { + if $_update['frequency'] == 'always' { Exec <| title=='apt_update' |> { refreshonly => false, } @@ -85,7 +89,7 @@ class apt( apt::setting { 'conf-update-stamp': priority => 15, - content => template('apt/_header.erb', 'apt/15update-stamp.erb'), + content => template('apt/_conf_header.erb', 'apt/15update-stamp.erb'), } file { 'sources.list': @@ -129,14 +133,22 @@ class apt( notify => Exec['apt_update'], } - # Need anchor to provide containment for dependencies. - anchor { 'apt::update': - require => Class['apt::update'], - } + anchor { 'apt_first': } -> Class['apt::update'] -> anchor { 'apt_last': } # manage sources if present - if $sources != undef { - validate_hash($sources) + if $sources { create_resources('apt::source', $sources) } + # manage keys if present + if $keys { + create_resources('apt::key', $keys) + } + # manage ppas if present + if $ppas { + create_resources('apt::ppa', $ppas) + } + # manage settings if present + if $settings { + create_resources('apt::setting', $settings) + } }