9. BUILDING AN IMAGE (DOCKERFILE)
FROM centos:stable
RUN yum -y upgrade
RUN yum install httpd
COPY httpd.conf /etc/httpd/conf/httpd.conf
EXPOSE 80
ENTRYPOINT ["/usr/sbin/apachectl", "-DFOREGOUND"]
10. BUILDING AN IMAGE (WITH ANSIBLE)
FROM ansible/centos7-ansible:stable
ADD ansible /srv/example/
WORKDIR /srv/example
RUN ansible-playbook site.yml -c local
EXPOSE 80
ENTRYPOINT ["/usr/sbin/apachectl", "-DFOREGROUND"]
12. HUH. SO WHAT MAKES ANSIBLE BETTER?
Power and consistency
Same method to configure images as your hosts
Templates and Conditionals
Portability
Try out new things via Galaxy roles
13. A MORE COMPLEX EXAMPLE!
- hosts: localhost
vars:
apache_group:
Debian: "root"
RedHat: "apache"
apache_ctl:
Debian: "/usr/sbin/apache2ctl"
RedHat: "/usr/sbin/apachectl"
14. A MORE COMPLEX EXAMPLE!
tasks:
- yum: pkg=httpd state=present
when: ansible_os_family == "RedHat"
- apt: update_cache=yes name="apache2" state=present
when: ansible_os_family == "Debian"
- name: Make an apachectl symlink that is the same between distros
file:
state: link
src: "{{apache_ctl[ansible_os_family]}}"
dest: /usr/local/bin/apachectl
15. A MORE COMPLEX EXAMPLE!
- name: Apply httpd configuration from template
template:
src: httpd.conf.j2
dest: /etc/httpd/conf/httpd.conf
group: "{{ apache_group[ansible_os_family] }}"
mode: "0644"
16. GALAXY + DOCKER == TRY BEFORE YOU BUY
FROM ansible/ubuntu14.04-ansible:stable
RUN mkdir /srv/example
WORKDIR /srv/example
ADD site.yml /srv/example/
RUN ansible-galaxy install geerlingguy.memcached
RUN ansible-playbook site.yml -c local
EXPOSE 11211
ENTRYPOINT ["/usr/bin/memcached", "-u", "memcache", "-l", "0.0.0.0", "-c" "1024", "-p",
17. GALAXY + DOCKER == TRY BEFORE YOU BUY
- hosts: localhost
roles:
- role: geerlingguy.memcached
18. IMAGES FOR BUILDING
Ansible layered on a Base OS Image
Building four images
Two images for Ubuntu-14.04
Two images for CentOS-7
An image for Ansible HEAD
An image for the Ansible release on pypi
19. CONTACT INFO & RESOURCES
https://registry.hub.docker.com/u/ansible/centos7-ansible/
https://registry.hub.docker.com/u/ansible/ubuntu14.04-ansible/
http://ansible.github.com/ansible/ansible-docker-base
http://ansible.com
tkuratomi@ansible.com