From fa65f215a42b6513884aca8a606a269da1c562fe Mon Sep 17 00:00:00 2001 From: A Holt Date: Sun, 15 Jul 2018 01:18:42 -0400 Subject: [PATCH 1/6] Update main.yml --- roles/sugarizer/tasks/main.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/roles/sugarizer/tasks/main.yml b/roles/sugarizer/tasks/main.yml index 07880c0f0..fe9b59108 100644 --- a/roles/sugarizer/tasks/main.yml +++ b/roles/sugarizer/tasks/main.yml @@ -95,6 +95,14 @@ - npm when: internet_available and (is_ubuntu_18 or not is_debuntu) +# 2018-07-15: TK Kang showed that "npm install" fails if run through sudo, with code EACCES, errno -13 (permission denied), "missing write access to /opt/iiab/sugarizer-server-1.0/node_modules" +- name: Change ownership of /root/.npm from iiab-admin to root + file: + path: /root/.npm + owner: root + group: root + recurse: yes + # 4. RUN "npm install" TO POPULATE ~35MB /opt/iiab/sugarizer-server/node_modules # Re-running "npm install" USED TO fail on Raspbian 9 if not other OS's. From 3434452eab7cea5a97951dae62f16187464e4180 Mon Sep 17 00:00:00 2001 From: A Holt Date: Sun, 15 Jul 2018 01:33:35 -0400 Subject: [PATCH 2/6] Update main.yml --- roles/sugarizer/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/sugarizer/tasks/main.yml b/roles/sugarizer/tasks/main.yml index fe9b59108..af0fccb2f 100644 --- a/roles/sugarizer/tasks/main.yml +++ b/roles/sugarizer/tasks/main.yml @@ -95,7 +95,7 @@ - npm when: internet_available and (is_ubuntu_18 or not is_debuntu) -# 2018-07-15: TK Kang showed that "npm install" fails if run through sudo, with code EACCES, errno -13 (permission denied), "missing write access to /opt/iiab/sugarizer-server-1.0/node_modules" +# 2018-07-15: TK Kang showed that "npm install" fails if run through sudo, with code EACCES, errno -13 (permission denied), "Missing write access to /opt/iiab/sugarizer-server-1.0/node_modules" - name: Change ownership of /root/.npm from iiab-admin to root file: path: /root/.npm From 7cf000debcd704830a20d04815b9a8d0349eaca1 Mon Sep 17 00:00:00 2001 From: A Holt Date: Sun, 15 Jul 2018 01:38:19 -0400 Subject: [PATCH 3/6] Update main.yml --- roles/sugarizer/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/sugarizer/tasks/main.yml b/roles/sugarizer/tasks/main.yml index af0fccb2f..6abdfb7fb 100644 --- a/roles/sugarizer/tasks/main.yml +++ b/roles/sugarizer/tasks/main.yml @@ -96,7 +96,7 @@ when: internet_available and (is_ubuntu_18 or not is_debuntu) # 2018-07-15: TK Kang showed that "npm install" fails if run through sudo, with code EACCES, errno -13 (permission denied), "Missing write access to /opt/iiab/sugarizer-server-1.0/node_modules" -- name: Change ownership of /root/.npm from iiab-admin to root +- name: Change ownership of /root/.npm [from iiab-admin] to root file: path: /root/.npm owner: root From 162a367885cdcd1ff76458d82a2436cb32d0b26e Mon Sep 17 00:00:00 2001 From: A Holt Date: Sun, 15 Jul 2018 07:10:31 -0400 Subject: [PATCH 4/6] Update main.yml --- roles/sugarizer/tasks/main.yml | 37 ++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/roles/sugarizer/tasks/main.yml b/roles/sugarizer/tasks/main.yml index 6abdfb7fb..d6374c8d0 100644 --- a/roles/sugarizer/tasks/main.yml +++ b/roles/sugarizer/tasks/main.yml @@ -95,25 +95,14 @@ - npm when: internet_available and (is_ubuntu_18 or not is_debuntu) -# 2018-07-15: TK Kang showed that "npm install" fails if run through sudo, with code EACCES, errno -13 (permission denied), "Missing write access to /opt/iiab/sugarizer-server-1.0/node_modules" -- name: Change ownership of /root/.npm [from iiab-admin] to root - file: - path: /root/.npm - owner: root - group: root - recurse: yes - # 4. RUN "npm install" TO POPULATE ~35MB /opt/iiab/sugarizer-server/node_modules -# Re-running "npm install" USED TO fail on Raspbian 9 if not other OS's. -# Several strategies to avoid re-running it: +# Re-running "npm install" USED TO fail on Raspbian 9 if not other OS's? +# Strategies considered to avoid re-running it: # OLD WAY 1: test & set flag node_modules_exists: True # OLD WAY 2: "creates: ..." checks for non-existence of /opt/iiab/sugarizer-server-1.0/node_modules # OLD WAY 3: set "register: git_sug_server_output" above, then as nec delete /opt/iiab/sugarizer-server-1.0/node_modules "when: git_sug_server_output.changed" and as nec run "npm install" -# NEW WAY: run "npm install" every time, as modern versions of npm are -# incremental, with sanity checks (as tested with npm 3.5.2 and 5.6.0) - #- name: Check for /opt/iiab/{{ sugarizer_server_version }}/node_modules # stat: # path: "{{ sugarizer_location }}/{{ sugarizer_server_version }}/node_modules" @@ -125,9 +114,27 @@ # node_modules_exists: True # when: nmtest.stat is defined and nmtest.stat.exists +# NEW WAY BELOW: run "npm install --allow-root" every time, as modern versions +# of npm are incremental, with sanity checks (all 3 may work: but npm 6.2.0 +# is better than 5.6.0 better than 3.5.2 + +# 2018-07-15: TK Kang & Holt confirmed sudo-driven "npm install" maxes out CPU +# for hours. Error code EACCES, errno -13 (permission denied): +# "Missing write access to /opt/iiab/sugarizer-server-1.0/node_modules" +# +# SOLUTION: +# Implemented '--allow-root' below, as is critical for 1st run of sudo-driven +# 'npm install' (causing it to create /root/.npm cache & lock files owned by +# root:root instead of iiab-admin:iiab-admin) permitting it and IIAB install +# scripts toactually complete :) +# +# CLARIF: something like 'chown -R root:root /root/.npm' cannot happen +# synchronously with the 1st run of 'npm install' (when it's needed!) +# nor is 'chown' functionality nec, now that --allow-root does the job) + #- name: Create the express framework for Node.js (OS's other than Fedora 18) -- name: Run 'npm install' to create /opt/iiab/{{ sugarizer_server_version }}/node_modules (CAN TAKE SEVERAL MINUTES) - command: npm install # slightly safer than "shell:" +- name: Run 'npm install --allow-root' to create /opt/iiab/{{ sugarizer_server_version }}/node_modules (CAN TAKE SEVERAL MINUTES) + command: npm install --allow-root # "command:" a bit safer than "shell:" args: chdir: "{{ sugarizer_location }}/{{ sugarizer_server_version }}" #creates: "{{ sugarizer_location }}/{{ sugarizer_server_version }}/node_modules" # OLD WAY 2 From 095d9b6caa26429ca04e618b795ae7fb7ce406d2 Mon Sep 17 00:00:00 2001 From: A Holt Date: Sun, 15 Jul 2018 07:16:50 -0400 Subject: [PATCH 5/6] Update main.yml --- roles/sugarizer/tasks/main.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/roles/sugarizer/tasks/main.yml b/roles/sugarizer/tasks/main.yml index d6374c8d0..d2b9f4cff 100644 --- a/roles/sugarizer/tasks/main.yml +++ b/roles/sugarizer/tasks/main.yml @@ -116,21 +116,20 @@ # NEW WAY BELOW: run "npm install --allow-root" every time, as modern versions # of npm are incremental, with sanity checks (all 3 may work: but npm 6.2.0 -# is better than 5.6.0 better than 3.5.2 +# is better than 5.6.0. which is better than Ubuntu 18.04's 3.5.2). # 2018-07-15: TK Kang & Holt confirmed sudo-driven "npm install" maxes out CPU -# for hours. Error code EACCES, errno -13 (permission denied): +# for hours, on diff OS's. Error code EACCES, errno -13 (permission denied): # "Missing write access to /opt/iiab/sugarizer-server-1.0/node_modules" # -# SOLUTION: -# Implemented '--allow-root' below, as is critical for 1st run of sudo-driven -# 'npm install' (causing it to create /root/.npm cache & lock files owned by -# root:root instead of iiab-admin:iiab-admin) permitting it and IIAB install -# scripts toactually complete :) +# SOLUTION: Implement '--allow-root' below, as is critical for 1st run of +# sudo-driven 'npm install' (causing it to create /root/.npm cache & lock +# files owned by root:root instead of iiab-admin:iiab-admin) permitting it +# and IIAB install scripts to actually complete :) # # CLARIF: something like 'chown -R root:root /root/.npm' cannot happen # synchronously with the 1st run of 'npm install' (when it's needed!) -# nor is 'chown' functionality nec, now that --allow-root does the job) +# Nor is 'chown' functionality nec, now that --allow-root does the job. #- name: Create the express framework for Node.js (OS's other than Fedora 18) - name: Run 'npm install --allow-root' to create /opt/iiab/{{ sugarizer_server_version }}/node_modules (CAN TAKE SEVERAL MINUTES) From b5822f1213845a5f60d2a4a3c4e5a5d735539d37 Mon Sep 17 00:00:00 2001 From: A Holt Date: Sun, 15 Jul 2018 07:22:49 -0400 Subject: [PATCH 6/6] Update main.yml --- roles/sugarizer/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/sugarizer/tasks/main.yml b/roles/sugarizer/tasks/main.yml index d2b9f4cff..7fe312ca3 100644 --- a/roles/sugarizer/tasks/main.yml +++ b/roles/sugarizer/tasks/main.yml @@ -97,7 +97,7 @@ # 4. RUN "npm install" TO POPULATE ~35MB /opt/iiab/sugarizer-server/node_modules -# Re-running "npm install" USED TO fail on Raspbian 9 if not other OS's? +# Re-running "npm install" USED TO fail on Raspbian 9 if not other OS's ? # Strategies considered to avoid re-running it: # OLD WAY 1: test & set flag node_modules_exists: True # OLD WAY 2: "creates: ..." checks for non-existence of /opt/iiab/sugarizer-server-1.0/node_modules