Webpack error when deploying Rails 6 app on elastic beanstalk with npm, yarn and webpack - npm

I tried to deploy my Rails 6 app that's running stable on production (!) into a second new environment on elastic beanstalk (eb) and I cannot get it to run despite just copying the configuration from the first setup.
After researching all resources I could find for 2 days, I'm currently stuck with the following error compilation failed: webpack not installed:
-------------------------------------
/var/log/eb-activity.log
-------------------------------------
+++ export RUBY_VERSION=2.6.5
+++ RUBY_VERSION=2.6.5
+++ export GEM_ROOT=/opt/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0
+++ GEM_ROOT=/opt/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0
++ (( 0 != 0 ))
+ /opt/elasticbeanstalk/support/scripts/check-for-gem.rb puma
+ echo true
[2020-01-09T20:22:02.966Z] INFO [1508] - [Application update app-f4fb-200109_211455#11/AppDeployStage0/AppDeployPreHook] : Completed activity. Result:
Successfully execute hooks in directory /opt/elasticbeanstalk/hooks/appdeploy/pre.
[2020-01-09T20:22:02.966Z] INFO [1508] - [Application update app-f4fb-200109_211455#11/AppDeployStage0/EbExtensionPostBuild] : Starting activity...
[2020-01-09T20:22:10.381Z] INFO [1508] - [Application update app-f4fb-200109_211455#11/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild] : Starting activity...
[2020-01-09T20:22:10.462Z] INFO [1508] - [Application update app-f4fb-200109_211455#11/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_XXX] : Starting activity...
[2020-01-09T20:22:23.059Z] INFO [1508] - [Application update app-f4fb-200109_211455#11/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_XXX/Command 01_restart_nginx] : Starting activity...
[2020-01-09T20:22:24.293Z] INFO [1508] - [Application update app-f4fb-200109_211455#11/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_XXX/Command 01_restart_nginx] : Completed activity. Result:
nginx: [warn] conflicting server name "_" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "localhost" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "localhost" on 0.0.0.0:80, ignored
Stopping nginx: [ OK ]
Starting nginx: nginx: [warn] conflicting server name "_" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "localhost" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "localhost" on 0.0.0.0:80, ignored
[ OK ]
[2020-01-09T20:22:24.293Z] INFO [1508] - [Application update app-f4fb-200109_211455#11/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_XXX] : Completed activity.
[2020-01-09T20:22:24.375Z] INFO [1508] - [Application update app-f4fb-200109_211455#11/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_1_XXX] : Starting activity...
[2020-01-09T20:22:37.045Z] INFO [1508] - [Application update app-f4fb-200109_211455#11/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_1_XXX/Command 10_install_webpack] : Starting activity...
[2020-01-09T20:25:12.155Z] INFO [1508] - [Application update app-f4fb-200109_211455#11/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_1_XXX/Command 10_install_webpack] : Completed activity. Result:
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.11 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
+ webpack#4.41.5
added 322 packages from 197 contributors and audited 4227 packages in 144.209s
3 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
[2020-01-09T20:25:13.256Z] INFO [1508] - [Application update app-f4fb-200109_211455#11/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_1_XXX/Command 11_precompile] : Starting activity...
[2020-01-09T20:30:24.349Z] INFO [1508] - [Application update app-f4fb-200109_211455#11/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_1_XXX/Command 11_precompile] : Activity execution failed, because: yarn install v1.21.1
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents#1.2.9: The platform "linux" is incompatible with this module.
info "fsevents#1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 162.47s.
yarn install v1.21.1
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents#1.2.9: The platform "linux" is incompatible with this module.
info "fsevents#1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 83.51s.
I, [2020-01-09T20:29:36.608192 #2970] INFO -- : Writing /var/app/ondeck/public/assets/manifest-cadda289ef9c70eaa0879a36e6263cb33f7523a16b3ef862e0b8609cdc2bdab1.js
I, [2020-01-09T20:29:36.609243 #2970] INFO -- : Writing /var/app/ondeck/public/assets/manifest-cadda289ef9c70eaa0879a36e6263cb33f7523a16b3ef862e0b8609cdc2bdab1.js.gz
I, [2020-01-09T20:29:36.609422 #2970] INFO -- : Writing /var/app/ondeck/public/assets/XXX-c0be3de839559053bb0a9486d5645ccba7a7452f6ef0370ee498e1fa59e364b2.png
I, [2020-01-09T20:29:36.609592 #2970] INFO -- : Writing /var/app/ondeck/public/assets/XXX-469a46bb9645a42d499c7f74ee69ffad4176e08c4373b6fe67a418e8289f3d83.png
I, [2020-01-09T20:29:36.609775 #2970] INFO -- : Writing /var/app/ondeck/public/assets/XXX-e57001fd85a8e1f4da2bb4bbd309a7d880a9d18e3447d743190ff9befb86413f.jpg
I, [2020-01-09T20:29:36.610062 #2970] INFO -- : Writing /var/app/ondeck/public/assets/application-e18be23bdc9236e71700193c31376705b918eab0738fdd68ef83e572da76c13d.css
I, [2020-01-09T20:29:36.610155 #2970] INFO -- : Writing /var/app/ondeck/public/assets/application-e18be23bdc9236e71700193c31376705b918eab0738fdd68ef83e572da76c13d.css.gz
I, [2020-01-09T20:29:36.610249 #2970] INFO -- : Writing /var/app/ondeck/public/assets/wall_street-e57001fd85a8e1f4da2bb4bbd309a7d880a9d18e3447d743190ff9befb86413f.jpg
I, [2020-01-09T20:29:36.610500 #2970] INFO -- : Writing /var/app/ondeck/public/assets/asset-d0ff5974b6aa52cf562bea5921840c032a860a91a3512f7fe8f768f6bbe005f6.css
I, [2020-01-09T20:29:36.610582 #2970] INFO -- : Writing /var/app/ondeck/public/assets/asset-d0ff5974b6aa52cf562bea5921840c032a860a91a3512f7fe8f768f6bbe005f6.css.gz
I, [2020-01-09T20:29:36.690087 #2970] INFO -- : Writing /var/app/ondeck/public/assets/XXX-d0ff5974b6aa52cf562bea5921840c032a860a91a3512f7fe8f768f6bbe005f6.css
I, [2020-01-09T20:29:36.690356 #2970] INFO -- : Writing /var/app/ondeck/public/assets/XXX-d0ff5974b6aa52cf562bea5921840c032a860a91a3512f7fe8f768f6bbe005f6.css.gz
I, [2020-01-09T20:29:36.690743 #2970] INFO -- : Writing /var/app/ondeck/public/assets/main-e18be23bdc9236e71700193c31376705b918eab0738fdd68ef83e572da76c13d.css
I, [2020-01-09T20:29:36.690957 #2970] INFO -- : Writing /var/app/ondeck/public/assets/main-e18be23bdc9236e71700193c31376705b918eab0738fdd68ef83e572da76c13d.css.gz
I, [2020-01-09T20:29:36.691548 #2970] INFO -- : Writing /var/app/ondeck/public/assets/round-d0ff5974b6aa52cf562bea5921840c032a860a91a3512f7fe8f768f6bbe005f6.css
I, [2020-01-09T20:29:36.772944 #2970] INFO -- : Writing /var/app/ondeck/public/assets/round-d0ff5974b6aa52cf562bea5921840c032a860a91a3512f7fe8f768f6bbe005f6.css.gz
Compiling...
Compilation failed:
webpack not installed
Install webpack to start bundling: [32m
$ npm install --save-dev webpack
(ElasticBeanstalk::ExternalInvocationError)
[2020-01-09T20:30:24.349Z] INFO [1508] - [Application update app-f4fb-200109_211455#11/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_1_XXX/Command 11_precompile] : Activity failed.
[2020-01-09T20:30:24.349Z] INFO [1508] - [Application update app-f4fb-200109_211455#11/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_1_XXX] : Activity failed.
[2020-01-09T20:30:24.349Z] INFO [1508] - [Application update app-f4fb-200109_211455#11/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild] : Activity failed.
[2020-01-09T20:30:25.008Z] INFO [1508] - [Application update app-f4fb-200109_211455#11/AppDeployStage0/EbExtensionPostBuild] : Activity failed.
[2020-01-09T20:30:25.008Z] INFO [1508] - [Application update app-f4fb-200109_211455#11/AppDeployStage0] : Activity failed.
[2020-01-09T20:30:25.009Z] INFO [1508] - [Application update app-f4fb-200109_211455#11] : Completed activity. Result:
Application update - Command CMD-AppDeploy failed
[2020-01-09T20:36:59.175Z] INFO [5013] - [CMD-TailLogs] : Starting activity...
[2020-01-09T20:36:59.175Z] INFO [5013] - [CMD-TailLogs/AddonsBefore] : Starting activity...
[2020-01-09T20:36:59.175Z] INFO [5013] - [CMD-TailLogs/AddonsBefore] : Completed activity.
[2020-01-09T20:36:59.175Z] INFO [5013] - [CMD-TailLogs/TailLogs] : Starting activity...
[2020-01-09T20:36:59.175Z] INFO [5013] - [CMD-TailLogs/TailLogs/TailLogs] : Starting activity...
-------------------------------------
/var/log/eb-commandprocessor.log
-------------------------------------
[2020-01-09T20:15:53.363Z] DEBUG [1508] : Retrieving metadata for key: AWS::ElasticBeanstalk::Ext||_API||_Commands..
[2020-01-09T20:15:53.364Z] INFO [1508] : Found enabled addons: ["logpublish", "logstreaming"].
[2020-01-09T20:15:53.444Z] INFO [1508] : Updating Command definition of addon logpublish.
[2020-01-09T20:15:53.444Z] INFO [1508] : Updating Command definition of addon logstreaming.
[2020-01-09T20:15:53.444Z] DEBUG [1508] : Retrieving metadata for key: AWS::CloudFormation::Init||Infra-WriteApplication2||files..
[2020-01-09T20:15:53.445Z] DEBUG [1508] : Retrieving metadata for key: AWS::ElasticBeanstalk::Ext||ManifestFileS3Key..
[2020-01-09T20:15:56.071Z] INFO [1508] : Loading manifest from bucket 'elasticbeanstalk-eu-west-1-511205900284' using computed S3 key 'resources/environments/e-zcsy2pgich/_runtime/versions/manifest_1578600905237'.
[2020-01-09T20:15:56.520Z] INFO [1508] : Updated manifest cache: deployment ID 11 and serial 18.
[2020-01-09T20:15:56.520Z] DEBUG [1508] : Loaded definition of Command CMD-AppDeploy.
[2020-01-09T20:15:56.520Z] INFO [1508] : Executing Application update
[2020-01-09T20:15:56.520Z] INFO [1508] : Executing command: CMD-AppDeploy...
[2020-01-09T20:15:56.520Z] INFO [1508] : Executing command CMD-AppDeploy activities...
[2020-01-09T20:15:56.520Z] DEBUG [1508] : Setting environment variables..
[2020-01-09T20:15:56.520Z] INFO [1508] : Running AddonsBefore for command CMD-AppDeploy...
[2020-01-09T20:15:59.632Z] DEBUG [1508] : Running stages of Command CMD-AppDeploy from stage 0 to stage 1...
[2020-01-09T20:15:59.632Z] INFO [1508] : Running stage 0 of command CMD-AppDeploy...
[2020-01-09T20:15:59.632Z] INFO [1508] : Running leader election...
[2020-01-09T20:16:07.059Z] INFO [1508] : Instance is Leader.
[2020-01-09T20:16:07.059Z] DEBUG [1508] : Loaded 5 actions for stage 0.
[2020-01-09T20:16:07.059Z] INFO [1508] : Running 1 of 5 actions: DownloadSourceBundle...
[2020-01-09T20:16:14.038Z] INFO [1508] : Running 2 of 5 actions: EbExtensionPreBuild...
[2020-01-09T20:18:12.566Z] INFO [1508] : Running 3 of 5 actions: AppDeployPreHook...
[2020-01-09T20:22:02.966Z] INFO [1508] : Running 4 of 5 actions: EbExtensionPostBuild...
[2020-01-09T20:30:25.008Z] ERROR [1508] : Command execution failed: Activity failed. (ElasticBeanstalk::ActivityFatalError)
caused by: yarn install v1.21.1
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents#1.2.9: The platform "linux" is incompatible with this module.
info "fsevents#1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 162.47s.
yarn install v1.21.1
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents#1.2.9: The platform "linux" is incompatible with this module.
info "fsevents#1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 83.51s.
I, [2020-01-09T20:29:36.608192 #2970] INFO -- : Writing /var/app/ondeck/public/assets/manifest-cadda289ef9c70eaa0879a36e6263cb33f7523a16b3ef862e0b8609cdc2bdab1.js
I, [2020-01-09T20:29:36.609243 #2970] INFO -- : Writing /var/app/ondeck/public/assets/manifest-cadda289ef9c70eaa0879a36e6263cb33f7523a16b3ef862e0b8609cdc2bdab1.js.gz
I, [2020-01-09T20:29:36.609422 #2970] INFO -- : Writing /var/app/ondeck/public/assets/XXX-c0be3de839559053bb0a9486d5645ccba7a7452f6ef0370ee498e1fa59e364b2.png
I, [2020-01-09T20:29:36.609592 #2970] INFO -- : Writing /var/app/ondeck/public/assets/XXX-469a46bb9645a42d499c7f74ee69ffad4176e08c4373b6fe67a418e8289f3d83.png
I, [2020-01-09T20:29:36.609775 #2970] INFO -- : Writing /var/app/ondeck/public/assets/XXX-e57001fd85a8e1f4da2bb4bbd309a7d880a9d18e3447d743190ff9befb86413f.jpg
I, [2020-01-09T20:29:36.610062 #2970] INFO -- : Writing /var/app/ondeck/public/assets/application-e18be23bdc9236e71700193c31376705b918eab0738fdd68ef83e572da76c13d.css
I, [2020-01-09T20:29:36.610155 #2970] INFO -- : Writing /var/app/ondeck/public/assets/application-e18be23bdc9236e71700193c31376705b918eab0738fdd68ef83e572da76c13d.css.gz
I, [2020-01-09T20:29:36.610249 #2970] INFO -- : Writing /var/app/ondeck/public/assets/XXX-e57001fd85a8e1f4da2bb4bbd309a7d880a9d18e3447d743190ff9befb86413f.jpg
I, [2020-01-09T20:29:36.610500 #2970] INFO -- : Writing /var/app/ondeck/public/assets/asset-d0ff5974b6aa52cf562bea5921840c032a860a91a3512f7fe8f768f6bbe005f6.css
I, [2020-01-09T20:29:36.610582 #2970] INFO -- : Writing /var/app/ondeck/public/assets/asset-d0ff5974b6aa52cf562bea5921840c032a860a91a3512f7fe8f768f6bbe005f6.css.gz
I, [2020-01-09T20:29:36.690087 #2970] INFO -- : Writing /var/app/ondeck/public/assets/XXX-d0ff5974b6aa52cf562bea5921840c032a860a91a3512f7fe8f768f6bbe005f6.css
I, [2020-01-09T20:29:36.690356 #2970] INFO -- : Writing /var/app/ondeck/public/assets/XXX-d0ff5974b6aa52cf562bea5921840c032a860a91a3512f7fe8f768f6bbe005f6.css.gz
I, [2020-01-09T20:29:36.690743 #2970] INFO -- : Writing /var/app/ondeck/public/assets/main-e18be23bdc9236e71700193c31376705b918eab0738fdd68ef83e572da76c13d.css
I, [2020-01-09T20:29:36.690957 #2970] INFO -- : Writing /var/app/ondeck/public/assets/main-e18be23bdc9236e71700193c31376705b918eab0738fdd68ef83e572da76c13d.css.gz
I, [2020-01-09T20:29:36.691548 #2970] INFO -- : Writing /var/app/ondeck/public/assets/round-d0ff5974b6aa52cf562bea5921840c032a860a91a3512f7fe8f768f6bbe005f6.css
I, [2020-01-09T20:29:36.772944 #2970] INFO -- : Writing /var/app/ondeck/public/assets/round-d0ff5974b6aa52cf562bea5921840c032a860a91a3512f7fe8f768f6bbe005f6.css.gz
Compiling...
Compilation failed:
webpack not installed
Install webpack to start bundling: [32m
$ npm install --save-dev webpack
(ElasticBeanstalk::ExternalInvocationError)
[2020-01-09T20:30:25.009Z] ERROR [1508] : Command CMD-AppDeploy failed!
[2020-01-09T20:30:25.086Z] INFO [1508] : Command processor returning results:
{"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"(TRUNCATED)...NFO -- : Writing /var/app/ondeck/public/assets/round-d0ff5974b6aa52cf562bea5921840c032a860a91a3512f7fe8f768f6bbe005f6.css.gz\nCompiling...\nCompilation failed:\n\nwebpack not installed\n\nInstall webpack to start bundling: \u001b[32m\n$ npm install --save-dev webpack. \ncontainer_command 11_precompile in .ebextensions/yarn.config failed. For more detail, check /var/log/eb-activity.log using console or EB CLI","returncode":1,"events":[]}],"truncated":"true"}
Logically, I tried to install webpack again and again which should be normally already be done through the ebextensions file yarn.config:
commands:
# 01_remove_clean_and_install_latest_nodejs:
# run this command from /tmp directory
# cwd: /tmp
# test: '[ -f /usr/bin/node ] && echo "remove previous node"'
# command: 'sudo yum remove -y nodejs | sudo rm /etc/yum.repos.d/nodesource*'
02_node_get:
# run this command from /tmp directory
cwd: /tmp
# flag -y for no-interaction installation
command: 'sudo curl --silent --location https://rpm.nodesource.com/setup_13.x | sudo bash -'
03_node_install:
# run this command from /tmp directory
cwd: /tmp
command: 'sudo yum -y install nodejs'
04_yarn_get:
# run this command from /tmp directory
cwd: /tmp
# don't run the command if yarn is already installed (file /usr/bin/yarn exists)
test: '[ ! -f /usr/bin/yarn ] && echo "yarn not installed"'
command: 'sudo wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo'
05_yarn_install:
# run this command from /tmp directory
cwd: /tmp
test: '[ ! -f /usr/bin/yarn ] && echo "yarn not installed"'
command: 'sudo yum -y install yarn'
06_mkdir_webapp_dir:
command: mkdir /home/webapp
ignoreErrors: true
07_chown_webapp_dir:
command: chown webapp:webapp /home/webapp
ignoreErrors: true
08_chmod_webapp_dir:
command: chmod 700 /home/webapp
ignoreErrors: true
09_update_bundler:
command: gem update bundler
ignoreErrors: true
container_commands:
10_install_webpack:
command: "sudo npm install --save-dev webpack"
11_precompile:
command: "bundle exec rake assets:precompile"
My other settings are RAILS_SKIP_ASSET_COMPILATION=true in eb
I tried installing webpack manually after ssh-ing into the machine via npm and yarn, with and without sudo, but nothing worked...
Each eb deploy takes roughly 20 mins and then times out into a "severe" state with the above error.
Edit
For some weird reason I got it to work now by running bundle exec rails webpacker:install in addition to having it in the Gemfile. Still not comfortable with the setup, but at least it's working for now

Update: We had two elasticsearch gems that were not being installed during bundle install but removing them from our gemfile allowed the deployment to go through. We noticed the issue locally as well with a bundle install that hung on "resolving dependencies" for about 4 hours, which is roughly how long it took our deployment to successfully go through. I'd start checking gems.
I'm not sure if this is related, but we have an open case with AWS support currently over a similar issue where deployments seemingly fail after hanging on some of AWS's own PreDeploy hook scripts (namely one that checks for Puma). We have been unable to successfully clone or deploy known working app code bundles to any new or existing instances. The issue started on the 7th of January, 2019.
AWS has since confirmed that the issue is on their end, but we have no remedy yet.
Sidenote: Code eventually will deploy after about 4 hours, but the instances all show degraded or error.

Related

CodeDeploy not properly copying code from GitHub

I have CodeDeploy pull code from my GitHub repo. In the deployment Commit ID (for GitHub) I have specified the Commit ID that I want to deploy. My repo has the following structure:
my-service/
README.md
.gitignore
scripts/
deploy.sh
src/
<lots of code here>
pm2.dev.json
appspec.yml
My appspec.yml file looks like:
version: 0.0
os: linux
files:
- source: /
destination: /home/ubuntu
hooks:
BeforeInstall:
- location: scripts/deploy.sh
timeout: 300
runas: root
My scripts/deploy.sh looks like:
sudo npm install pm2 -g
pwd
pm2 start /home/ubuntu/my-service/pm2.dev.json
When I run the CodeDeployment deployment for this, it fails with the following error:
Script at specified location: scripts/deploy.sh run as user root failed with exit code 1
When I look at the logs I see:
LifecycleEvent - BeforeInstall
Script - scripts/deploy.sh
[stderr]npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
[stdout]changed 182 packages, and audited 183 packages in 8s
[stdout]
[stdout]12 packages are looking for funding
[stdout] run `npm fund` for details
[stdout]
[stdout]found 0 vulnerabilities
[stdout]/opt/codedeploy-agent
[stderr][PM2][ERROR] File /home/ubuntu/my-service/pm2.dev.json not found
Sure enough when I look in /home/ubuntu/my-service, I do not see a pm2.dev.json file, because this server had been manually configured several weeks ago before a pm2.dev.json file was added to the project. I would have expected CodeDeploy to have written whats in the repo to the server under /home/ubuntu.
Can anyone spot anything wrong with my appspec.yml or other configuration? Could it be a bad GitHub setup?
Had to change BeforeInstall to Install.
BeforeInstall runs before it copies over the source code (specified under files/source). But Install run just after that copy occurs, hence files will be available on the file system.

Cypress E2E Testing VueJS with GitLab Runner returns 404 not found

I have the following simple GitLab CI file
stages:
- e2e_test
e2e_test:
stage: e2e_test
tags:
- test
script:
- npm config set strict-ssl false
- npm install
- npm run test:e2e:ci
I am running the above script in a shell runner for very specific corporate reasons.
This script results in a 404 error with the following log
npm run test:e2e:ci
> todo-app#0.1.0 test:e2e:ci /home/gitlab-runner/builds/UHz6XzwM/0/microservices-and-cognitive-solutions/demos/microservice-concept/todo-app
> vue-cli-service test:e2e --headless
INFO Starting e2e tests...
INFO Starting development server...
DONE Compiled successfully in 8865ms6:51:36 PM
App running at:
- Local: http://localhost:8083/
- Network: http://10.108.201.150:8083/
App is served in production mode.
Note this is for preview or E2E testing only.
====================================================================================================
(Run Starting)
tput: No value for $TERM and no -T specified
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 3.8.3 │
│ Browser: Electron 78 (headless) │
│ Specs: 1 found (test.js) │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: test.js (1 of 1)
Browserslist: caniuse-lite is outdated. Please run the following command: `npm update`
My First Test
1) Visits the app root url
0 passing (341ms)
1 failing
1) My First Test Visits the app root url:
CypressError: cy.visit() failed trying to load:
http://localhost:8083/
The response we received from your web server was:
> 404: Not Found
This was considered a failure because the status code was not '2xx'.
If you do not want status codes to cause failures pass the option: 'failOnStatusCode: false'
at Object.cypressErr (http://localhost:8083/__cypress/runner/cypress_runner.js:86207:11)
at Object.throwErr (http://localhost:8083/__cypress/runner/cypress_runner.js:86162:18)
at Object.throwErrByPath (http://localhost:8083/__cypress/runner/cypress_runner.js:86194:17)
at http://localhost:8083/__cypress/runner/cypress_runner.js:71493:31
at visitFailedByErr (http://localhost:8083/__cypress/runner/cypress_runner.js:71006:12)
at http://localhost:8083/__cypress/runner/cypress_runner.js:71474:22
at tryCatcher (http://localhost:8083/__cypress/runner/cypress_runner.js:120203:23)
at Promise._settlePromiseFromHandler (http://localhost:8083/__cypress/runner/cypress_runner.js:118139:31)
at Promise._settlePromise (http://localhost:8083/__cypress/runner/cypress_runner.js:118196:18)
at Promise._settlePromise0 (http://localhost:8083/__cypress/runner/cypress_runner.js:118241:10)
at Promise._settlePromises (http://localhost:8083/__cypress/runner/cypress_runner.js:118316:18)
at Async../node_modules/bluebird/js/release/async.js.Async._drainQueue (http://localhost:8083/__cypress/runner/cypress_runner.js:114928:16)
at Async../node_modules/bluebird/js/release/async.js.Async._drainQueues (http://localhost:8083/__cypress/runner/cypress_runner.js:114938:10)
at Async.drainQueues (http://localhost:8083/__cypress/runner/cypress_runner.js:114812:14)
If I clone the same repository on the same server and manually run the following commands in the terminal it works fine.
npm install
npm run test:e2e:ci
Any idea why the same commands would fail in a GitLab runner shell but working in a user shell
I found the problem to fix my issue. I needed to set a no_proxy environment entry in my gitlab-runner config.toml file. This won't affect everyone, but since i am behind a corporate proxy, I needed it.
export no_proxy="localhost"

create-react-app circle build failed

!/bin/bash -eo pipefail
yarn build
yarn run v1.6.0
$ react-scripts build
Creating an optimized production build...
Starting type checking and linting service...
Using 1 worker with 2048MB memory limit
events.js:183
throw er; // Unhandled 'error' event
^
Error: This socket has been ended by the other party
at Socket.writeAfterFIN [as write] (net.js:364:12)
at PoolWorker.writeJson (/home/circleci/repo/node_modules/thread-loader/dist/WorkerPool.js:89:22)
at PoolWorker.run (/home/circleci/repo/node_modules/thread-loader/dist/WorkerPool.js:69:12)
at WorkerPool.distributeJob (/home/circleci/repo/node_modules/thread-loader/dist/WorkerPool.js:326:20)
at /home/circleci/repo/node_modules/thread-loader/node_modules/async/queue.js:10:5
at Object.process (/home/circleci/repo/node_modules/thread-loader/node_modules/async/internal/queue.js:175:17)
at /home/circleci/repo/node_modules/thread-loader/node_modules/async/internal/queue.js:115:15
at /home/circleci/repo/node_modules/thread-loader/node_modules/async/internal/onlyOnce.js:12:16
at callback (/home/circleci/repo/node_modules/thread-loader/dist/WorkerPool.js:163:21)
at /home/circleci/repo/node_modules/thread-loader/dist/WorkerPool.js:190:15
at /home/circleci/repo/node_modules/thread-loader/node_modules/async/internal/map.js:32:9
at /home/circleci/repo/node_modules/thread-loader/node_modules/async/internal/once.js:12:16
at replenish (/home/circleci/repo/node_modules/thread-loader/node_modules/async/internal/eachOfLimit.js:61:25)
at iterateeCallback (/home/circleci/repo/node_modules/thread-loader/node_modules/async/internal/eachOfLimit.js:50:17)
at /home/circleci/repo/node_modules/thread-loader/node_modules/async/internal/onlyOnce.js:12:16
at /home/circleci/repo/node_modules/thread-loader/node_modules/async/internal/map.js:29:13
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Exited with code 1

Unable to install httpd service on chef client(node)

I am new to chef and following "Learning Chef" book from "O'Riely" to learn the chef basics.
In its chapter 07 they have described to install httpd service on chef client(node) from chef host using cookbook.
This is how my .kitchen.yaml file looks like :
---
driver:
name: vagrant
provisioner:
name: chef_zero
platforms:
- name: centos_apache
driver:
box: learningchef/centos65
boxurl: learningchef/centos65
suites:
- name: default
run_list:
- recipe[my_apache::default]
attributes:
The recipe for installing httpd service looks like :
#
# Cookbook Name:: my_apache
# Recipe:: default
#
# Copyright (c) 2015 The Authors, All Rights Reserved.
#
yum_package 'httpd' do
source "/home/vipul/Downloads/httpd-2.2.15-39.el6.centos.x86_64.rpm"
action :install
end
And this is the log which I get after executing the command "kitchen converge"
-----> Starting Kitchen (v1.4.0)
-----> Converging <default-centos-apache>...
Preparing files for transfer
Preparing dna.json
Preparing current project directory as a cookbook
Removing non-cookbook files before transfer
Preparing validation.pem
Preparing client.rb
-----> Chef Omnibus installation detected (install only if missing)
Transferring files to <default-centos-apache>
Starting Chef Client, version 12.4.0
[2015-07-08T12:56:06+00:00] WARN: Child with name 'dna.json' found in multiple directories: /tmp/kitchen/dna.json and /tmp/kitchen/dna.json
resolving cookbooks for run list: ["my_apache::default"]
Synchronizing Cookbooks:
- my_apache
Compiling Cookbooks...
Converging 1 resources
Recipe: my_apache::default
================================================================================
Error executing action `install` on resource 'yum_package[httpd]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of /usr/bin/python /opt/chef/embedded/apps/chef/lib/chef/provider/package/yum-dump.py --options --installed-provides --yum-lock-timeout 30 ----
STDOUT: [option installonlypkgs] kernel kernel-bigmem installonlypkg(kernel-module) installonlypkg(vm) kernel-enterprise kernel-smp kernel-debug kernel-unsupported kernel-source kernel-devel kernel-PAE kernel-PAE-debug
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os error was
14: PYCURL ERROR 7 - "Failed to connect to 2a02:2498:1:3d:5054:ff:fed3:e91a: Network is unreachable"
STDERR: yum-dump Repository Error: Cannot find a valid baseurl for repo: base
---- End output of /usr/bin/python /opt/chef/embedded/apps/chef/lib/chef/provider/package/yum-dump.py --options --installed-provides --yum-lock-timeout 30 ----
Ran /usr/bin/python /opt/chef/embedded/apps/chef/lib/chef/provider/package/yum-dump.py --options --installed-provides --yum-lock-timeout 30 returned 1
Resource Declaration:
---------------------
# In /tmp/kitchen/cache/cookbooks/my_apache/recipes/default.rb
8: yum_package 'httpd' do
9: source "/home/vipul/Downloads/httpd-2.2.15-39.el6.centos.x86_64.rpm"
10: action :install
11: end
Compiled Resource:
------------------
# Declared in /tmp/kitchen/cache/cookbooks/my_apache/recipes/default.rb:8:in `from_file'
yum_package("httpd") do
action :install
retries 0
retry_delay 2
default_guard_interpreter :default
package_name "httpd"
source "/home/vipul/Downloads/httpd-2.2.15-39.el6.centos.x86_64.rpm"
flush_cache {:before=>false, :after=>false}
declared_type :yum_package
cookbook_name "my_apache"
recipe_name "default"
end
Running handlers:
[2015-07-08T12:56:14+00:00] ERROR: Running exception handlers
Running handlers complete
[2015-07-08T12:56:14+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 11.596431753 seconds
[2015-07-08T12:56:14+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
[2015-07-08T12:56:14+00:00] ERROR: yum_package[httpd] (my_apache::default line 8) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /usr/bin/python /opt/chef/embedded/apps/chef/lib/chef/provider/package/yum-dump.py --options --installed-provides --yum-lock-timeout 30 ----
STDOUT: [option installonlypkgs] kernel kernel-bigmem installonlypkg(kernel-module) installonlypkg(vm) kernel-enterprise kernel-smp kernel-debug kernel-unsupported kernel-source kernel-devel kernel-PAE kernel-PAE-debug
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os error was
14: PYCURL ERROR 7 - "Failed to connect to 2a02:2498:1:3d:5054:ff:fed3:e91a: Network is unreachable"
STDERR: yum-dump Repository Error: Cannot find a valid baseurl for repo: base
---- End output of /usr/bin/python /opt/chef/embedded/apps/chef/lib/chef/provider/package/yum-dump.py --options --installed-provides --yum-lock-timeout 30 ----
Ran /usr/bin/python /opt/chef/embedded/apps/chef/lib/chef/provider/package/yum-dump.py --options --installed-provides --yum-lock-timeout 30 returned 1
[2015-07-08T12:56:14+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
>>>>>> Converge failed on instance <default-centos-apache>.
>>>>>> Please see .kitchen/logs/default-centos-apache.log for more details
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: SSH exited (1) for command: [sh -c '
sudo -E /opt/chef/bin/chef-client --local-mode --config /tmp/kitchen/client.rb --log_level auto --force-formatter --no-color --json-attributes /tmp/kitchen/dna.json --chef-zero-port 8889
']
>>>>>> ----------------------
I want to install httpd service using the local rpm package. Chef client is already installed on the virtual machine.
I have tried various steps, but getting same output always.
Update: So I did yum update in my host and client both.
After that the output log changed.. I says that it couldn't find the package at defined source, while it is present there. Please suggest::
-----> Starting Kitchen (v1.4.0)
-----> Converging <default-centos-apache>...
Preparing files for transfer
Preparing dna.json
Preparing current project directory as a cookbook
Removing non-cookbook files before transfer
Preparing validation.pem
Preparing client.rb
-----> Chef Omnibus installation detected (install only if missing)
Transferring files to <default-centos-apache>
Starting Chef Client, version 12.4.0
[2015-07-09T14:16:57+00:00] WARN: Child with name 'dna.json' found in multiple directories: /tmp/kitchen/dna.json and /tmp/kitchen/dna.json
resolving cookbooks for run list: ["my_apache::default"]
Synchronizing Cookbooks:
- my_apache
Compiling Cookbooks...
Converging 1 resources
Recipe: my_apache::default
================================================================================
Error executing action `install` on resource 'yum_package[httpd]'
================================================================================
Chef::Exceptions::Package
-------------------------
Package httpd not found: /home/vipul/Downloads/httpd-2.2.15-39.el6.centos.x86_64.rpm
Resource Declaration:
---------------------
# In /tmp/kitchen/cache/cookbooks/my_apache/recipes/default.rb
8: package "httpd" do
9: source "/home/vipul/Downloads/httpd-2.2.15-39.el6.centos.x86_64.rpm"
10: action :install
11: end
Compiled Resource:
------------------
# Declared in /tmp/kitchen/cache/cookbooks/my_apache/recipes/default.rb:8:in `from_file'
yum_package("httpd") do
action :install
retries 0
retry_delay 2
default_guard_interpreter :default
package_name "httpd"
source "/home/vipul/Downloads/httpd-2.2.15-39.el6.centos.x86_64.rpm"
flush_cache {:before=>false, :after=>false}
declared_type :package
cookbook_name "my_apache"
recipe_name "default"
end
Running handlers:
[2015-07-09T14:17:01+00:00] ERROR: Running exception handlers
Running handlers complete
[2015-07-09T14:17:01+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 6.822340816 seconds
[2015-07-09T14:17:01+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
[2015-07-09T14:17:01+00:00] ERROR: yum_package[httpd] (my_apache::default line 8) had an error: Chef::Exceptions::Package: Package httpd not found: /home/vipul/Downloads/httpd-2.2.15-39.el6.centos.x86_64.rpm
[2015-07-09T14:17:01+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
>>>>>> Converge failed on instance <default-centos-apache>.
>>>>>> Please see .kitchen/logs/default-centos-apache.log for more details
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: SSH exited (1) for command: [sh -c '
sudo -E /opt/chef/bin/chef-client --local-mode --config /tmp/kitchen/client.rb --log_level auto --force-formatter --no-color --json-attributes /tmp/kitchen/dna.json --chef-zero-port 8889
']
>>>>>> ----------------------
Might want to try following the steps outlined here if you can't work out your proxy/network issues. http://xmodulo.com/how-to-fix-yum-errors-on-centos-rhel-or-fedora.html
Regards,
The answer to the problem is in comments of question,by Mark.
Hence just pasting it here.
Terminal proxies are not enough. Kitchen is running chef client within a virtual machine. See: docs.chef.io/config_yml_kitchen.html#work-with-proxies

Vagrant - Ansible error installing Apache

I'm working on a project with Vagrant and Ansible and Virtualbox.
When I try to install Apache on an ubuntu precise (14.04) box, Vagrant fails. I improved the answer after.
It seems a known bug, but even if I'm installing a newer version, the error shows up.
I tried also as stated here, but with no luck.
How can I resolve this issue?
Thank you.
UPDATED ANSWER
This is the Ansible task.
Version 1:
- name: Install Apache
sudo: yes
apt: pkg=apache2 state=latest
register: apache2_apt
Output:
failed: [default] => {"failed": true}
stderr: E: Sub-process /usr/bin/dpkg returned an error code (1)
stdout: Reading package lists...
Building dependency tree...
Reading state information...
Suggested packages:
www-browser apache2-doc apache2-suexec-pristine apache2-suexec-custom
The following NEW packages will be installed:
apache2
0 upgraded, 1 newly installed, 0 to remove and 183 not upgraded.
Need to get 0 B/146 kB of archives.
After this operation, 460 kB of additional disk space will be used.
(Reading database ... 52932 files and directories currently installed.)
Unpacking apache2 (from .../apache2_2.4.12-1+deb.sury.org~precise+5_amd64.deb) ...
dpkg: error processing /var/cache/apt/archives/apache2_2.4.12-1+deb.sury.org~precise+5_amd64.deb (--unpack):
error setting ownership of `/var/www/html.dpkg-new': Operation not permitted
Processing triggers for man-db ...
Processing triggers for ureadahead ...
Errors were encountered while processing:
/var/cache/apt/archives/apache2_2.4.12-1+deb.sury.org~precise+5_amd64.deb
msg: '/usr/bin/apt-get -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" install 'apache2'' failed: E: Sub-process /usr/bin/dpkg returned an error code (1)
FATAL: all hosts have already failed -- aborting
Version 2:
- name: Install Apache
command: "sudo apt-get install apache2"
register: apache2_apt
Output:
failed: [default] => {"changed": true, "cmd": ["sudo", "apt-get", "install", "apache2"], "delta": "0:00:07.745095", "end": "2015-06-09 11:08:53.726031", "rc": 100, "start": "2015-06-09 11:08:45.980936", "warnings": []}
stderr: E: Sub-process /usr/bin/dpkg returned an error code (1)
stdout: Reading package lists...
Building dependency tree...
Reading state information...
Suggested packages:
www-browser apache2-doc apache2-suexec-pristine apache2-suexec-custom
The following NEW packages will be installed:
apache2
0 upgraded, 1 newly installed, 0 to remove and 183 not upgraded.
Need to get 0 B/146 kB of archives.
After this operation, 460 kB of additional disk space will be used.
(Reading database ... 52932 files and directories currently installed.)
Unpacking apache2 (from .../apache2_2.4.12-1+deb.sury.org~precise+5_amd64.deb) ...
dpkg: error processing /var/cache/apt/archives/apache2_2.4.12-1+deb.sury.org~precise+5_amd64.deb (--unpack):
error setting ownership of `/var/www/html.dpkg-new': Operation not permitted
Processing triggers for man-db ...
Processing triggers for ureadahead ...
ureadahead will be reprofiled on next reboot
Errors were encountered while processing:
/var/cache/apt/archives/apache2_2.4.12-1+deb.sury.org~precise+5_amd64.deb
FATAL: all hosts have already failed -- aborting
There are few possible issues for this
You need to disable apparmor or better add a rule to apparmor service for ability to have access by the script to /var/www within guest machine
There is a trouble with host machine permissions for /var/www folder. Try to check if the user has access to local folder, mapped as shared folder from host to guest - possibly you need to add permissions for local user at host machine.
try to use ansible-galaxy and search for already created role with fixes for both previous issues