From commits-return-21504-archive-asf-public=cust-asf.ponee.io@airavata.apache.org Wed Oct 16 19:44:40 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 7774118067E for ; Wed, 16 Oct 2019 21:44:40 +0200 (CEST) Received: (qmail 56170 invoked by uid 500); 16 Oct 2019 19:44:39 -0000 Mailing-List: contact commits-help@airavata.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@airavata.apache.org Delivered-To: mailing list commits@airavata.apache.org Received: (qmail 56081 invoked by uid 99); 16 Oct 2019 19:44:39 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Oct 2019 19:44:39 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 64BBF811C0; Wed, 16 Oct 2019 19:44:39 +0000 (UTC) Date: Wed, 16 Oct 2019 19:44:40 +0000 To: "commits@airavata.apache.org" Subject: [airavata] 01/07: Ansible: build django JS code locally in Docker MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: machristie@apache.org In-Reply-To: <157125507930.31316.12449506241876041442@gitbox.apache.org> References: <157125507930.31316.12449506241876041442@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: airavata X-Git-Refname: refs/heads/staging X-Git-Reftype: branch X-Git-Rev: cf29ed27b1951c61042a29ab767a445a9b605ee6 X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20191016194439.64BBF811C0@gitbox.apache.org> 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 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 }}