You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2019/10/16 19:44:40 UTC
[airavata] 01/07: Ansible: build django JS code locally in Docker
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch staging
in repository https://gitbox.apache.org/repos/asf/airavata.git
commit cf29ed27b1951c61042a29ab767a445a9b605ee6
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Tue Aug 6 09:33:20 2019 -0400
Ansible: build django JS code locally in Docker
---
dev-tools/ansible/requirements.txt | 1 +
dev-tools/ansible/roles/django/tasks/main.yml | 64 +++++++++++++++++++--------
2 files changed, 47 insertions(+), 18 deletions(-)
diff --git a/dev-tools/ansible/requirements.txt b/dev-tools/ansible/requirements.txt
index de84a27..dc30cfd 100644
--- a/dev-tools/ansible/requirements.txt
+++ b/dev-tools/ansible/requirements.txt
@@ -16,3 +16,4 @@
# under the License.
ansible~=2.3.1
+docker<3.0
diff --git a/dev-tools/ansible/roles/django/tasks/main.yml b/dev-tools/ansible/roles/django/tasks/main.yml
index 0cd19b0..2be4aa0 100644
--- a/dev-tools/ansible/roles/django/tasks/main.yml
+++ b/dev-tools/ansible/roles/django/tasks/main.yml
@@ -31,17 +31,51 @@
file: path="{{ doc_root_dir }}" state=directory owner="{{user}}" group="{{group}}"
become: yes
-- name: Git clone django portal
- git:
- repo: "{{ airavata_django_repo }}"
- dest: "{{ airavata_django_checkout }}"
- version: "{{ airavata_django_git_branch }}"
- update: yes
- force: yes
- become: yes
- become_user: "{{user}}"
- notify:
- - restart uwsgi
+- name: git clone django repo
+ local_action:
+ module: git
+ repo: "{{ airavata_django_repo }}"
+ # TODO: create new temp directory
+ dest: "/tmp/airavata-django-portal"
+ # TODO: change to {{ airavata_django_git_branch }}
+ version: "local-builds"
+ update: yes
+ force: yes
+ run_once: true
+
+# TODO: check if Docker is running (docker_host_info can_talk_to_docker? https://docs.ansible.com/ansible/latest/modules/docker_host_info_module.html#return-values)
+- name: build Docker image for building the JS
+ local_action:
+ module: docker_image
+ # TODO: use temp directory
+ path: "/tmp/airavata-django-portal/scripts/docker-build/"
+ name: av-django-build
+ force: true
+ # source: build
+ run_once: true
+
+- name: build Django JS code in Docker container
+ local_action:
+ module: docker_container
+ name: ansible-av-django-build
+ image: av-django-build
+ cleanup: true
+ detach: false
+ # TODO: use temp directory
+ volumes:
+ - /tmp/airavata-django-portal:/code
+ run_once: true
+
+- name: rsync build Django code to {{ airavata_django_checkout }}
+ synchronize:
+ src: /tmp/airavata-django-portal/
+ dest: "{{ airavata_django_checkout }}"
+ rsync_opts:
+ - "--exclude=node_modules"
+ # Bug: become_user doesn't work with synchronize: https://github.com/ansible/ansible/issues/29698
+ rsync_path: "sudo -u {{ user }} rsync"
+ # become: yes
+ # become_user: "{{user}}"
- name: Create virtual environment for Django portal and install dependencies
pip:
@@ -77,13 +111,6 @@
become: yes
become_user: "{{user}}"
-- name: Build JS
- command: bash {{ airavata_django_checkout }}/build_js.sh
- environment:
- STATIC_ROOT: "{{ static_root_dir }}"
- become: yes
- become_user: "{{user}}"
-
- name: Run Django's manage.py collectstatic
django_manage:
command: "collectstatic -i node_modules --noinput"
@@ -138,6 +165,7 @@
state: yes
persistent: yes
become: yes
+ when: ansible_os_family == "RedHat"
- name: run restorecon on those directories
command: restorecon -F -R {{ doc_root_dir }}