From 2a4142f2b51f40986caa3e89e260152d65b10048 Mon Sep 17 00:00:00 2001 From: Dorian Pula Date: Wed, 11 Mar 2015 22:09:54 -0400 Subject: [PATCH] Integrate deployment of rookeries web application into rolebook. --- deployment.yaml | 30 ------------------------------ tasks/main.yml | 1 + tasks/rookeries_deployment.yaml | 31 +++++++++++++++++++++++++++++++ vars/main.yml | 7 +++++++ 4 files changed, 39 insertions(+), 30 deletions(-) delete mode 100644 deployment.yaml create mode 100644 tasks/rookeries_deployment.yaml diff --git a/deployment.yaml b/deployment.yaml deleted file mode 100644 index a93708b..0000000 --- a/deployment.yaml +++ /dev/null @@ -1,30 +0,0 @@ ---- -- hosts: all - sudo: yes - vars: - web_server_home: /srv/www - web_server_group: www-data - rookeries_venv: "{{ web_server_home }}/virtualenvs/rookeries" - rookeries_package: rookeries-0.4.0.tar.bz2 - tasks: - - - name: upload + extract rookeries package to web server home - unarchive: src=../../../{{ rookeries_package }} dest={{ web_server_home }}/ - - - name: install rookeries dependencies - pip: requirements=rookeries_webapp/requirements.txt virtualenv={{ rookeries_venv }} chdir={{ web_server_home }} - - - name: install extra MySQL python connector dependency - pip: name=mysql-connector-python virtualenv={{ rookeries_venv }} version=1.1.6 - extra_args='--allow-external mysql-connector-python --allow-unverified mysql-connector-python' - - - name: fix permissions on extracted web app - file: path={{ web_server_home }}/rookeries_webapp owner={{ web_server_group }} group={{ web_server_group }} - state=directory recurse=yes - - # TODO Step 4 - Setup environment variables on target system related to config. - - - name: install bower dependencies in app - command: bower install --allow-root --quiet chdir={{ web_server_home }}/rookeries_webapp - # TODO Replace with bower command in future version of Ansible (1.9.0) - # bower: path={{ web_server_home }}/rookeries_webapp state=present diff --git a/tasks/main.yml b/tasks/main.yml index 9515eb3..8a2473e 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,3 +2,4 @@ - include: mysql_db.yaml - include: nodejs.yaml - include: dev_email_server.yaml +- include: rookeries_deployment.yaml diff --git a/tasks/rookeries_deployment.yaml b/tasks/rookeries_deployment.yaml new file mode 100644 index 0000000..b727557 --- /dev/null +++ b/tasks/rookeries_deployment.yaml @@ -0,0 +1,31 @@ +--- +- name: upload + extract rookeries package to web server home + unarchive: src={{ rookeries_package_path }} dest={{ web_root_path }} + sudo: yes + register: ready_to_deploy + ignore_errors: True + +- command: echo Hello {{ app_root_path }} + +- name: install rookeries dependencies + pip: requirements=requirements.txt virtualenv={{ rookeries_venv }} chdir={{ app_root_path }} + when: ready_to_deploy|success + +- name: install extra MySQL python connector dependency + pip: name=mysql-connector-python virtualenv={{ rookeries_venv }} version=1.1.6 + extra_args='--allow-external mysql-connector-python --allow-unverified mysql-connector-python' + when: ready_to_deploy|success + +- name: fix permissions on extracted web app + file: path={{ app_root_path }} owner={{ web_server_group }} group={{ web_server_group }} + state=directory recurse=yes + when: ready_to_deploy|success + +# TODO Step 4 - Setup environment variables on target system related to config. + +- name: install bower dependencies in app + command: bower install --allow-root --quiet chdir={{ web_root_path }}/rookeries_webapp + notify: restart uwsgi app + when: ready_to_deploy|success + # TODO Replace with bower command in future version of Ansible (1.9.0) + # bower: path={{ app_root_path }} state=present diff --git a/vars/main.yml b/vars/main.yml index 04c8283..8f68e67 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -7,8 +7,15 @@ databases: # TODO Move into defaults/main.yaml rookeries_app_name: rookeries +app_name: "{{ rookeries_app_name }}" # The mode of the setup. Setting to "dev" enables the use of a SMTP fake server to help with development. # TODO Move into defaults/main.yaml rookeries_environ_type: dev rookeries_dev_email_server_venv: "{{ virtualenv_root_path }}/mail_server" + +# Introduced from deployment playbook +# TODO Reorganize everything +rookeries_venv: "{{ virtualenv_root_path }}/rookeries" +rookeries_package: rookeries-0.4.0.tar.bz2 +rookeries_package_path: "../../{{ rookeries_package }}"