From 30f95742b91de1d7c06cbe898d6aa716e26f80b8 Mon Sep 17 00:00:00 2001 From: Jeff Bradberry Date: Thu, 26 Apr 2018 11:39:18 -0400 Subject: [PATCH 1/4] Split out the nodejs and npm related tasks into a new role --- README.rst | 38 ++++++++++++-------------------------- defaults/main.yml | 1 - handlers/main.yml | 15 --------------- tasks/main.yml | 19 ------------------- tasks/web.yml | 17 +++++------------ 5 files changed, 17 insertions(+), 73 deletions(-) diff --git a/README.rst b/README.rst index 0d16572..413e38f 100644 --- a/README.rst +++ b/README.rst @@ -43,24 +43,27 @@ allow the roles to be installed into ``/etc/ansible/roles``) :: Create a ``requirements.yml`` file in your project's deployment directory. It is recommended to include `tequila-common -`_, which sets up -the project directory structure and users, and also `geerlingguy/nodejs -`_ -to install nodejs and any front-end packages that your project -requires :: +`_, which sets up the +project directory structure and users, and also `tequila-nodejs +`_ and `geerlingguy/nodejs +`_ to install +nodejs and any front-end packages that your project requires :: --- # file: deployment/requirements.yml - - src: geerlingguy.nodejs - version: 4.1.2 - name: nodejs - - src: https://github.com/caktus/tequila-common version: v0.8.0 - src: https://github.com/caktus/tequila-django version: v0.9.11 + - src: geerlingguy.nodejs + version: 4.1.2 + name: nodejs + + - src: https://github.com/caktus/tequila-nodejs + version: v0.8.0 + Run ``ansible-galaxy`` with your requirements file :: $ ansible-galaxy install -r deployment/requirements.yml @@ -116,7 +119,6 @@ The following variables are used by the ``tequila-django`` role: - ``source_is_local`` **default:** ``false`` - ``github_deploy_key`` **required if source_is_local is false** - ``local_project_dir`` **required if source_is_local** -- ``ignore_devdependencies`` **default:** ``false`` - ``extra_env`` **default:** empty dict The ``extra_env`` variable is a dict of keys and values that is @@ -141,14 +143,6 @@ every web instance, since they'll be getting in each other's way. This variable set to ``true`` causes the ``collectstatic`` task to be run only once. -Due to `some `_ `issues -`_ discovered with -npm not managing package installation when new packages are added to -the ``devDependencies`` object in package.json, tequila-django checks -for the presence of any packages in this variable and will throw an -error if found. This behavior can be disabled by setting -``ignore_devdependencies`` to ``true``. - Optimizations ------------- @@ -163,11 +157,3 @@ to your project's `ansible.cfg` file :: **Warning:** this will cause deployments to break if ``securetty`` is used in your server's ``/etc/sudoers`` file. - - -Notes ------ - -See `geerlingguy/nodejs -`_ for the -expected Ansible configuration variables for that role. diff --git a/defaults/main.yml b/defaults/main.yml index 5129e85..0d4fb3d 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -19,5 +19,4 @@ use_newrelic: false source_is_local: false is_web: false is_worker: false -ignore_devdependencies: false extra_env: {} diff --git a/handlers/main.yml b/handlers/main.yml index cd10ccd..08c6585 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,19 +1,4 @@ --- -- name: chown node_modules - file: - owner: "{{ project_user }}" - group: "{{ project_user }}" - path: "{{ source_dir }}/node_modules" - recurse: yes - -- name: npm run build - command: npm run build - args: - chdir: "{{ source_dir }}" - become_user: "{{ project_user }}" - vars: - ansible_ssh_pipelining: true - - name: collectstatic django_manage: command: collectstatic diff --git a/tasks/main.yml b/tasks/main.yml index 815c3df..40bfe98 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -127,25 +127,6 @@ vars: ansible_ssh_pipelining: true -- name: check for a package.json file - stat: path={{ source_dir }}/package.json - register: package_json - -- name: check for build script in package.json - command: awk '/\/,/\/' {{ source_dir }}/package.json - register: build_script - when: package_json.stat.exists == True - -- name: check developer dependencies - command: npm ls -dev --parseable --prefix {{ source_dir }} - register: dev_dependencies - when: package_json.stat.exists == True - -- name: fail when there are project-level devDependencies - fail: - msg: "There are packages listed under `devDependencies`. Please move them to `dependencies` instead." - when: not ignore_devdependencies and package_json.stat.exists == True and dev_dependencies.stdout_lines|length > 1 - - name: clear out leftover build cruft from the project requirements file: path={{ venv_dir }}/build state=absent diff --git a/tasks/web.yml b/tasks/web.yml index cb2e9e7..fb0fc66 100644 --- a/tasks/web.yml +++ b/tasks/web.yml @@ -42,18 +42,11 @@ group={{ project_name }} mode=700 -# Note: we want the npm build and collectstatic steps to happen at the -# very end of the roles section for the current playbook, so that -# they'll still happen in the order needed even if the playbook has a -# 3rd-party role after tequila-django, e.g. geerlingguy/nodejs. Thus, -# they are moved out into handlers. - -- name: trigger build of npm artifacts - command: /bin/true - notify: - - chown node_modules - - npm run build - when: package_json.stat.exists == True and build_script.stdout != "" +# Note: we want the collectstatic step to happen at the very end of +# the roles section for the current playbook, so that it'll still +# happen in the order needed even if the playbook has another role +# after tequila-django, e.g. geerlingguy/nodejs and tequila-nodejs. +# Thus, it is moved out into handlers. - name: trigger collectstatic command: /bin/true From f4a332d9322f1db0a7ffd6d68df763abc884f1a1 Mon Sep 17 00:00:00 2001 From: Jeff Bradberry Date: Thu, 26 Apr 2018 12:08:43 -0400 Subject: [PATCH 2/4] Update CHANGES.rst to reflect this split, and note what projects need to do to support tequila-nodejs. --- CHANGES.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 424f82d..af7cf40 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -3,6 +3,20 @@ Tequila-django Changes +v 0.9.12 on April 27, 2018 +-------------------------- + +* Split out the npm tasks into a new role, `tequila-nodejs + `_. Projects upgrading to + this version will need to add tequila-nodejs to their + requirements.yml file while still retaining geerlingguy.nodejs, + which is a dependency of this new role. Additionally, the + playbook/web.yml playbook should be updated to execute + tequila-nodejs instead of geerlingguy.nodejs, and it should be + placed immediately after the tequila-django role. See the new + example web.yml file in the playbooks directory in this repo. + + v 0.9.11 on March 19, 2018 -------------------------- From d120b87305898b42854398815b9bb3d46899f3d4 Mon Sep 17 00:00:00 2001 From: Jeff Bradberry Date: Thu, 26 Apr 2018 12:13:20 -0400 Subject: [PATCH 3/4] Fix typo --- CHANGES.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index af7cf40..be91940 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -14,7 +14,8 @@ v 0.9.12 on April 27, 2018 playbook/web.yml playbook should be updated to execute tequila-nodejs instead of geerlingguy.nodejs, and it should be placed immediately after the tequila-django role. See the new - example web.yml file in the playbooks directory in this repo. + example web.yml file in the playbooks directory in the + `caktus/tequila `_ repo. v 0.9.11 on March 19, 2018 From 1c339f0772f96328d60d2cbf0c5ce9e5bb65c081 Mon Sep 17 00:00:00 2001 From: Neil Ashton Date: Thu, 31 May 2018 16:01:39 -0400 Subject: [PATCH 4/4] Updating CHANGES to reflect new date --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index be91940..f6df737 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -3,7 +3,7 @@ Tequila-django Changes -v 0.9.12 on April 27, 2018 +v 0.9.12 on May 31, 2018 -------------------------- * Split out the npm tasks into a new role, `tequila-nodejs