Skip to content

Breaks when a Package title != name #5

@giuliano108

Description

@giuliano108

I found about this while trying to use an up to date version of package_purging at work. Specifically, the bug is triggered by the Docker module.

To reproduce, apply the patch below to the fix_tests branch (which hasn't been merged yet but should hopefully be soon, see PR #4) and run Beaker.

The test case below yields:

Error: Failed to apply catalog: Cannot alias Package[fortunes] to ["fortunes", :held_apt]; resource ["Package", "fortunes", :held_apt] already declared at /tmp/apply_manifest.pp.KZ4wgB:5

If "name => 'fortunes'" is commented out, the test passes.

commit 09e94469d57fbf73312c4be4cc7011a50e6e0993
Author: Giuliano Cioffi <[email protected]>
Date:   Sat Jan 28 14:15:15 2017 -0800

    title vs. name

diff --git a/spec/acceptance/purges_safely_spec.rb b/spec/acceptance/purges_safely_spec.rb
index 3f46270..21c683e 100644
--- a/spec/acceptance/purges_safely_spec.rb
+++ b/spec/acceptance/purges_safely_spec.rb
@@ -7,6 +7,7 @@ describe 'package_purging_with_apt' do
       package { 'puppetlabs-release-pc1': }
       package { 'puppet-agent': }
       package { 'fortunes': }
+      package { 'openssh-server': }
       include package_purging::config
       aptly_purge { 'packages': }
     EOS
diff --git a/spec/acceptance/zz_aliasing_bug_spec.rb b/spec/acceptance/zz_aliasing_bug_spec.rb
new file mode 100644
index 0000000..b071f99
--- /dev/null
+++ b/spec/acceptance/zz_aliasing_bug_spec.rb
@@ -0,0 +1,26 @@
+require 'spec_helper_acceptance'
+
+describe 'title_and_name' do
+  before :all do
+    hosts.each do |host|
+      install_package host, 'fortunes'
+      # same as `include package_purging::config`, saves a Puppet run
+      create_remote_file host, '/etc/apt/apt.conf.d/99always-purge', "APT::Get::Purge \"true\";\n";
+    end
+  end
+
+  it 'should work when, in a package resource, title and name differ' do
+    m = <<-EOS
+      package { 'ubuntu-minimal': }
+      package { 'puppetlabs-release-pc1': }
+      package { 'puppet-agent': }
+      package { 'openssh-server': }
+      package {'fortunespkg':
+        name => 'fortunes',  # commenting this out causes the test to pass
+      }
+      aptly_purge {'packages': }
+    EOS
+    apply_manifest m, :debug => true
+    expect(@result.exit_code).to eq 0
+  end
+end

/cc @solarkennedy

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions