Last active
June 29, 2017 21:00
-
-
Save mivok/f73992be9247df1d3cb5b195d43c5e5c to your computer and use it in GitHub Desktop.
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 MockDeliverySugar | |
module DSL | |
def automate_chef_server | |
@automate_chef_server ||= MockDeliverySugar::ChefServer.new | |
end | |
def load_delivery_chef_config | |
automate_chef_server.load_server_config | |
end | |
end | |
class ChefServer | |
include MockDeliverySugar::DSL | |
def load_server_config | |
Chef::Log.info("In MockDeliverySugar::ChefServer.load_server_config") | |
# Note: we don't actually load the config here, we're just testing to | |
# see if the stored config has some value in it | |
@stored_config = "Some value: #{rand(1000000)}" | |
Chef::Log.info("Stored config is: #{@stored_config}") | |
end | |
def unload_server_config | |
Chef::Log.info("In MockDeliverySugar::ChefServer.unload_server_config") | |
Chef::Log.info("Stored config is: #{@stored_config}") | |
end | |
end | |
end | |
module TestCookbook | |
module Helpers | |
module_function | |
def unload_delivery_chef_config | |
Chef::Log.info("In unload_delivery_chef_config") | |
automate_chef_server = send(:automate_chef_server) | |
automate_chef_server.unload_server_config | |
end | |
end | |
end | |
Chef::Recipe.send(:include, TestCookbook::Helpers) | |
Chef::Resource.send(:include, TestCookbook::Helpers) | |
Chef::Provider.send(:include, TestCookbook::Helpers) | |
Chef::Recipe.send(:include, MockDeliverySugar::DSL) | |
Chef::Resource.send(:include, MockDeliverySugar::DSL) | |
Chef::Provider.send(:include, MockDeliverySugar::DSL) |
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
name 'test' |
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
test_resource "foo" |
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
action :create do | |
load_delivery_chef_config | |
log 'This is where we would use the config, do provisioning and stuff' | |
ruby_block 'force_unload_server_config' do | |
block { unload_delivery_chef_config } | |
end | |
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
#!/bin/bash | |
chef-client -z -r test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment