Wednesday, August 26, 2015

Docker and Beaker (Puppet Testing)

Sooo... we've historically been very bad about testing our puppet stuff.
We don't really do module level testing.
We manually do end-to-end testing.  I guess its been 'good enough' so far...although tedious.

Anyways, I thought we should chart some new territory and attempt to use Beaker to some degree.

Beaker Wiki: link

Anyways...turns out they support Docker.
I thought, yay, finally an excuse to play with Docker a bit.

Turns out it was a pain in the ass to setup though.

  1. Get the Ubuntu 14 vagrant box:
    https://atlas.hashicorp.com/ubuntu/boxes/trusty64
     
  2. SSH into that box
     
  3. Install Beaker on that box
    https://github.com/puppetlabs/beaker/wiki/Beaker-Installation#installing-beaker
     
  4. Install Docker on that box
    https://docs.docker.com/installation/ubuntulinux/
     
  5. Create a 'beaker hosts config file' on that box
    example file:  "beaker_hosts.cfg"
    HOSTS:
      ubuntu-12-10:
        platform: ubuntu-12.10-x64
        image: modified_ubuntu
        hypervisor: docker
    CONFIG:
      type: foss
  6. Do a simple 'docker run' to get docker to download the Ubuntu Container Image:
    sudo docker run ubuntu:12.10 /bin/echo 'shit'
     
  7. Modify the Ubuntu Container Image by installing 'ssh' onto it:
    sudo docker run ubuntu:12.10 apt-get install -y ssh
     
  8. Find the 'container id' after the previous step finishes.
    sudo docker ps -l
     
  9. Commit the changes to the container
    sudo docker commit someFriggingUglyContainerId modified_ubuntu
     
  10. Confirm that 'ssh' is installed:
    a) open an interactive session with the new container thingy:
    sudo docker run -i -t modified_ubuntu /bin/bash
    b) start the 'ssh' service on the new container thingy:
    service ssh start
    c) quit the new container thingy:
    exit
     
  11. Run beaker on the VM !!
    sudo beaker --log-level debug --hosts beaker_hosts.cfg
  12. Happy Dance.

The following images MAY have differently named files/settings... so just use your brain:







No comments:

Post a Comment