Module: Rig::Chef
- Defined in:
- lib/rig/chef.rb
Class Method Summary collapse
- .client_delete(name) ⇒ Object
- .client_list ⇒ Object
- .configure ⇒ Object
- .environment_create(name) ⇒ Object
- .environment_destroy(name) ⇒ Object
- .node_delete(name) ⇒ Object
Class Method Details
.client_delete(name) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/rig/chef.rb', line 38 def client_delete(name) configure # TODO: better error handling client = ::Chef::ApiClient.load(name) rescue nil client.destroy if client end |
.client_list ⇒ Object
45 46 47 48 49 |
# File 'lib/rig/chef.rb', line 45 def client_list configure # TODO: better error handling ::Chef::ApiClient.list end |
.configure ⇒ Object
12 13 14 |
# File 'lib/rig/chef.rb', line 12 def configure @chef ||= ::Chef::Config.from_file(File.(Rig.config.chef.knife)) end |
.environment_create(name) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rig/chef.rb', line 16 def environment_create(name) configure env = ::Chef::Environment.new env.name(name) env.description("created by Rig") env.save true rescue => e puts "*** chef exception: #{e.}" false end |
.environment_destroy(name) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/rig/chef.rb', line 28 def environment_destroy(name) configure env = ::Chef::Environment.load(name) rescue nil env.destroy if env true rescue => e puts "*** chef exception: #{e.}" false end |
.node_delete(name) ⇒ Object
51 52 53 54 55 56 |
# File 'lib/rig/chef.rb', line 51 def node_delete(name) configure # TODO: better error handling node = ::Chef::Node.load(name) rescue nil node.destroy if node end |