diff --git a/defaults/main.yml b/defaults/main.yml index 179b80e..57abd9f 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -18,9 +18,16 @@ rookeries_environ_type: dev # Name of the rookeries app rookeries_app_name: rookeries rookeries_version: 0.4.9 + +# Rookeries deployment configuration rookeries_app_hostname: localhost rookeries_local_uwsgi_port: 8001 +# TODO Clean up and factor out once better developed. +rookeries_deploy_source: "{{ rookeries_app_name }}-{{ rookeries_version }}-{{ rookeries_app_hostname }}" +rookeries_deploy_target: "{{ rookeries_app_name }}_{{ rookeries_app_hostname }}" + + # The default configuration for running rookeries rookeries_app_config: diff --git a/meta/main.yml b/meta/main.yml index 60cca1f..2ebfb54 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -13,9 +13,10 @@ galaxy_info: - development - web dependencies: - - { role: dorianpula.nginx-uwsgi-supervisor, - app_name: "{{ rookeries_app_name }}", - app_nginx_hostname: "{{ rookeries_app_hostname }}", - app_uwsgi_port: "{{ rookeries_local_uwsgi_port }}", - app_uwsgi_executable: "rookeries:make_rookeries_app()", - app_uwsgi_envs: "{{ rookeries_app_config }}"} + - role: dorianpula.nginx-uwsgi-supervisor + app_name: "{{ rookeries_app_name }}" + app_root_path: "{{ rookeries_app_symlink }}" + app_nginx_hostname: "{{ rookeries_app_hostname }}" + app_uwsgi_port: "{{ rookeries_local_uwsgi_port }}" + app_uwsgi_executable: "rookeries:make_rookeries_app()" + app_uwsgi_envs: "{{ rookeries_app_config }}" diff --git a/tasks/mysql_db.yaml b/tasks/mysql_db.yaml index 0f3764d..3209f72 100644 --- a/tasks/mysql_db.yaml +++ b/tasks/mysql_db.yaml @@ -12,6 +12,7 @@ when: rookeries_db.setup_db - name: add MySQL database users for rookeries. - mysql_user: name={{ rookeries_db.username }} password={{ rookeries_db.password }} priv={{ rookeries_db.db_name }}:ALL + mysql_user: name={{ rookeries_db.username }} password={{ rookeries_db.password }} + priv={{ rookeries_db.db_name }}.*:ALL login_host={{ rookeries_db.host }} login_port={{ rookeries_db.port }} when: rookeries_db.setup_db diff --git a/tasks/rookeries_deployment.yaml b/tasks/rookeries_deployment.yaml index 22a3769..b179332 100644 --- a/tasks/rookeries_deployment.yaml +++ b/tasks/rookeries_deployment.yaml @@ -10,7 +10,7 @@ when: deploy_package.stat.exists - name: install rookeries dependencies - pip: requirements=requirements.txt virtualenv={{ rookeries_venv }} chdir={{ app_root_path }} + pip: requirements=requirements.txt virtualenv={{ rookeries_venv }} chdir={{ rookeries_deploy_dir }} when: deploy_package.stat.exists # TODO Remove after transition to CouchDB as a store. @@ -19,13 +19,23 @@ extra_args="--allow-external mysql-connector-python --allow-unverified mysql-connector-python" when: deploy_package.stat.exists +- name: install frontend dependencies for app + npm: path={{ rookeries_deploy_dir }} state=present registry=http://registry.npmjs.org/ + when: deploy_package.stat.exists + - name: fix permissions on extracted web app - file: path={{ app_root_path }} owner={{ web_server_group }} group={{ web_server_group }} + file: path={{ rookeries_deploy_dir }} owner={{ web_server_group }} group={{ web_server_group }} state=directory recurse=yes when: deploy_package.stat.exists -- name: install frontend dependencies for app - npm: path={{ app_root_path }} state=present registry=http://registry.npmjs.org/ +- name: add in symlink to deployed package. + file: state=link src={{ rookeries_deploy_dir }} path={{ rookeries_app_symlink }} + owner={{ web_server_group }} group={{ web_server_group }} + when: deploy_package.stat.exists + +- name: add in symlink to deployed virtualenv. + file: state=link src={{ rookeries_venv }} path={{ rookeries_venv_symlink }} + owner={{ web_server_group }} group={{ web_server_group }} notify: - restart uwsgi app when: deploy_package.stat.exists diff --git a/vars/main.yml b/vars/main.yml index 01dda82..3ea06d3 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -3,9 +3,14 @@ app_name: "{{ rookeries_app_name }}" # Introduced from deployment playbook -rookeries_venv: "{{ virtualenv_root_path }}/{{ rookeries_app_name }}" -rookeries_package: "{{ rookeries_app_name }}-{{ rookeries_version }}.tar.bz2" + +rookeries_package: "{{ rookeries_deploy_source }}.tar.bz2" +rookeries_deploy_dir: "{{ web_root_path }}/{{ rookeries_deploy_source }}" +rookeries_venv: "{{ virtualenv_root_path }}/{{ rookeries_deploy_source }}" +rookeries_app_symlink: "{{ web_root_path }}/{{ rookeries_deploy_target }}" +rookeries_venv_symlink: "{{ virtualenv_root_path }}/{{ rookeries_deploy_target }}" + rookeries_package_path: "{{ rookeries_package }}" # Extra virtualenv if working in a dev environment to provide the mailsink testing server