Class: Qurd::Action::Chef
- Inherits:
-
Qurd::Action
- Object
- Qurd::Action
- Qurd::Action::Chef
- Defined in:
- lib/qurd/action/chef.rb
Overview
Clean up chef client and node data
Instance Attribute Summary
Attributes inherited from Qurd::Action
Class Method Summary collapse
-
.configure(_action) ⇒ Object
Add a setter and getter for Message
chef_node
chef_client
and configure Chef using Configurationchef_configuration
or the default/etc/chef/knife.rb
. -
.configure_chef ⇒ Object
Parse Chef’s configuration file, as defined in
qurd.yml
, set Chef’slog_level
, and Chef’slog_location
.
Instance Method Summary collapse
-
#run_before ⇒ Object
Find the node, using the
instance_id
of themessage
. -
#terminate ⇒ Object
Delete the node, if the message did not fail other processing steps and dry_run is not true.
-
#test ⇒ Object
Respond to test actions.
Methods inherited from Qurd::Action
#aws_credentials, #initialize, #inspect, #launch, #region, #run_after
Methods included from Mixins::Configuration
#qurd_config, #qurd_configuration, #qurd_logger, #qurd_logger!
Methods included from Mixins::AwsClients
Constructor Details
This class inherits a constructor from Qurd::Action
Class Method Details
.configure(_action) ⇒ Object
Add a setter and getter for Message chef_node
chef_client
and configure Chef using Configuration chef_configuration
or the default /etc/chef/knife.rb
. If Configuration log_file
is defined, Chef will log to it.
17 18 19 20 21 22 23 |
# File 'lib/qurd/action/chef.rb', line 17 def self.configure(_action) return if @configure_done configure_chef Qurd::Message.add_accessor(:chef_node) Qurd::Message.add_accessor(:chef_client) @configure_done = true end |
.configure_chef ⇒ Object
Parse Chef’s configuration file, as defined in qurd.yml
, set Chef’s log_level
, and Chef’s log_location
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/qurd/action/chef.rb', line 27 def self.configure_chef config = File.(qurd_configuration.chef_configuration || '/etc/chef/knife.rb') qurd_logger.debug("Configuring Chef for using #{config}") ::Chef::Config.from_file(config) ::Chef::Config[:log_level] = qurd_configuration.log_level if qurd_configuration.log_file_io qurd_logger.debug('Setting chef log file to ' \ "'#{qurd_configuration.log_file_io.path}'") ::Chef::Config[:log_location] = qurd_configuration.log_file_io end end |
Instance Method Details
#run_before ⇒ Object
Find the node, using the instance_id
of the message
41 42 43 44 |
# File 'lib/qurd/action/chef.rb', line 41 def run_before find_chef_node find_chef_client end |
#terminate ⇒ Object
Delete the node, if the message did not fail other processing steps and dry_run is not true
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/qurd/action/chef.rb', line 49 def terminate if .failed? qurd_logger.warn('Not deleting, message failed to process') elsif qurd_configuration.dry_run check_dry_run else qurd_logger.debug('Deleting') .chef_node.destroy unless .chef_node.nil? .chef_client.destroy unless .chef_client.nil? end end |
#test ⇒ Object
Respond to test actions
62 63 64 |
# File 'lib/qurd/action/chef.rb', line 62 def test qurd_logger.info('Test') end |