setup_containers.yml 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. ---
  2. - name: "get output of: docker images"
  3. command: docker images
  4. changed_when: False # don't report as changed
  5. register: docker_images
  6. - name: docker pull busybox ONLY if it's not present
  7. command: "docker pull busybox:latest"
  8. when: "not docker_images.stdout | search('busybox.*latest')"
  9. - name: docker pull containers ONLY if they're not present (needed otherwise systemd will timeout pulling the containers)
  10. command: "docker pull docker-registry.ops.rhcloud.com/{{ item }}:{{ oo_env }}"
  11. with_items:
  12. - oso-v2-proxy
  13. - oso-v2-puppet
  14. - oso-v2-monitoring
  15. when: "not docker_images.stdout | search('docker-registry.ops.rhcloud.com/{{ item }}.*{{ oo_env }}')"
  16. - name: "get output of: docker ps -a"
  17. command: docker ps -a
  18. changed_when: False # don't report as changed
  19. register: docker_ps
  20. - name: run proxy-shared-data-1
  21. command: /usr/bin/docker run --name "proxy-shared-data-1" \
  22. -v /shared/etc/haproxy \
  23. -v /shared/etc/httpd \
  24. -v /shared/etc/openshift \
  25. -v /shared/etc/pki \
  26. -v /shared/var/run/ctr-ipc \
  27. -v /shared/var/lib/haproxy \
  28. -v /shared/usr/local \
  29. "busybox:latest" true
  30. when: "not docker_ps.stdout | search('proxy-shared-data-1')"
  31. - name: Deploy systemd files for containers
  32. template:
  33. src: "systemd/{{ item }}.j2"
  34. dest: "/etc/systemd/system/{{ item }}"
  35. mode: 0640
  36. owner: root
  37. group: root
  38. with_items:
  39. - ctr-proxy-1.service
  40. - ctr-proxy-monitoring-1.service
  41. - ctr-proxy-puppet-1.service
  42. notify: reload systemd
  43. - name: start containers
  44. service:
  45. name: "{{ item }}"
  46. state: started
  47. enabled: yes
  48. with_items:
  49. - ctr-proxy-puppet-1
  50. - ctr-proxy-1
  51. - ctr-proxy-monitoring-1