(CONT-581) Adding deferred function support for password field CONT-581
authorRamesh Sencha <ramesh.sencha@perforce.com>
Mon, 29 May 2023 08:38:36 +0000 (14:08 +0530)
committerRamesh Sencha <ramesh.sencha@perforce.com>
Tue, 30 May 2023 13:02:59 +0000 (18:32 +0530)
manifests/init.pp
spec/classes/apt_spec.rb
spec/defines/source_spec.rb
templates/auth_conf.epp

index 7d1baf3fb4965cda2de59d0d3de8c9396081e252..cd408d8f67e0da8140c1edd4bf67706c8cfa53d5 100644 (file)
@@ -366,14 +366,14 @@ class apt (
       default => 'present',
     }
 
-    $auth_conf_tmp = epp('apt/auth_conf.epp')
+    $auth_conf_tmp = stdlib::deferrable_epp('apt/auth_conf.epp', { 'auth_conf_entries' => $auth_conf_entries })
 
     file { '/etc/apt/auth.conf':
       ensure  => $auth_conf_ensure,
       owner   => $auth_conf_owner,
       group   => 'root',
       mode    => '0600',
-      content => Sensitive("${confheadertmp}${auth_conf_tmp}"),
+      content => Sensitive($auth_conf_tmp),
       notify  => Class['apt::update'],
     }
   }
index cb65c1e0012a12193a03ac9e6d854f3838ad38d6..51cc7eb459080d331faca4f4d37804a97a8a7cd7 100644 (file)
@@ -415,10 +415,11 @@ describe 'apt' do
             super().merge(manage_auth_conf: true)
           end
 
-          auth_conf_content = "// This file is managed by Puppet. DO NOT EDIT.
-machine deb.example.net login foologin password secret
-machine apt.example.com login aptlogin password supersecret
-"
+          auth_conf_content = <<~CONTENT
+            // This file is managed by Puppet. DO NOT EDIT.
+            machine deb.example.net login foologin password secret
+            machine apt.example.com login aptlogin password supersecret
+          CONTENT
 
           it {
             expect(subject).to contain_file('/etc/apt/auth.conf').with(ensure: 'present',
index e9c0cf28af2d52205c9ffdc80c10ccaff31f544b..d9627172be7945275eab6ff31670cad3154d9294 100644 (file)
@@ -130,7 +130,7 @@ describe 'apt::source' do
 
       it {
         expect(subject).to contain_apt__key("Add key: #{id} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'refreshed',
-                                                                                                                                                id: GPG_KEY_ID,
+                                                                                                                                                id: id,
                                                                                                                                                 server: 'pgp.mit.edu',
                                                                                                                                                 content: 'GPG key content',
                                                                                                                                                 source: 'http://apt.puppetlabs.com/pubkey.gpg',
index 5b3000ffcc604aee88287388fc0f123c8299c6af..5dc37e9626d4ca712f972b23ffef39c5a83d2a24 100644 (file)
@@ -1,5 +1,6 @@
-<% if $apt::auth_conf_entries != [] { -%>
-<% $apt::auth_conf_entries.each | $auth_conf_entry | { -%>
+// This file is managed by Puppet. DO NOT EDIT.
+<% if $auth_conf_entries != [] { -%>
+<% $auth_conf_entries.each | $auth_conf_entry | { -%>
 machine <%= $auth_conf_entry['machine'] %> login <%= $auth_conf_entry['login'] %> password <%= $auth_conf_entry['password'] %>
 <% } -%>
 <% } -%>