Files
wrestlingdev-ansible/playbooks/code-deploy.yml

56 lines
1.7 KiB
YAML

---
# This playbook deploys the whole application stack for wrestlingdev
#
- hosts: web
remote_user: root
serial: 1
tasks:
- name: Refresh code
command: chdir=/root/wrestlingApp git pull origin master
- name: Pull latest ruby image
command: docker pull ruby:2.3.0
- name: Create apache docker image
command: chdir=/root/wrestlingApp docker build -t wrestlingdev-web -f rails-prod-Dockerfile .
- name: Kill container
command: docker stop wrestlingdev-web
ignore_errors: yes
- name: Remove container
command: docker rm wrestlingdev-web
ignore_errors: yes
- name: Start docker container
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
ignore_errors: yes
- hosts: worker
remote_user: root
serial: 1
tasks:
- name: Refresh code
command: chdir=/root/wrestlingApp git pull origin master
- name: Pull latest ruby image
command: docker pull ruby:2.3.0
- name: Create apache docker image
command: chdir=/root/wrestlingApp docker build -t wrestlingdev-worker -f rails-prod-Dockerfile .
- name: Kill container
command: docker stop wrestlingdev-worker
ignore_errors: yes
- name: Remove container
command: docker rm wrestlingdev-worker
ignore_errors: yes
- name: Start docker container
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
ignore_errors: yes