Open yazgoo opened 9 years ago
Here is a bypass which uses docker inspect to get the ipaddress if it is not set:
class Chef::Resource::Machine
def running_on? kind
kind == ENV['CHEF_DRIVER'].sub(/::.*$/, "").to_sym
end
def get_docker_ip_address name
JSON.parse(`docker inspect #{name}`).first["NetworkSettings"]["IPAddress"]
end
alias :old_search :search
def search what, query
result = old_search what, query
if what == :node and running_on? :docker
result.map! do |node|
node.default["ipaddress"] = get_docker_ip_address(node.name) if node["ipaddress"] == nil
node
end
end
return result
end
end
Hm, there are no much changes between 0.7 and master.
I personally have ipaddress
among node attributes when running CPD. Though, I use forked version of my own without changes introduced by 07753c4520d3364124dbdca434cd102e471b8bb4 .
Here are two scripts. One creates a machine:
The other searches for it:
When I run these scripts with bundle and this Gemfile:
The second script works fine.
When I try and run against the master git HEAD version :
I get the following error: