ansible: playbook for deploying MozReview to production
authorGregory Szorc <gps@mozilla.com>
Mon, 20 Apr 2015 08:58:57 -0700
changeset 360693 e73ddc6910b40eae33b6d215bd1a72e052223b56
parent 360692 77fec00acbf6ce64a49b941ea39470b747a8cd29
child 360694 a7389a53e79babeddf0169ecbbea1c3b4efeb2fd
push id16998
push userrwood@mozilla.com
push dateMon, 02 May 2016 19:42:03 +0000
ansible: playbook for deploying MozReview to production This isn't complete. But it is better than nothing.
ansible/deploy-mozreview-prod.yml
ansible/hosts
ansible/roles/reviewboard-admin/defaults/main.yml
ansible/roles/reviewboard-admin/files/requirements.txt
ansible/roles/reviewboard-admin/tasks/main.yml
testing/vcttesting/deploy.py
testing/vcttesting/deploy_mach_commands.py
new file mode 100644
--- /dev/null
+++ b/ansible/deploy-mozreview-prod.yml
@@ -0,0 +1,34 @@
+# This playbook is used to update the production deployment of
+# MozReview (reviewboard.mozilla.org).
+---
+- hosts: reviewboardadm.private.scl3.mozilla.com
+  roles:
+    - { role: reviewboard-admin, site: reviewboard.mozilla.org }
+  vars:
+    repo: https://hg.mozilla.org/hgcustom/version-control-tools
+    rev: "@"
+    vct: /data/reviewboard/src/version-control-tools
+    venv: /data/reviewboard/src/reviewboard.mozilla.org/venv
+    python: /data/reviewboard/src/reviewboard.mozilla.org/venv/bin/python
+    easy_install: /data/reviewboard/src/reviewboard.mozilla.org/venv/bin/easy_install
+    rbsite: /data/reviewboard/src/reviewboard.mozilla.org/venv/bin/rb-site
+    sitehome: /data/reviewboard/src/reviewboard.mozilla.org/reviewboard
+  tasks:
+    - name: prepare v-c-t repo
+      hg: repo={{ repo }} dest={{ vct }} revision={{ rev }} force=yes purge=yes executable={{ venv }}/bin/hg
+
+    # TODO: consolidate with reviewboard-dev.yml in a role.
+    - name: build MozReview eggs
+      command: "{{ python }} setup.py bdist_egg chdir={{ vct }}/{{ item }}"
+      with_items:
+        - pylib/mozreview
+        - pylib/rbbz
+
+    - name: install MozReview eggs
+      shell: "{{ easy_install }} -U dist/*.egg chdir={{ vct }}/{{ item}}"
+      with_items:
+        - pylib/mozreview
+        - pylib/rbbz
+
+    - name: generate static Review Board files
+      command: "{{ rbsite }} manage {{ sitehome }} -- collectstatic --noinput"
--- a/ansible/hosts
+++ b/ansible/hosts
@@ -1,1 +1,2 @@
 reviewboard1.dev.webapp.scl3.mozilla.com ansible_ssh_user=root
+reviewboardadm.private.scl3.mozilla.com ansible_sudo=true
new file mode 100644
--- /dev/null
+++ b/ansible/roles/reviewboard-admin/defaults/main.yml
@@ -0,0 +1,2 @@
+---
+src: /data/reviewboard/src
new file mode 100644
--- /dev/null
+++ b/ansible/roles/reviewboard-admin/files/requirements.txt
@@ -0,0 +1,105 @@
+--find-links http://downloads.reviewboard.org/releases/django-evolution/0.7/
+--find-links http://downloads.reviewboard.org/releases/Djblets/0.8/
+--allow-external django-evolution
+--allow-unverified django-evolution
+--allow-external rbtools
+--allow-unverified rbtools
+
+# sha256: 406XZaYSD0ZkwSD0GYp4bDmg-35KWb0ZotbjqIS2OIk
+amqp==1.4.6
+
+# sha256: N4Ethjya0-NcBzTELgvwMgzow77YLNIK1UyzTRWBV7o
+anyjson==0.3.3
+
+# sha256: 0Bl46ajFHqezTscfP87RMmQ3zTZrnC4ZJlrOBQkk4OI
+argparse==1.3.0
+
+# sha256: byzISLK3Kt9TpvPyG-BJxHfoLECLznzttX7-sJhL3iQ
+Django==1.6.11
+
+# sha256: ca3Sb2gsLnZSxD0Bq2rBscaT2Gn2YxQvX3w3sAeI0WI
+django-pipeline==1.3.27
+
+# sha256: C3W_Fj1chZ8XG69nRQPfs8p9HS7wguXFlS1Sue5mROQ
+django-evolution==0.7.4
+
+# sha256: ow34iO4NoyxIN8Mo7PhZ6ZLtttGF76fUk0HMGUnbsk0
+django-haystack==2.3.1
+
+# sha256: 4ieyxkTS3HwtK5IAe_mb6vbqfhu0Lh5mrVsaBY9W7q4
+Djblets==0.8.18
+
+# sha256: x9txeBCraWX2bIzwOYqYydjfmC2jm0zX8WKRHriVlvo
+docutils==0.12
+
+# sha256: QNACzzYNDgNc8suYXhMI1BqqCHy_wTWy3C2EQpbqVGw
+ecdsa==0.13
+
+# sha256: f2UH1ADQft_R6oIF2jaAgAmwxTn1uKbgq1Qze5VebcM
+feedparser==5.1.3
+
+# sha256: n9IrNUpMR1WtjH0WHZP1AmrKTP6Zm9LlMWjxR2XALNY
+futures==2.2.0
+
+# sha256: fLtRSjUvghxpuOi9qmsuWXKFR6iWVQPHWGUsKCbRV7U
+importlib==1.0.3
+
+# sha256: SGL3SQ8T4GJXMS9X6BVT85jMcboDXQJjL_QXOcVy1K0
+kombu==3.0.24
+
+# sha256: gS7FJJ9F7cMTMLf7BuUqr2qy2DqicEfffLaDfvLSabY
+Markdown==2.4.1
+
+# sha256: pEU2fw3Lrzpieb-nQ7Nk5ym-DR8MhSy2038peRb_rhM
+mercurial==3.3.3
+
+# sha256: U0_2_u_hzQOYT0ROZBWqzHnAqF87ho7EGi_VADAEwx4
+mimeparse==0.1.3
+
+# sha256: 3Fi2CrGs4V9Safiq-CebD25SXZLec7D2ts-Hh6z7Uww
+MozillaPulse==1.0.1
+
+# sha256: gRBAtkfl1WhvhNtBXv1pfmJQAIsRK2kJunesBZ4UDHQ
+MySQL-python==1.2.5
+
+# sha256: HDW0rCBs7y0kgWyJ-Jzyid09OM98RJuz-re_bUPwGx8
+ordereddict==1.1
+
+# sha256: xnVVjqRXwUdce4L0rkBL31bERj9vJiZloxvfi5yahZw
+paramiko==1.15.2
+
+# sha256: JukyDnP1ghgmtrJAijv_Cowp5FFZUwBpoRfv0572Gfg
+Pillow==2.7.0
+
+# sha256: Fbzhklo9ZpQM65ozw8Vd6NlUYs4TbE1G6Gc_KRm0AdY
+pillowfight==0.2
+
+# sha256: CjoiZeHvsN76ci0fQpcw3J35da3DxgrH0rQyvfA8BB0
+Pygments==2.0.2
+
+# sha256: bxlzSLRvuM358_z8Kn1al9qV2z4uhmfPZXIWJ0_hsAk
+python-dateutil==1.5
+
+# sha256: Z-HBi2uZykwsjkoC4KlhdL9waJGaWv9Sg2YAl0we9Ng
+python-memcached==1.54
+
+# sha256: NYsFoMJgXBXPgzfRcBbrla_qrQfJAN-cLN524hlKklg
+pytz==2015.2
+
+# sha256: KMaFPB0T02W33HGmsF5f-1ZHH3CoUN4xivUNPXwN6i8
+recaptcha-client==1.0.6
+
+# sha256: fee8TQCm0FHbs2C0jrfzzQAjc9hyUvsLKEo8nEU6dnc
+Whoosh==2.6.0
+
+# sha256: 8s4emJsnLPy2d2FnY-Ci5-xlnv-meoiqkrOmVSj2Cjw
+pycrypto==2.6.1
+
+# sha256: SFxYdfcE05QYN1gC0971KqEk7KP85BG_dgBMsBBodzU
+RBTools==0.6.1
+
+# sha256: EkiQ9BcjyFqoLf4IB0Mq6kbSSusNr840CWnSCJVIwsM
+requests==2.4.3
+
+# sha256: QYqTw5en7asj5ViNvAZ6x0pyPts9VBvUk295R252Rdo
+six==1.9.0
new file mode 100644
--- /dev/null
+++ b/ansible/roles/reviewboard-admin/tasks/main.yml
@@ -0,0 +1,26 @@
+---
+- name: install dependency packages
+  yum: name={{ item }}
+  with_items:
+    - libjpeg-turbo-devel
+    - mysql-devel
+    - nodejs-less
+    - nodejs-uglify-js
+    - python-devel
+    - python-virtualenv
+    - zlib-devel
+
+- name: copy requirements.txt
+  copy: src=requirements.txt dest={{ src }}/{{ site }}/requirements.txt owner=root group=root
+
+- name: create virtualenv
+  command: /usr/bin/virtualenv {{ src }}/{{ site }}/venv creates={{ src }}/{{ site}}/venv
+
+- name: ensure packaging packages up to date
+  command: "{{ src }}/{{ site }}/venv/bin/pip install --upgrade pip peep setuptools"
+
+- name: populate virtualenv
+  pip: virtualenv={{ src }}/{{ site }}/venv requirements={{ src }}/{{ site }}/requirements.txt executable={{ src }}/{{ site }}/venv/bin/peep
+
+- name: install Review Board package
+  command: "{{ src }}/{{ site }}/venv/bin/easy_install ReviewBoard==2.0.12"
--- a/testing/vcttesting/deploy.py
+++ b/testing/vcttesting/deploy.py
@@ -38,8 +38,19 @@ def deploy_reviewboard_dev(repo=None, re
     extra = {}
     if repo:
         extra['repo'] = repo
     if rev:
         extra['rev'] = rev
 
     return run_playbook('reviewboard-dev', extra_vars=extra,
                         verbosity=verbosity)
+
+
+def deploy_reviewboard_prod(repo=None, rev=None, verbosity=0):
+    extra = {}
+    if repo:
+        extra['repo'] = repo
+    if rev:
+        extra['rev'] = rev
+
+    return run_playbook('deploy-mozreview-prod', extra_vars=extra,
+                        verbosity=verbosity)
--- a/testing/vcttesting/deploy_mach_commands.py
+++ b/testing/vcttesting/deploy_mach_commands.py
@@ -3,17 +3,20 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from mach.decorators import (
     CommandArgument,
     CommandProvider,
     Command,
 )
 
-from vcttesting.deploy import deploy_reviewboard_dev
+from vcttesting.deploy import (
+    deploy_reviewboard_dev,
+    deploy_reviewboard_prod,
+)
 
 
 @CommandProvider
 class DeployCommands(object):
     def __init__(self, context):
         lm = context.log_manager
         lm.enable_unstructured()
 
@@ -22,8 +25,19 @@ class DeployCommands(object):
     @CommandArgument('--repo',
                      help='Alternative repository URL to deploy from')
     @CommandArgument('--rev',
                      help='Explicit revision in repository to deploy from')
     @CommandArgument('--verbosity', type=int,
                      help='How verbose to be with output')
     def reviewboard_dev(self, repo=None, rev=None, verbosity=None):
         return deploy_reviewboard_dev(repo=repo, rev=rev, verbosity=verbosity)
+
+    @Command('reviewboard-prod', category='deploy',
+             description='Deploy Review Board to production')
+    @CommandArgument('--repo',
+                     help='Alternative repository URL to deploy from')
+    @CommandArgument('--rev',
+                     help='Explicit revision in repository to deploy from')
+    @CommandArgument('--verbosity', type=int,
+                     help='How verbose to be with output')
+    def reviewboard_prod(self, repo=None, rev=None, verbosity=None):
+        return deploy_reviewboard_prod(repo=repo, rev=rev, verbosity=verbosity)