lib/kitchen/driver/docker.rb in kitchen-docker-0.1.1.dev vs lib/kitchen/driver/docker.rb in kitchen-docker-0.1.1
- old
+ new
@@ -31,12 +31,19 @@
default_config :image, 'ubuntu'
default_config :platform, 'ubuntu'
default_config :port, '22'
default_config :username, 'kitchen'
default_config :password, 'kitchen'
- default_config :require_chef_omnibus, 'latest'
+ default_config :require_chef_omnibus, true
+ def verify_dependencies
+ run_command('docker > /dev/null', :quiet => true)
+ rescue
+ raise UserError,
+ 'You must first install Docker http://www.docker.io/gettingstarted/'
+ end
+
def create(state)
state[:image_id] = build_image(state) unless state[:image_id]
state[:container_id] = run_container(state) unless state[:container_id]
state[:hostname] = container_address(state) unless state[:hostname]
wait_for_sshd(state[:hostname])
@@ -68,16 +75,18 @@
eos
else
raise ActionFailed,
"Unknown platform '#{config[:platform]}'"
end
+ username = config[:username]
+ password = config[:password]
base = <<-eos
RUN mkdir /var/run/sshd
RUN echo '127.0.0.1 localhost.localdomain localhost' >> /etc/hosts
- RUN useradd -d /home/kitchen -m -s /bin/bash kitchen
- RUN echo kitchen:kitchen | chpasswd
- RUN echo 'kitchen ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
+ RUN useradd -d /home/#{username} -m -s /bin/bash #{username}
+ RUN echo #{username}:#{password} | chpasswd
+ RUN echo '#{username} ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
eos
[from, platform, base].join("\n")
end
def parse_image_id(output)
@@ -119,10 +128,10 @@
end
end
def container_address(state)
container_id = state[:container_id]
- output = run_command("docker inspect #{container_id}", :quiet => true)
+ output = run_command("docker inspect #{container_id}")
parse_container_ip(output)
end
def ensure_fqdn(state)
ssh_args = build_ssh_args(state)