From 023f92f9e3eec7de6c1286549000be79189a4fde Mon Sep 17 00:00:00 2001 From: Thomas Wiest Date: Mon, 15 Dec 2014 16:00:47 -0500 Subject: changed atomic proxy to use pre-built container images --- roles/atomic_proxy/files/ctr-proxy-1.service | 37 -------------- .../files/ctr-proxy-monitoring-1.service | 37 -------------- .../atomic_proxy/files/ctr-proxy-puppet-1.service | 37 -------------- roles/atomic_proxy/handlers/main.yml | 3 +- roles/atomic_proxy/tasks/main.yml | 20 +------- roles/atomic_proxy/tasks/setup_containers.yml | 57 ++++++++++++++++++++++ .../templates/systemd/ctr-proxy-1.service.j2 | 32 ++++++++++++ .../systemd/ctr-proxy-monitoring-1.service.j2 | 36 ++++++++++++++ .../systemd/ctr-proxy-puppet-1.service.j2 | 33 +++++++++++++ 9 files changed, 161 insertions(+), 131 deletions(-) delete mode 100644 roles/atomic_proxy/files/ctr-proxy-1.service delete mode 100644 roles/atomic_proxy/files/ctr-proxy-monitoring-1.service delete mode 100644 roles/atomic_proxy/files/ctr-proxy-puppet-1.service create mode 100644 roles/atomic_proxy/tasks/setup_containers.yml create mode 100644 roles/atomic_proxy/templates/systemd/ctr-proxy-1.service.j2 create mode 100644 roles/atomic_proxy/templates/systemd/ctr-proxy-monitoring-1.service.j2 create mode 100644 roles/atomic_proxy/templates/systemd/ctr-proxy-puppet-1.service.j2 (limited to 'roles/atomic_proxy') diff --git a/roles/atomic_proxy/files/ctr-proxy-1.service b/roles/atomic_proxy/files/ctr-proxy-1.service deleted file mode 100644 index c532eb8e8..000000000 --- a/roles/atomic_proxy/files/ctr-proxy-1.service +++ /dev/null @@ -1,37 +0,0 @@ - - -[Unit] -Description=Container proxy-1 - - -[Service] -Type=simple -TimeoutStartSec=5m -Slice=container-small.slice - -ExecStartPre=-/usr/bin/docker rm "proxy-1" - -ExecStart=/usr/bin/docker run --rm --name "proxy-1" \ - --volumes-from proxy-shared-data-1 \ - -a stdout -a stderr -p 80:80 -p 443:443 -p 4999:4999 \ - "proxy:latest" - -ExecStartPost=-/usr/bin/gear init --post "proxy-1" "proxy:latest" -ExecReload=-/usr/bin/docker stop "proxy-1" -ExecReload=-/usr/bin/docker rm "proxy-1" -ExecStop=-/usr/bin/docker stop "proxy-1" - -[Install] -WantedBy=container.target - -# Container information -X-ContainerId=proxy-1 -X-ContainerImage=proxy:latest -X-ContainerUserId= -X-ContainerRequestId=LwiWtYWaAvSavH6Ze53QJg -X-ContainerType=simple -X-PortMapping=80:80 -X-PortMapping=443:443 -X-PortMapping=4999:4999 - - diff --git a/roles/atomic_proxy/files/ctr-proxy-monitoring-1.service b/roles/atomic_proxy/files/ctr-proxy-monitoring-1.service deleted file mode 100644 index 7a91ea02c..000000000 --- a/roles/atomic_proxy/files/ctr-proxy-monitoring-1.service +++ /dev/null @@ -1,37 +0,0 @@ - - -[Unit] -Description=Container proxy-monitoring-1 - - -[Service] -Type=simple -TimeoutStartSec=5m -Slice=container-small.slice - -ExecStartPre=-/usr/bin/docker rm "proxy-monitoring-1" - -ExecStart=/usr/bin/docker run --rm --name "proxy-monitoring-1" \ - --volumes-from proxy-shared-data-1 \ - -a stdout -a stderr \ - "monitoring:latest" - -ExecStartPost=-/usr/bin/gear init --post "proxy-monitoring-1" "monitoring:latest" -ExecReload=-/usr/bin/docker stop "proxy-monitoring-1" -ExecReload=-/usr/bin/docker rm "proxy-monitoring-1" -ExecStop=-/usr/bin/docker stop "proxy-monitoring-1" - -[Install] -WantedBy=container.target - -# Container information -X-ContainerId=proxy-monitoring-1 -X-ContainerImage=monitoring:latest -X-ContainerUserId= -X-ContainerRequestId=LwiWtYWaAvSavH6Ze53QJg -X-ContainerType=simple -X-PortMapping=80:80 -X-PortMapping=443:443 -X-PortMapping=4999:4999 - - diff --git a/roles/atomic_proxy/files/ctr-proxy-puppet-1.service b/roles/atomic_proxy/files/ctr-proxy-puppet-1.service deleted file mode 100644 index c1f4d9b13..000000000 --- a/roles/atomic_proxy/files/ctr-proxy-puppet-1.service +++ /dev/null @@ -1,37 +0,0 @@ - - -[Unit] -Description=Container proxy-puppet-1 - - -[Service] -Type=simple -TimeoutStartSec=5m -Slice=container-small.slice - - -ExecStartPre=-/usr/bin/docker rm "proxy-puppet-1" - -ExecStart=/usr/bin/docker run --rm --name "proxy-puppet-1" \ - --volumes-from proxy-shared-data-1 \ - -v /var/lib/docker/volumes/proxy_puppet/var/lib/puppet/ssl:/var/lib/puppet/ssl \ - -v /var/lib/docker/volumes/proxy_puppet/etc/puppet:/etc/puppet \ - -a stdout -a stderr \ - "puppet:latest" -# Set links (requires container have a name) -ExecStartPost=-/usr/bin/gear init --post "proxy-puppet-1" "puppet:latest" -ExecReload=-/usr/bin/docker stop "proxy-puppet-1" -ExecReload=-/usr/bin/docker rm "proxy-puppet-1" -ExecStop=-/usr/bin/docker stop "proxy-puppet-1" - -[Install] -WantedBy=container.target - -# Container information -X-ContainerId=proxy-puppet-1 -X-ContainerImage=puppet:latest -X-ContainerUserId= -X-ContainerRequestId=Ky0lhw0onwoSDJR4GK6t3g -X-ContainerType=simple - - diff --git a/roles/atomic_proxy/handlers/main.yml b/roles/atomic_proxy/handlers/main.yml index 8de31258f..8eedec17a 100644 --- a/roles/atomic_proxy/handlers/main.yml +++ b/roles/atomic_proxy/handlers/main.yml @@ -1,2 +1,3 @@ --- -# handlers file for atomic_proxy +- name: reload systemd + command: systemctl daemon-reload diff --git a/roles/atomic_proxy/tasks/main.yml b/roles/atomic_proxy/tasks/main.yml index d5a5a0a47..073a1c61e 100644 --- a/roles/atomic_proxy/tasks/main.yml +++ b/roles/atomic_proxy/tasks/main.yml @@ -1,21 +1,3 @@ --- -- name: upload sbin scripts - copy: > - src={{ item }} - dest=/usr/local/sbin/{{ item }} - mode=0750 - with_items: - - setup-proxy-containers.sh - -- name: upload /usr/local/etc files - copy: > - src={{ item }} - dest=/usr/local/etc/{{ item }} - mode=0640 - with_items: - - proxy_containers_deploy_descriptor.json - - ctr-proxy-1.service - - ctr-proxy-puppet-1.service - - ctr-proxy-monitoring-1.service - - include: setup_puppet.yml +- include: setup_containers.yml diff --git a/roles/atomic_proxy/tasks/setup_containers.yml b/roles/atomic_proxy/tasks/setup_containers.yml new file mode 100644 index 000000000..63c385afe --- /dev/null +++ b/roles/atomic_proxy/tasks/setup_containers.yml @@ -0,0 +1,57 @@ +--- +- name: get output of: docker images + command: docker images + changed_when: False # don't report as changed + register: docker_images + +- name: docker pull busybox ONLY if it's not present + command: "docker pull busybox:latest" + when: "not docker_images.stdout | search('busybox.*latest')" + +- name: docker pull containers ONLY if they're not present (needed otherwise systemd will timeout pulling the containers) + command: "docker pull docker-registry.ops.rhcloud.com/{{ item }}:{{ oo_env }}" + with_items: + - oso-v2-proxy + - oso-v2-puppet + - oso-v2-monitoring + when: "not docker_images.stdout | search('docker-registry.ops.rhcloud.com/{{ item }}.*{{ oo_env }}')" + +- name: get output of: docker ps -a + command: docker ps -a + changed_when: False # don't report as changed + register: docker_ps + +- name: run proxy-shared-data-1 + command: /usr/bin/docker run --name "proxy-shared-data-1" \ + -v /shared/etc/haproxy \ + -v /shared/etc/httpd \ + -v /shared/etc/openshift \ + -v /shared/etc/pki \ + -v /shared/var/run/ctr-ipc \ + -v /shared/var/lib/haproxy \ + -v /shared/usr/local \ + "busybox:latest" true + when: "not docker_ps.stdout | search('proxy-shared-data-1')" + +- name: Deploy systemd files for containers + template: + src: "systemd/{{ item }}.j2" + dest: "/etc/systemd/system/{{ item }}" + mode: 0640 + owner: root + group: root + with_items: + - ctr-proxy-1.service + - ctr-proxy-monitoring-1.service + - ctr-proxy-puppet-1.service + notify: reload systemd + +- name: start containers + service: + name: "{{ item }}" + state: started + enabled: yes + with_items: + - ctr-proxy-puppet-1 + - ctr-proxy-1 + - ctr-proxy-monitoring-1 diff --git a/roles/atomic_proxy/templates/systemd/ctr-proxy-1.service.j2 b/roles/atomic_proxy/templates/systemd/ctr-proxy-1.service.j2 new file mode 100644 index 000000000..988a9f544 --- /dev/null +++ b/roles/atomic_proxy/templates/systemd/ctr-proxy-1.service.j2 @@ -0,0 +1,32 @@ +[Unit] +Description=Container proxy-1 + + +[Service] +Type=simple +TimeoutStartSec=5m +Slice=container-small.slice + +ExecStartPre=-/usr/bin/docker rm "proxy-1" + +ExecStart=/usr/bin/docker run --rm --name "proxy-1" \ + --volumes-from proxy-shared-data-1 \ + -a stdout -a stderr -p 80:80 -p 443:443 -p 4999:4999 \ + "docker-registry.ops.rhcloud.com/oso-v2-proxy:{{ oo_env }}" + +ExecReload=-/usr/bin/docker stop "proxy-1" +ExecReload=-/usr/bin/docker rm "proxy-1" +ExecStop=-/usr/bin/docker stop "proxy-1" + +[Install] +WantedBy=container.target + +# Container information +X-ContainerId=proxy-1 +X-ContainerImage=docker-registry.ops.rhcloud.com/oso-v2-proxy:{{ oo_env }} +X-ContainerUserId= +X-ContainerRequestId=LwiWtYWaAvSavH6Ze53QJg +X-ContainerType=simple +X-PortMapping=80:80 +X-PortMapping=443:443 +X-PortMapping=4999:4999 diff --git a/roles/atomic_proxy/templates/systemd/ctr-proxy-monitoring-1.service.j2 b/roles/atomic_proxy/templates/systemd/ctr-proxy-monitoring-1.service.j2 new file mode 100644 index 000000000..975b0061b --- /dev/null +++ b/roles/atomic_proxy/templates/systemd/ctr-proxy-monitoring-1.service.j2 @@ -0,0 +1,36 @@ +[Unit] +Description=Container proxy-monitoring-1 + + +[Service] +Type=simple +TimeoutStartSec=5m +Slice=container-small.slice + +ExecStartPre=-/usr/bin/docker rm "proxy-monitoring-1" + +ExecStart=/usr/bin/docker run --rm --name "proxy-monitoring-1" \ + --volumes-from proxy-shared-data-1 \ + -a stdout -a stderr \ + -e "OO_ENV={{ oo_env }}" \ + -e "OO_CTR_TYPE=proxy" \ + -e "OO_ZABBIX_HOSTGROUPS={{ oo_zabbix_hostgroups | join(',') }}" \ + -e "OO_ZABBIX_TEMPLATES=Template OpenShift Proxy Ctr" \ + "docker-registry.ops.rhcloud.com/oso-v2-monitoring:{{ oo_env }}" + +ExecReload=-/usr/bin/docker stop "proxy-monitoring-1" +ExecReload=-/usr/bin/docker rm "proxy-monitoring-1" +ExecStop=-/usr/bin/docker stop "proxy-monitoring-1" + +[Install] +WantedBy=container.target + +# Container information +X-ContainerId=proxy-monitoring-1 +X-ContainerImage=docker-registry.ops.rhcloud.com/oso-v2-monitoring:{{ oo_env }} +X-ContainerUserId= +X-ContainerRequestId=LwiWtYWaAvSavH6Ze53QJg +X-ContainerType=simple +X-PortMapping=80:80 +X-PortMapping=443:443 +X-PortMapping=4999:4999 diff --git a/roles/atomic_proxy/templates/systemd/ctr-proxy-puppet-1.service.j2 b/roles/atomic_proxy/templates/systemd/ctr-proxy-puppet-1.service.j2 new file mode 100644 index 000000000..c3f28f471 --- /dev/null +++ b/roles/atomic_proxy/templates/systemd/ctr-proxy-puppet-1.service.j2 @@ -0,0 +1,33 @@ +[Unit] +Description=Container proxy-puppet-1 + + +[Service] +Type=simple +TimeoutStartSec=5m +Slice=container-small.slice + + +ExecStartPre=-/usr/bin/docker rm "proxy-puppet-1" + +ExecStart=/usr/bin/docker run --rm --name "proxy-puppet-1" \ + --volumes-from proxy-shared-data-1 \ + -v /var/lib/docker/volumes/proxy_puppet/var/lib/puppet/ssl:/var/lib/puppet/ssl \ + -v /var/lib/docker/volumes/proxy_puppet/etc/puppet:/etc/puppet \ + -a stdout -a stderr \ + "docker-registry.ops.rhcloud.com/oso-v2-puppet:{{ oo_env }}" + +# Set links (requires container have a name) +ExecReload=-/usr/bin/docker stop "proxy-puppet-1" +ExecReload=-/usr/bin/docker rm "proxy-puppet-1" +ExecStop=-/usr/bin/docker stop "proxy-puppet-1" + +[Install] +WantedBy=container.target + +# Container information +X-ContainerId=proxy-puppet-1 +X-ContainerImage=docker-registry.ops.rhcloud.com/oso-v2-puppet:{{ oo_env }} +X-ContainerUserId= +X-ContainerRequestId=Ky0lhw0onwoSDJR4GK6t3g +X-ContainerType=simple -- cgit v1.2.3