Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaks when a Package title != name #5

Open
giuliano108 opened this issue Jan 28, 2017 · 0 comments
Open

Breaks when a Package title != name #5

giuliano108 opened this issue Jan 28, 2017 · 0 comments

Comments

@giuliano108
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant