forked from redhat-openstack/openstack-puppet-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #506 from binford2k/feature/service_provider_fact
Add a service_provider fact
- Loading branch information
Showing
2 changed files
with
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Fact: service_provider | ||
# | ||
# Purpose: Returns the default provider Puppet will choose to manage services | ||
# on this system | ||
# | ||
# Resolution: Instantiates a dummy service resource and return the provider | ||
# | ||
# Caveats: | ||
# | ||
Facter.add(:service_provider) do | ||
setcode do | ||
Puppet::Type.type(:service).newservice(:name => 'dummy')[:provider].to_s | ||
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,37 @@ | ||
#! /usr/bin/env ruby -S rspec | ||
require 'spec_helper' | ||
require 'puppet/type' | ||
require 'puppet/type/service' | ||
|
||
describe 'service_provider', :type => :fact do | ||
before { Facter.clear } | ||
after { Facter.clear } | ||
|
||
context "macosx" do | ||
it "should return launchd" do | ||
provider = Puppet::Type.type(:service).provider(:launchd) | ||
Puppet::Type.type(:service).stubs(:defaultprovider).returns provider | ||
|
||
expect(Facter.fact(:service_provider).value).to eq('launchd') | ||
end | ||
end | ||
|
||
context "systemd" do | ||
it "should return systemd" do | ||
provider = Puppet::Type.type(:service).provider(:systemd) | ||
Puppet::Type.type(:service).stubs(:defaultprovider).returns provider | ||
|
||
expect(Facter.fact(:service_provider).value).to eq('systemd') | ||
end | ||
end | ||
|
||
context "redhat" do | ||
it "should return redhat" do | ||
provider = Puppet::Type.type(:service).provider(:redhat) | ||
Puppet::Type.type(:service).stubs(:defaultprovider).returns provider | ||
|
||
expect(Facter.fact(:service_provider).value).to eq('redhat') | ||
end | ||
end | ||
|
||
end |