Skip to content

Instantly share code, notes, and snippets.

@jkeiser
Created March 29, 2015 17:53
Show Gist options
  • Select an option

  • Save jkeiser/60a158fc13adfb155790 to your computer and use it in GitHub Desktop.

Select an option

Save jkeiser/60a158fc13adfb155790 to your computer and use it in GitHub Desktop.
require 'chef/provisioning/docker_driver'
# Create the hosts
machine_batch 'docker hosts' do
machine "dockerhost1" do
recipe "docker"
attribute %w(docker host), 'tcp://localhost:5555'
end
machine "dockerhost2" do
recipe "docker"
attribute %w(docker host), 'tcp://localhost:5555'
end
end
at_converge_time "create docker containers" do
machine_batch do
with_docker_host 'dockerhost1' do |chef_server_url|
with_machine_options(
convergence_options: { extra_config: "chef_server_url #{chef_server_url.inspect}" },
image: 'ubuntu'
)
machine 'web1' do
recipe 'mywebapp'
end
machine 'web2' do
recipe 'mywebapp'
end
end
with_docker_host 'dockerhost2' do |chef_server_url|
with_machine_options convergence_options: { extra_config: "chef_server_url #{chef_server_url.inspect}" }
machine 'web3' do
recipe 'mywebapp'
end
machine 'web4' do
recipe 'mywebapp'
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment