mirror of
https://github.com/koodiklinikka/playbooks.git
synced 2026-02-25 00:56:55 +00:00
remove duplication from deploy
This commit is contained in:
21
roles/deploy/tasks/rollback.yml
Normal file
21
roles/deploy/tasks/rollback.yml
Normal file
@@ -0,0 +1,21 @@
|
||||
---
|
||||
|
||||
- name: get running container
|
||||
shell: docker ps -a|grep {{ container_name }}|grep latest| awk '{print $1}'
|
||||
register: current_container_id
|
||||
|
||||
- name: kill old version
|
||||
shell: docker stop {{ container_name }}
|
||||
when: current_container_id != ""
|
||||
|
||||
- name: get old containers
|
||||
shell: docker ps -a|grep Exited| awk '{print $1}'
|
||||
register: old_containers
|
||||
|
||||
- name: clean old containers
|
||||
shell: docker rm $(docker ps -a|grep Exited| awk '{print $1}')
|
||||
when: old_containers.stdout != ""
|
||||
|
||||
- name: Start the container
|
||||
shell: docker run -d --name {{ container_name }} {{ container_name }}:old
|
||||
|
||||
Reference in New Issue
Block a user