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 remove action to package resource #92

Merged
merged 2 commits into from
Mar 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion itamae.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]

spec.add_runtime_dependency "thor"
spec.add_runtime_dependency "specinfra", "~> 2.12.1"
spec.add_runtime_dependency "specinfra", ">= 2.18.2"
spec.add_runtime_dependency "hashie"
spec.add_runtime_dependency "ansi"

Expand Down
9 changes: 9 additions & 0 deletions lib/itamae/resource/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ def pre_action
case @current_action
when :install
attributes.installed = true
when :remove
attributes.installed = false
end
end

Expand All @@ -29,6 +31,13 @@ def action_install(action_options)
updated!
end
end

def action_remove(action_options)
if run_specinfra(:check_package_is_installed, attributes.name, nil)
run_specinfra(:remove_package, attributes.name, attributes.options)
updated!
end
end
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions spec/integration/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
it { should be_installed }
end

describe package('resolvconf') do
it { should_not be_installed }
end

describe file('/tmp/remote_file') do
it { should be_file }
its(:content) { should match(/Hello Itamae/) }
Expand Down
4 changes: 4 additions & 0 deletions spec/integration/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
version '3.03-17'
end

package 'resolvconf' do
action :remove
end

######

package "ruby"
Expand Down