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

Add yum::repo ensure => absent functionality #22

Merged
merged 2 commits into from
Sep 28, 2017

Conversation

jeffmccune
Copy link
Contributor

Without this patch, puppet cannot easily remove specific yum
repositories. This is a problem in situations where the
directory cannot be fully purged due to unmanaged files and
when a specific configuration needs to be removed from specific
nodes.

Without this patch puppet-lint 2.3.1 results in this error in Ruby 1.8.7:

    SyntaxError: /home/travis/.rvm/gems/ruby-1.8.7-p371/gems/puppet-lint-2.3.1/lib/puppet-lint/configuration.rb:53: undefined (?...) sequence: /^(?<option>\w+)=?$/
    /home/travis/.rvm/gems/ruby-1.8.7-p371/gems/puppet-lint-2.3.1/lib/puppet-lint.rb:7:in `gem_original_require'
    /home/travis/.rvm/gems/ruby-1.8.7-p371/gems/puppet-lint-2.3.1/lib/puppet-lint.rb:7:in `require'
    /home/travis/.rvm/gems/ruby-1.8.7-p371/gems/puppet-lint-2.3.1/lib/puppet-lint.rb:7
    /home/travis/.rvm/gems/ruby-1.8.7-p371/gems/puppet-lint-2.3.1/lib/puppet-lint/tasks/puppet-lint.rb:1:in `gem_original_require'
    /home/travis/.rvm/gems/ruby-1.8.7-p371/gems/puppet-lint-2.3.1/lib/puppet-lint/tasks/puppet-lint.rb:1:in `require'
    /home/travis/.rvm/gems/ruby-1.8.7-p371/gems/puppet-lint-2.3.1/lib/puppet-lint/tasks/puppet-lint.rb:1
    /home/travis/.rvm/gems/ruby-1.8.7-p371/gems/puppetlabs_spec_helper-2.0.2/lib/puppetlabs_spec_helper/rake_tasks.rb:438:in `gem_original_require'
    /home/travis/.rvm/gems/ruby-1.8.7-p371/gems/puppetlabs_spec_helper-2.0.2/lib/puppetlabs_spec_helper/rake_tasks.rb:438:in `require'
    /home/travis/.rvm/gems/ruby-1.8.7-p371/gems/puppetlabs_spec_helper-2.0.2/lib/puppetlabs_spec_helper/rake_tasks.rb:438
    /home/travis/build/nytm/puppet-module-confluence/Rakefile:1:in `gem_original_require'
    /home/travis/build/nytm/puppet-module-confluence/Rakefile:1:in `require'
    /home/travis/build/nytm/puppet-module-confluence/Rakefile:1
    /home/travis/.rvm/gems/ruby-1.8.7-p371/bin/ruby_executable_hooks:15
    (See full trace by running task with --trace)

The issue has been filed upstream as rodjek/puppet-lint#759
@jeffmccune jeffmccune force-pushed the yum_repo_ensure_absent branch 2 times, most recently from 59aac67 to be3335b Compare September 27, 2017 23:18
@@ -155,7 +164,6 @@

# Only need to deal with importing GPG keys, if we have gpgcheck enabled
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a conditional around the existing conditional and code for yum::rpm_gpg_key

if $ensure == 'present' {
<existing code>
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added ensure == 'present' condition.

@@ -232,6 +232,16 @@
it { should contain_file('rspec.repo').with_content(/\[rspec\][\s\S]*sslcacert=\/path\/to\/cert/) }
end

context 'with ensure set to valid string "absent"' do
let(:params) { mandatory_params.merge({ :ensure => 'absent' }) }
it { should contain_file('rspec.repo').with_ensure('absent') }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it { is_expected.to have_yum__rpm_gpg_key_resource_count(0) }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, added the test.

Without this patch, puppet cannot easily remove specific yum
repositories.  This is a problem in situations where the
directory cannot be fully purged due to unmanaged files and
when a specific configuration needs to be removed from specific
nodes.
@jeffmccune
Copy link
Contributor Author

@ghoneycutt Requested changes have been made.

@ghoneycutt ghoneycutt merged commit 88ed882 into ghoneycutt:master Sep 28, 2017
@ghoneycutt
Copy link
Owner

Released in v1.4.0

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

Successfully merging this pull request may close these issues.

2 participants