geerlingguy / ansible-role-nodejs

Ansible Role - Node.js

Home Page:https://galaxy.ansible.com/geerlingguy/nodejs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Running yarn through ansible gives: "[Errno 2] No such file or directory"

pconerly opened this issue · comments

I'm installing yarn with the geerlingguy.nodejs package, but I'm running into a problem. My deploy task was previously working, but it's not working on newly provisioned machines on digitalocean.

The bug output:

TASK [deploy : get yarn version] ****************************************************************
fatal: [165.227.4.56]: FAILED! => {"changed": false, "cmd": "yarn --version", "msg": "[Errno 2] No such file or directory", "rc": 2}
fatal: [138.197.212.150]: FAILED! => {"changed": false, "cmd": "yarn --version", "msg": "[Errno 2] No such file or directory", "rc": 2}

When I manually log onto the machine and run yarn --version or yarn install it works just fine. Running which yarn gives me: /usr/local/lib/npm/bin/yarn, which is what's expected for the geerlingguy.nodejs's install location.

Here's my setup:
deployment.yaml

---
- name: 'Deploy webs to production'
  any_errors_fatal: true
  hosts: web
  vars:
    nodejs_version: '10.x'
    nodejs_npm_global_packages:
      - name: yarn
      - name: pm2

  environment:
    NODE_ENV: '{{ webdiff_env }}'
  roles:
    - geerlingguy.nodejs
    - { role: deploy }

a line in deploy/tasks/main.yml

   - name: 'get yarn version'
     command: "yarn --version"
     register: yarnversion

   - debug: msg="{{ yarnversion }}"

Sorry if this isn't an issue with the geerlingguy package!

I've fixed this by changing all of the instances of command: yarn to command: /usr/local/lib/npm/bin/yarn but it feels bad :-/

commented

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.

commented

This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.