Trying to handle containers in a smarter way
This commit is contained in:
@@ -16,11 +16,18 @@
|
|||||||
- name: Create apache docker image
|
- name: Create apache docker image
|
||||||
command: chdir=/root/wrestlingApp docker build -t wrestlingdev-web -f rails-prod-Dockerfile .
|
command: chdir=/root/wrestlingApp docker build -t wrestlingdev-web -f rails-prod-Dockerfile .
|
||||||
|
|
||||||
- name: Kill running docker container
|
- name: Is wrestlingdev running
|
||||||
shell: docker stop $(docker ps -a -q)
|
command: docker ps | grep wrestlingdev
|
||||||
|
register: wrestlingdev_running
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: Kill and remove container
|
||||||
|
command: docker stop $(docker ps -a -q) && docker rm $(docker ps -a -q)
|
||||||
|
when: wrestlingdev_running != ""
|
||||||
|
|
||||||
- name: Start docker container
|
- name: Start docker container
|
||||||
command: docker run -h {{ansible_hostname}} -d --restart=always --env-file /root/prod.env -v /srv/docker/apache2/logs:/var/log/apache2 -v /etc/localtime:/etc/localtime -p 80:80 -p 443:443 wrestlingdev-web
|
command: docker run -h {{ansible_hostname}} --name wrestlingdev-web -d --restart=always --env-file /root/prod.env -v /srv/docker/apache2/logs:/var/log/apache2 -v /etc/localtime:/etc/localtime -p 80:80 -p 443:443 wrestlingdev-web
|
||||||
|
when: wrestlingdev_running == ""
|
||||||
|
|
||||||
- hosts: worker
|
- hosts: worker
|
||||||
remote_user: root
|
remote_user: root
|
||||||
@@ -36,8 +43,15 @@
|
|||||||
- name: Create apache docker image
|
- name: Create apache docker image
|
||||||
command: chdir=/root/wrestlingApp docker build -t wrestlingdev-worker -f rails-prod-Dockerfile .
|
command: chdir=/root/wrestlingApp docker build -t wrestlingdev-worker -f rails-prod-Dockerfile .
|
||||||
|
|
||||||
- name: Kill running docker container
|
- name: Is wrestlingdev running
|
||||||
shell: docker stop $(docker ps -a -q)
|
command: docker ps | grep wrestlingdev
|
||||||
|
register: wrestlingdev_running
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: Kill and remove container
|
||||||
|
command: docker stop $(docker ps -a -q) && docker rm $(docker ps -a -q)
|
||||||
|
when: wrestlingdev_running != ""
|
||||||
|
|
||||||
- name: Start docker container
|
- name: Start docker container
|
||||||
command: docker run -h {{ansible_hostname}} -d --restart=always --env-file /root/prod.env -v /etc/localtime:/etc/localtime wrestlingdev-worker bundle exec rake jobs:work RAILS_ENV=production
|
command: docker run -h {{ansible_hostname}} --name wrestlingdev-worker -d --restart=always --env-file /root/prod.env -v /etc/localtime:/etc/localtime wrestlingdev-worker bundle exec rake jobs:work RAILS_ENV=production
|
||||||
|
when: wrestlingdev_running == ""
|
||||||
|
|||||||
@@ -7,5 +7,15 @@
|
|||||||
- name: Create apache docker image
|
- name: Create apache docker image
|
||||||
command: chdir=/root/wrestlingApp docker build -t wrestlingdev-web -f rails-prod-Dockerfile .
|
command: chdir=/root/wrestlingApp docker build -t wrestlingdev-web -f rails-prod-Dockerfile .
|
||||||
|
|
||||||
|
- name: Is wrestlingdev running
|
||||||
|
command: docker ps | grep wrestlingdev
|
||||||
|
register: wrestlingdev_running
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: Kill and remove container
|
||||||
|
command: docker stop $(docker ps -a -q) && docker rm $(docker ps -a -q)
|
||||||
|
when: wrestlingdev_running != ""
|
||||||
|
|
||||||
- name: Start docker container
|
- name: Start docker container
|
||||||
command: docker run -h {{ansible_hostname}} -d --restart=always --env-file /root/prod.env -v /srv/docker/apache2/logs:/var/log/apache2 -v /etc/localtime:/etc/localtime -p 80:80 -p 443:443 wrestlingdev-web
|
command: docker run -h {{ansible_hostname}} --name wrestlingdev-web -d --restart=always --env-file /root/prod.env -v /srv/docker/apache2/logs:/var/log/apache2 -v /etc/localtime:/etc/localtime -p 80:80 -p 443:443 wrestlingdev-web
|
||||||
|
when: wrestlingdev_running == ""
|
||||||
|
|||||||
@@ -7,5 +7,15 @@
|
|||||||
- name: Create apache docker image
|
- name: Create apache docker image
|
||||||
command: chdir=/root/wrestlingApp docker build -t wrestlingdev-worker -f rails-prod-Dockerfile .
|
command: chdir=/root/wrestlingApp docker build -t wrestlingdev-worker -f rails-prod-Dockerfile .
|
||||||
|
|
||||||
|
- name: Is wrestlingdev running
|
||||||
|
command: docker ps | grep wrestlingdev
|
||||||
|
register: wrestlingdev_running
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: Kill and remove container
|
||||||
|
command: docker stop $(docker ps -a -q) && docker rm $(docker ps -a -q)
|
||||||
|
when: wrestlingdev_running != ""
|
||||||
|
|
||||||
- name: Start docker container
|
- name: Start docker container
|
||||||
command: docker run -h {{ansible_hostname}} -d --restart=always --env-file /root/prod.env -v /etc/localtime:/etc/localtime wrestlingdev-worker bundle exec rake jobs:work RAILS_ENV=production
|
command: docker run -h {{ansible_hostname}} --name wrestlingdev-worker -d --restart=always --env-file /root/prod.env -v /etc/localtime:/etc/localtime wrestlingdev-worker bundle exec rake jobs:work RAILS_ENV=production
|
||||||
|
when: wrestlingdev_running == ""
|
||||||
|
|||||||
Reference in New Issue
Block a user