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
| module MCollective | |
| module Agent | |
| # An agent that uses Opscode to manage resources | |
| # Original credit goes to R.I. Pienaar | |
| class ChefExistingResource < RPC::Agent | |
| metadata :name => "SimpleRPC Existing Chef Resource Agent", | |
| :description => "Generic resource management", | |
| :author => "Nicolas Szalay <nico@rottenbytes.info>", | |
| :license => "BSD", | |
| :version => "1.0", |
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
| ruby_block "foo" do | |
| block do | |
| node[:some][:value] = 'is awesome' | |
| end | |
| action :nothing | |
| run_action :create | |
| end |
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
| node.save if node.run_list.roles.include?('mysql_master') | |
| sleep 5 # just in case the queue takes a while | |
| search(:node, 'role:mysql_master') do |foo| | |
| ... | |
| end |
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
| { | |
| "id": "0123456789abcdef", | |
| "name": "myname", | |
| "provider": "puppet", | |
| "os": { | |
| "name": "linux", | |
| "version": "2.6.35-22-generic", | |
| "vendor": "ubuntu", | |
| "vendor_version": "10.10" | |
| }, |
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
| case node[:hostname] | |
| when "foo" | |
| node[:cron][:backup][:hour] = 10 | |
| when "bar" | |
| node[:cron][:backup][:hour] = 11 | |
| end |
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
| require 'chef' | |
| require 'chef/node' | |
| class Opscode | |
| class Backup | |
| attr_accessor :backup_dir | |
| def initialize(backup_dir, config_file) | |
| @backup_dir = backup_dir | |
| Chef::Config.from_file(config_file) |
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
| def action_create | |
| if @current_resource.to != ::File.expand_path(@new_resource.to, @new_resource.target_file) | |
| noop "Creating a #{@new_resource.link_type} link from #{@new_resource.to} -> #{@new_resource.target_file} for #{@new_resource}" do | |
| if @new_resource.link_type == :symbolic | |
| unless (::File.symlink?(@new_resource.target_file) && ::File.readlink(@new_resource.target_file) == @new_resource.to) | |
| if ::File.symlink?(@new_resource.target_file) || ::File.exist?(@new_resource.target_file) | |
| ::File.unlink(@new_resource.target_file) | |
| end | |
| ::File.symlink(@new_resource.to,@new_resource.target_file) | |
| end |
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
| node['filesystem']['/dev/disk0s2']['percent_used'] =~ /^(\d+)%$/ | |
| percent_used = $1.to_i | |
| if percent_used > 90 | |
| include_recipe "raid::grow" | |
| end |
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
| #!/usr/bin/env ruby | |
| require 'rubygems' | |
| require 'chef' | |
| require 'chef/client' | |
| require 'chef/run_context' | |
| Chef::Config[:solo] = true | |
| Chef::Config[:log_level] = :info | |
| Chef::Log.level(:info) |
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
| #!/usr/bin/env ruby | |
| require 'rubygems' | |
| require 'chef' | |
| require 'chef/client' | |
| require 'chef/run_context' | |
| Chef::Config[:solo] = true | |
| Chef::Config[:log_level] = :info | |
| Chef::Log.level(:info) |