Skip to content

Instantly share code, notes, and snippets.

@bhcopeland
Created July 23, 2015 13:45
Show Gist options
  • Save bhcopeland/e10e1a6b435ac9b20263 to your computer and use it in GitHub Desktop.
Save bhcopeland/e10e1a6b435ac9b20263 to your computer and use it in GitHub Desktop.
Docker file to deploy ansible playbook
# Builds ubuntu latest image from docker hub
# Install and setups ansible
# Run from ansible dir: "docker build -t ansible_deploy ."
# You will need to update the playbook you deploy in this file.
FROM ubuntu
MAINTAINER Ben Copeland <ben.copeland@linaro.org>
RUN apt-get install -y software-properties-common
RUN apt-add-repository ppa:ansible/ansible
# Update apt cache
RUN apt-get -y update
RUN apt-get install -y ansible
# add playbooks/roles to the image.
ADD roles/ /etc/ansible/roles
ADD host_vars/ /etc/ansible/host_vars
ADD group_vars/ /etc/ansible/group_vars
ADD *.yml /etc/ansible/
ADD hosts-deploy /etc/ansible/hosts
WORKDIR /etc/ansible
# Run ansible using the site.yml playbook
#RUN ansible --version
# Does a syntax check. Will fail the build if it does not pass.
RUN ansible-playbook --syntax-check --list-tasks padpaste-servers.yml -c local
# Go wild, run the playbook.
RUN ansible-playbook padpaste-servers.yml -c local
# Open up some ports to access the build
EXPOSE 80 9001 22
# Delete cache (this saves a lot of disk space)
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
WORKDIR /srv
ENTRYPOINT ["/bin/bash"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment