Created
October 12, 2015 21:46
-
-
Save chasebolt/17cf00daf4892d13b80b 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
Chef::Resource::DockerService.class_eval do | |
property :dependencies_updated, [true, false] | |
def depends_on(resource) | |
subscribes :dependencies_updated, resource, :immediately | |
subscribes :run, resource | |
end | |
action :dependencies_updated do | |
new_resource.dependencies_updated true | |
end | |
module NewCreateAction | |
def action_create | |
super | |
new_resource.reset_property(:dependencies_updated) | |
end | |
end | |
# This puts NewCreateAction::action_create as the first thing called, and super() == DockerContainer::action_create | |
prepend NewCreateAction | |
end | |
# And then change subscribes to depends_on in your recipe: | |
directory '/tmp' | |
file '/tmp/some_config.ini' do | |
content 'blah' | |
action :create | |
end | |
file '/tmp/another_config.ini' do | |
content 'blah' | |
action :create | |
end | |
docker_image 'alpine' do | |
tag 'latest' | |
action :pull_if_missing | |
end | |
docker_container 'alpine' do | |
command 'sleep 3000' | |
depends_on 'docker_image[some_image]' | |
depends_on 'template[/tmp/some_config.ini]' | |
depends_on 'template[/tmp/another_config.ini]' | |
action :run | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment