Sha256: 2f4ca91135ea2a760b411b9e713f726ea8885130e2ba0ddb6b7765201023fdc2
Contents?: true
Size: 1.32 KB
Versions: 1
Compression:
Stored size: 1.32 KB
Contents
command :'ship host' do |c| c.summary = 'Create Docker containers defined in ops/containers/[host_name].yml' c.syntax = 'ops ship host [host_name]' c.description = "Create all docker containers described in #{Ops::CONTAINERS_DIR}/[host_name].yml" c.example "Create a container called 'www' in the host example.com. This is described in '#{Ops::CONTAINERS_DIR}/example.com.yml' like:\n # www:\n # detach: true\n # image: jlebrijo/prun\n # ports:\n # - '2222:22'\n # - '80:80'", 'ops ship host example.com' c.action do |args, options| host = args[0] user = Ops::get_user_for(host) Docker::containers_for(host).each do |container_name, config| ports = config["ports"].map{|port| "-p #{port}"}.join(" ") options = [] config.reject{|k| Docker::SPECIAL_OPTS.include? k}.each do |option, value| options << "--#{option}=#{value}" end say "Container '#{container_name}' loading on #{host}, please wait ....\n" Net::SSH.start(host, user) do |ssh| command = "docker run #{options.join(" ")} --name #{container_name} #{ports} #{config["image"]} #{config["command"]}" say "Docker CMD: #{command}" ssh.exec command end sleep 5 config["post-conditions"].each { |c| system c } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
prun-ops-0.0.4 | lib/prun-ops/commands/ship_host.rb |