This file contains 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
class Chef | |
class Provider | |
class CloudMagic < Chef::Provider | |
# We MUST override this method in our custom provider | |
def load_current_resource | |
# Here we keep the existing version of the resource | |
# if none exists we create a new one from the resource we defined earlier | |
@current_resource ||= Chef::Resource::CloudMagic.new(new_resource.name) | |
This file contains 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
action :enable, :remove | |
default_action :enable | |
attribute :magic, kind_of => [TrueClass, FalseClass], :default => true | |
attribute :cloud, kind_of => String, :name_attribute => true |
This file contains 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/resource' | |
class Chef | |
class Resource | |
class CloudMagic < Chef::Resource | |
# Some Magic Happens | |
end | |
end |
This file contains 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
cloud_magic "My Cloud Magic" do | |
action :create | |
cloud "My Cloud Magic" | |
magic true | |
end |
This file contains 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
attributes/ | |
default.rb | |
libraries/ | |
helpers.rb | |
provider_default.rb | |
providers/ | |
resources/ | |
default.rb | |
recipes/ | |
default.rb |
This file contains 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
actions :configure, :enable, :start | |
# Installation attributes | |
attribute :server_name, :kind_of => String, :name_attribute => true | |
# Big hack below to work around this line not working | |
# attribute :version, :kind_of => String, :default => node['redisio']['version'] | |
def version(arg=nil) | |
default_set_in_attributes = run_context.node['redisio']['version'] |
This file contains 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 load_current_resource | |
# Because these attributes are loaded lazily | |
# we have to call each one explicitly | |
new_resource.pidfile new_resource.pidfile || "/var/run/redis/#{new_resource.name}.pid" | |
new_resource.logfile new_resource.logfile || "/var/log/redis/#{new_resource.name}.log" | |
new_resource.dbfilename new_resource.dbfilename || "#{new_resource.name}.rdb" | |
new_resource.user new_resource.user || node.redis.user | |
new_resource.group new_resource.group || node.redis.group | |
new_resource.slaveof_ip new_resource.slaveof_ip |
This file contains 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
# Tried | |
File.readlines(config_file).each{ |line| puts line unless /^#+.*/.match(line) } | |
File.readlines(config_file).each{ |line| puts line unless line.match(/^#+.*/) } | |
# Variations on regex that failed | |
# /^.*\#+.*/ | |
# /\#/ | |
# /#/ | |
# /\#+/ | |
# and many more |
This file contains 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
gem install bundler | |
echo "source :rubygems" >> Gemfile | |
echo "gem 'berkshelf'" >> Gemfile | |
echo "gem 'vagrant'" >> Gemfile | |
bundle install | |
bundle exec berks install |
This file contains 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
if node["platform"] == "windows" | |
existence_check = :exists? | |
# Where will also return files that have extensions matching PATHEXT (e.g. | |
# *.bat). We don't want the batch file wrapper, but the actual script. | |
which = 'set PATHEXT=.exe & where' | |
Chef::Log.debug "Using exists? and 'where', since we're on Windows" | |
else | |
existence_check = :executable? | |
which = 'which' | |
Chef::Log.debug "Using executable? and 'which' since we're on Linux" |