From: Dominic Cleal Date: Mon, 24 Apr 2017 07:30:15 +0000 (+0100) Subject: Fix architecture fact overriding unset `architecture` source option X-Git-Tag: 4.0.0^2^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=c9a7fe36241831bf95426795e38edaf203396f20;p=puppet-modules%2Fpuppetlabs-apt.git Fix architecture fact overriding unset `architecture` source option When the `architecture` parameter to apt::source wasn't set, the `architecture` fact would be used instead, causing the source to always be limited by the architecture of the host. The EPP variable has been renamed to avoid clashing with the fact name. --- diff --git a/manifests/source.pp b/manifests/source.pp index 8db3b28..9cb2133 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -99,13 +99,13 @@ define apt::source( $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}": diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 0972512..10a8062 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -237,6 +237,30 @@ describe 'apt::source' do } end + context 'with architecture fact and unset architecture parameter' do + let :facts do + { + :architecture => 'amd64', + :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }}, + :lsbdistid => 'Debian', + :lsbdistcodename => 'wheezy', + :osfamily => 'Debian', + :puppetversion => Puppet.version, + } + end + let :params do + { + :location => 'hello.there', + :include => {'deb' => false, 'src' => true,}, + } + end + + it { is_expected.to contain_apt__setting('list-my_source').with({ + :ensure => 'present', + }).with_content(/# my_source\ndeb-src hello.there wheezy main\n/) + } + end + context 'include_src => true' do let :facts do { diff --git a/templates/source.list.epp b/templates/source.list.epp index 727766c..4b29726 100644 --- a/templates/source.list.epp +++ b/templates/source.list.epp @@ -1,10 +1,10 @@ -<%- | String $comment, Hash $includes, $architecture, Boolean $allow_unsigned, $location, $release, String $repos | -%> +<%- | String $comment, Hash $includes, $opt_architecture, Boolean $allow_unsigned, $location, $release, String $repos | -%> # <%= $comment %> <%- if $includes['deb'] { -%> -deb <%- if ($architecture or $allow_unsigned) {-%> - [<%- if ($architecture) {%>arch=<%= $architecture %><% } %><%if ($architecture and $allow_unsigned) {%> <% }%><% if ($allow_unsigned) {%>trusted=yes<% } %>] <%- } %> <%= $location %> <%= $release %> <%= $repos %> +deb <%- if ($opt_architecture or $allow_unsigned) {-%> + [<%- if ($opt_architecture) {%>arch=<%= $opt_architecture %><% } %><%if ($opt_architecture and $allow_unsigned) {%> <% }%><% if ($allow_unsigned) {%>trusted=yes<% } %>] <%- } %> <%= $location %> <%= $release %> <%= $repos %> <%- } -%> <%- if $includes['src'] { -%> -deb-src <%- if $architecture or $allow_unsigned { -%> - [<%- if ($architecture) {%>arch=<%= $architecture %><% } %><%if ($architecture and $allow_unsigned) {%> <% }%><% if ($allow_unsigned) {%>trusted=yes<% } %>] <%- } %> <%= $location %> <%= $release %> <%= $repos %> +deb-src <%- if $opt_architecture or $allow_unsigned { -%> + [<%- if ($opt_architecture) {%>arch=<%= $opt_architecture %><% } %><%if ($opt_architecture and $allow_unsigned) {%> <% }%><% if ($allow_unsigned) {%>trusted=yes<% } %>] <%- } %> <%= $location %> <%= $release %> <%= $repos %> <%- } -%>