I am using ansible to setup a node project on my EC2 instance. I am using npm module
to install npm modules. The issue which I am facing is that my ansible script is failing to do so exactly 50% of the time. So every alternative time it will fail on the same step wth the same exact playbook.
This is my playbook
---
- hosts: test
gather_facts: false
tasks:
- name: clear map files from /tmp
shell: rm /tmp/*.map
become: yes
ignore_errors: yes
- name: remove /home/ubuntu/app dir
file:
path: /home/ubuntu/app
state: absent
- name: clone github repo
git:
accept_hostkey: yes
repo: git@github.com:test_company/app.git
dest: /home/ubuntu/app
version: master
- name: install npm packages
npm:
path: /home/ubuntu/app
register: node_module
ignore_errors: yes
- debug: var=node_module
- name: start node app
shell: cd /home/ubuntu/app && pm2 kill && pm2 flush && npm start
My playbook fails on install npm packages
step. This is the output i get in debug task
TASK [debug] *******************************************************************
ok: [localhost] => {
"node_module": {
"changed": false,
"cmd": "/usr/bin/npm install",
"failed": true,
"msg": "",
"rc": -9,
"stderr": "npm WARN deprecated node-uuid@1.4.8: Use uuid module instead\n",
"stdout": "\n> unix-dgram@0.2.3 install /home/ubuntu/app/node_modules/unix-dgram\n> node-gyp rebuild\n\nmake: Entering directory '/home/ubuntu/app/node_modules/unix-dgram/build'\n CXX(target) Release/obj.target/unix_dgram/src/unix_dgram.o\n SOLINK_MODULE(target) Release/obj.target/unix_dgram.node\n COPY Release/unix_dgram.node\nmake: Leaving directory '/home/ubuntu/app/node_modules/unix-dgram/build'\n\n> sharp@0.17.3 install /home/ubuntu/app/node_modules/sharp\n> node-gyp rebuild\n\nmake: Entering directory '/home/ubuntu/app/node_modules/sharp/build'\n TOUCH Release/obj.target/libvips-cpp.stamp\n CXX(target) Release/obj.target/sharp/src/common.o\n CXX(target) Release/obj.target/sharp/src/metadata.o\n CXX(target) Release/obj.target/sharp/src/operations.o\n CXX(target) Release/obj.target/sharp/src/pipeline.o\n",
"stdout_lines": [
"",
"> unix-dgram@0.2.3 install /home/ubuntu/app/node_modules/unix-dgram",
"> node-gyp rebuild",
"",
"make: Entering directory '/home/ubuntu/app/node_modules/unix-dgram/build'",
" CXX(target) Release/obj.target/unix_dgram/src/unix_dgram.o",
" SOLINK_MODULE(target) Release/obj.target/unix_dgram.node",
" COPY Release/unix_dgram.node",
"make: Leaving directory '/home/ubuntu/app/node_modules/unix-dgram/build'",
"",
"> sharp@0.17.3 install /home/ubuntu/app/node_modules/sharp",
"> node-gyp rebuild",
"",
"make: Entering directory '/home/ubuntu/app/node_modules/sharp/build'",
" TOUCH Release/obj.target/libvips-cpp.stamp",
" CXX(target) Release/obj.target/sharp/src/common.o",
" CXX(target) Release/obj.target/sharp/src/metadata.o",
" CXX(target) Release/obj.target/sharp/src/operations.o",
" CXX(target) Release/obj.target/sharp/src/pipeline.o"
]
}
}
While when the task succeed then I get this output in debug statement
TASK [debug] *******************************************************************
ok: [localhost] => {
"node_module": {
"changed": true
}
}
I tried using the shell moduele and it gave the same result. On the other hand if i run npm i
command manually then i am getting no errors and modules are installing properly. I have no clue why is this failing every alternative time.
via shivams
No comments:
Post a Comment