Last active
December 31, 2015 17:48
-
-
Save zts/8022194 to your computer and use it in GitHub Desktop.
Use Chef to check whether a package has been installed
This file contains hidden or 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
[root@ci cache]# chef-shell | |
loading configuration: none (standalone session) | |
Session type: standalone | |
Loading.done. | |
This is the chef-shell. | |
Chef Version: 11.8.2 | |
http://www.opscode.com/chef | |
http://wiki.opscode.com/display/chef/Home | |
run `help' for help, `exit' or ^D to quit. | |
Ohai2u [email protected]! | |
chef > recipe_mode | |
chef:recipe > echo off | |
chef:recipe > pkg = Chef::Resource::Package.new("chef") | |
chef:recipe > provider = Chef::Platform.find_provider_for_node(node, pkg).new(pkg, run_context) | |
chef:recipe > puts provider.load_current_resource.version | |
11.8.2-1.el6 | |
chef:recipe > | |
chef:recipe > chef_svc = Chef::Resource::Service.new("chef-client") | |
chef:recipe > chef_svc_provider = Chef::Platform.find_provider_for_node(node, chef_svc).new(chef_svc, run_context) | |
chef:recipe > puts chef_svc_provider.load_current_resource.enabled | |
false | |
chef:recipe > | |
chef:recipe > cron_svc = Chef::Resource::Service.new("crond") | |
chef:recipe > cron_svc_provider = Chef::Platform.find_provider_for_node(node, cron_svc).new(cron_svc, run_context) | |
chef:recipe > puts cron_svc_provider.load_current_resource.enabled | |
true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment