forked from evolvingweb/puppet-apt
-
Notifications
You must be signed in to change notification settings - Fork 466
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #319 from cloudbuy/master
add facts showing available updates
- Loading branch information
Showing
7 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Facter.add("apt_package_updates") do | ||
confine :osfamily => 'Debian' | ||
setcode do | ||
if File.executable?("/usr/lib/update-notifier/apt-check") | ||
packages = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check -p 2>&1') | ||
packages = packages.split("\n") | ||
if Facter.version < '2.0.0' | ||
packages = packages.join(',') | ||
end | ||
packages | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Facter.add("apt_security_updates") do | ||
confine :osfamily => 'Debian' | ||
setcode do | ||
if File.executable?("/usr/lib/update-notifier/apt-check") | ||
updates = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check 2>&1') | ||
Integer(updates.strip.split(';')[1]) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Facter.add("apt_updates") do | ||
confine :osfamily => 'Debian' | ||
setcode do | ||
if File.executable?("/usr/lib/update-notifier/apt-check") | ||
updates = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check 2>&1') | ||
Integer(updates.strip.split(';')[0]) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require 'spec_helper' | ||
|
||
describe 'apt_package_updates fact' do | ||
subject { Facter.fact(:apt_package_updates).value } | ||
after(:each) { Facter.clear } | ||
|
||
describe 'on Debian based distro missing update-notifier-common' do | ||
before { | ||
Facter.fact(:osfamily).stubs(:value).returns 'Debian' | ||
File.stubs(:executable?).returns false | ||
} | ||
it { should == nil } | ||
end | ||
|
||
describe 'on Debian based distro' do | ||
before { | ||
Facter.fact(:osfamily).stubs(:value).returns 'Debian' | ||
File.stubs(:executable?).returns true | ||
Facter::Util::Resolution.stubs(:exec).returns "puppet-common\nlinux-generic\nlinux-image-generic" | ||
} | ||
it { | ||
if Facter.version < '2.0.0' | ||
should == 'puppet-common,linux-generic,linux-image-generic' | ||
else | ||
should == ['puppet-common', 'linux-generic', 'linux-image-generic'] | ||
end | ||
} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require 'spec_helper' | ||
|
||
describe 'apt_security_updates fact' do | ||
subject { Facter.fact(:apt_security_updates).value } | ||
after(:each) { Facter.clear } | ||
|
||
describe 'on Debian based distro missing update-notifier-common' do | ||
before { | ||
Facter.fact(:osfamily).stubs(:value).returns 'Debian' | ||
File.stubs(:executable?).returns false | ||
} | ||
it { should == nil } | ||
end | ||
|
||
describe 'on Debian based distro' do | ||
before { | ||
Facter.fact(:osfamily).stubs(:value).returns 'Debian' | ||
File.stubs(:executable?).returns true | ||
Facter::Util::Resolution.stubs(:exec).returns '14;7' | ||
} | ||
it { should == 7 } | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require 'spec_helper' | ||
|
||
describe 'apt_updates fact' do | ||
subject { Facter.fact(:apt_updates).value } | ||
after(:each) { Facter.clear } | ||
|
||
describe 'on Debian based distro missing update-notifier-common' do | ||
before { | ||
Facter.fact(:osfamily).stubs(:value).returns 'Debian' | ||
File.stubs(:executable?).returns false | ||
} | ||
it { should == nil } | ||
end | ||
|
||
describe 'on Debian based distro' do | ||
before { | ||
Facter.fact(:osfamily).stubs(:value).returns 'Debian' | ||
File.stubs(:executable?).returns true | ||
Facter::Util::Resolution.stubs(:exec).returns '14;7' | ||
} | ||
it { should == 14 } | ||
end | ||
|
||
end |