Fix architecture fact overriding unset `architecture` source option
authorDominic Cleal <dominic@cleal.org>
Mon, 24 Apr 2017 07:30:15 +0000 (08:30 +0100)
committerDominic Cleal <dominic@cleal.org>
Mon, 24 Apr 2017 07:33:51 +0000 (08:33 +0100)
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.

manifests/source.pp
spec/defines/source_spec.rb
templates/source.list.epp

index 8db3b28ef12457c501f498017372fe4cd6720458..9cb21338d771a87615ec9595a4548d21dcee458e 100644 (file)
@@ -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}":
index 0972512699d917132ac1d6e3d8c134e7c6b51120..10a8062911332167813a7eac0eec777c058b42db 100644 (file)
@@ -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
       {
index 727766c376cb092bfee570a6abdce7fa332e5ddc..4b29726c57464ca65f743d68b73d3b708ef2d4c4 100644 (file)
@@ -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 %>
 <%- } -%>