template “/path/to/file/on/our/node.cmd” do source “node.erb” end
<%= node['sql_server']['product_key'] %>
, def mailing puts "\n Sending your email..." r = chef_gem "mail" do action :install end Gem.clear_paths require 'mail' options = { :address => new_resource.server, :port => new_resource.port, :mailto => new_resource.mailto, :user_name => new_resource.user_name, :password => new_resource.password, :authentication => 'plain', :enable_starttls_auto => true } Mail.defaults do delivery_method :smtp, options end mail = Mail.deliver do from options[:user_name] to options[:mailto] subject 'Hello' body new_resource.msg end end
actions :create default_action :create attribute :app_name, :kind_of => String attribute :user_name, :kind_of => String, :default => "" attribute :password, :kind_of => String, :default => "" attribute :server, :kind_of => String, :default => "" attribute :port, :kind_of => Integer, :default => 465 attribute :mailto, :kind_of => [String, NilClass], :default => "" attribute :from, :kind_of => [String, NilClass], :default => "" attribute :msg, :kind_of => String, :default => "Hi there" def initialize(*args) super @ action = :create End
knife node list
. As a result, should get the names of the active nodes.knife cookbook upload name-of-cookbook
. As a result, a message about successful loading and the presence of our cookbook in the list received by the knife cookbook list
command.knife node edit name-of-node
and make text changes to the run-list section, adding the line “recipe [name-of-recipe]” there . And what if there are ten such recipes? Not very comfortable. name "mailer" description "Role for host that will notify us on changes" run_list "recipe[name-of-recipe]"
knife role from file name-of-role-file
. After loading - the role can be assigned to the run-list of the node, which we will do.Source: https://habr.com/ru/post/209368/
All Articles