Separated workers and webservers
This commit is contained in:
45
roles/applicationvars/tasks/main.yml
Normal file
45
roles/applicationvars/tasks/main.yml
Normal file
@@ -0,0 +1,45 @@
|
||||
---
|
||||
# This task puts all application variables in place for both workers and webservers
|
||||
#
|
||||
|
||||
- name: Create prod.env
|
||||
shell: touch /var/www/html/prod.env
|
||||
|
||||
- name: Declare env file
|
||||
shell: echo export WRESTLINGDEV_ENV_FILE=/var/www/html/prod.env
|
||||
|
||||
- name: Set env file permanently
|
||||
shell: echo export WRESTLINGDEV_ENV_FILE=/var/www/html/prod.env >> /etc/environment
|
||||
|
||||
- name: Set DB Name
|
||||
shell: echo export WRESTLINGDEV_DB_NAME={{ lookup('env', 'WRESTLINGDEV_DB_NAME') }} >> /var/www/html/prod.env
|
||||
|
||||
- name: Set db password
|
||||
shell: echo export WRESTLINGDEV_DB_PWD={{ lookup('env', 'WRESTLINGDEV_DB_PWD') }} >> /var/www/html/prod.env
|
||||
|
||||
- name: Set db host
|
||||
shell: echo export WRESTLINGDEV_DB_HOST={{ lookup('env', 'WRESTLINGDEV_DB_HOST') }} >> /var/www/html/prod.env
|
||||
|
||||
- name: Set db port
|
||||
shell: echo export WRESTLINGDEV_DB_PORT={{ lookup('env', 'WRESTLINGDEV_DB_PORT') }} >> /var/www/html/prod.env
|
||||
|
||||
- name: Set devise secret key
|
||||
shell: echo export WRESTLINGDEV_DEVISE_SECRET_KEY={{ lookup('env', 'WRESTLINGDEV_DEVISE_SECRET_KEY') }} >> /var/www/html/prod.env
|
||||
|
||||
- name: Set secret key base
|
||||
shell: echo export WRESTLINGDEV_SECRET_KEY_BASE={{ lookup('env', 'WRESTLINGDEV_SECRET_KEY_BASE') }} >> /var/www/html/prod.env
|
||||
|
||||
- name: Set new relic license
|
||||
shell: echo export WRESTLINGDEV_NEW_RELIC_LICENSE_KEY={{ lookup('env', 'WRESTLINGDEV_NEW_RELIC_LICENSE_KEY') }} >> /var/www/html/prod.env
|
||||
|
||||
- name: Set memcached username
|
||||
shell: echo export MEMCACHIER_USERNAME={{ lookup('env', 'MEMCACHIER_USERNAME') }} >> /var/www/html/prod.env
|
||||
|
||||
- name: Set memcached password
|
||||
shell: echo export MEMCACHIER_PASSWORD={{ lookup('env', 'MEMCACHIER_PASSWORD') }} >> /var/www/html/prod.env
|
||||
|
||||
- name: Set memcached servers
|
||||
shell: echo export MEMCACHIER_SERVERS={{ lookup('env', 'MEMCACHIER_SERVERS') }} >> /var/www/html/prod.env
|
||||
|
||||
- name: Set email password
|
||||
shell: echo export WRESTLINGDEV_EMAIL_PWD={{ lookup('env', 'WRESTLINGDEV_EMAIL_PWD') }} >> /var/www/html/prod.env
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
# This playbook contains playhs that will run on all nodes
|
||||
# This playbook contains plays that will run on all nodes
|
||||
|
||||
- name: Update apt
|
||||
apt: update_cache=yes
|
||||
|
||||
@@ -1,54 +1,9 @@
|
||||
---
|
||||
# These tasks are responsible for copying the latest dev/production code from
|
||||
# # the version control system.
|
||||
#
|
||||
# This task clones the repo and runs the webserver docker container.
|
||||
|
||||
- name: Copy the code from repository
|
||||
git: repo={{ repository }} dest=/var/www/html/
|
||||
|
||||
- name: Create prod.env
|
||||
shell: touch /var/www/html/prod.env
|
||||
|
||||
- name: Declare env file
|
||||
shell: echo export WRESTLINGDEV_ENV_FILE=/var/www/html/prod.env
|
||||
|
||||
- name: Set env file permanently
|
||||
shell: echo export WRESTLINGDEV_ENV_FILE=/var/www/html/prod.env >> /etc/environment
|
||||
|
||||
- name: Set DB Name
|
||||
shell: echo export WRESTLINGDEV_DB_NAME={{ lookup('env', 'WRESTLINGDEV_DB_NAME') }} >> /var/www/html/prod.env
|
||||
|
||||
- name: Set db password
|
||||
shell: echo export WRESTLINGDEV_DB_PWD={{ lookup('env', 'WRESTLINGDEV_DB_PWD') }} >> /var/www/html/prod.env
|
||||
|
||||
- name: Set db host
|
||||
shell: echo export WRESTLINGDEV_DB_HOST={{ lookup('env', 'WRESTLINGDEV_DB_HOST') }} >> /var/www/html/prod.env
|
||||
|
||||
- name: Set db port
|
||||
shell: echo export WRESTLINGDEV_DB_PORT={{ lookup('env', 'WRESTLINGDEV_DB_PORT') }} >> /var/www/html/prod.env
|
||||
|
||||
- name: Set devise secret key
|
||||
shell: echo export WRESTLINGDEV_DEVISE_SECRET_KEY={{ lookup('env', 'WRESTLINGDEV_DEVISE_SECRET_KEY') }} >> /var/www/html/prod.env
|
||||
|
||||
- name: Set secret key base
|
||||
shell: echo export WRESTLINGDEV_SECRET_KEY_BASE={{ lookup('env', 'WRESTLINGDEV_SECRET_KEY_BASE') }} >> /var/www/html/prod.env
|
||||
|
||||
- name: Set new relic license
|
||||
shell: echo export WRESTLINGDEV_NEW_RELIC_LICENSE_KEY={{ lookup('env', 'WRESTLINGDEV_NEW_RELIC_LICENSE_KEY') }} >> /var/www/html/prod.env
|
||||
|
||||
- name: Set memcached username
|
||||
shell: echo export MEMCACHIER_USERNAME={{ lookup('env', 'MEMCACHIER_USERNAME') }} >> /var/www/html/prod.env
|
||||
|
||||
- name: Set memcached password
|
||||
shell: echo export MEMCACHIER_PASSWORD={{ lookup('env', 'MEMCACHIER_PASSWORD') }} >> /var/www/html/prod.env
|
||||
|
||||
- name: Set memcached servers
|
||||
shell: echo export MEMCACHIER_SERVERS={{ lookup('env', 'MEMCACHIER_SERVERS') }} >> /var/www/html/prod.env
|
||||
|
||||
- name: Set email password
|
||||
shell: echo export WRESTLINGDEV_EMAIL_PWD={{ lookup('env', 'WRESTLINGDEV_EMAIL_PWD') }} >> /var/www/html/prod.env
|
||||
|
||||
- name: Create and start apache docker image
|
||||
shell: cd /var/www/html/ && bash rails-prod.sh wrestlingdev-web
|
||||
|
||||
- name: Create and run delayed job worker
|
||||
shell: cd /var/www/html/ && bash rails-worker-prod.sh wrestlingdev-worker
|
||||
|
||||
8
roles/worker/tasks/main.yml
Normal file
8
roles/worker/tasks/main.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
# This task clones the repo and runs the worker docker container.
|
||||
#
|
||||
- name: Copy the code from repository
|
||||
git: repo={{ repository }} dest=/var/www/html/
|
||||
|
||||
- name: Create and run delayed job worker
|
||||
shell: cd /var/www/html/ && bash rails-worker-prod.sh wrestlingdev-worker
|
||||
11
site.yml
11
site.yml
@@ -13,15 +13,24 @@
|
||||
remote_user: root
|
||||
|
||||
roles:
|
||||
- applicationvars
|
||||
- web
|
||||
|
||||
- name: configure and deploy the rails workers and application code
|
||||
hosts: workers
|
||||
remote_user: root
|
||||
|
||||
roles:
|
||||
- applicationvars
|
||||
- worker
|
||||
|
||||
- name: deploy first db and create cluster
|
||||
hosts: dbfirstclustermachine
|
||||
remote_user: root
|
||||
|
||||
roles:
|
||||
- firstdb
|
||||
- db
|
||||
- firstdb
|
||||
|
||||
- name: deploy mysql and configure database
|
||||
hosts: dbservers
|
||||
|
||||
Reference in New Issue
Block a user