Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem: qa/1.7.x branch error on role dependency (geerlingguy.nodejs) #151

Open
hakamine opened this issue Nov 24, 2017 · 5 comments
Open

Comments

@hakamine
Copy link
Member

Getting an error like this when the role dependency is executing:

TASK [geerlingguy.nodejs : Create npm global directory] ********************************************************
...
    "mode": "0755",
    "msg": "chown failed: failed to look up user hector",
    "owner": "root",
    "path": "/usr/local/lib/npm",
    "size": 4096,
    "state": "directory",
    "uid": 0
}
@hakamine
Copy link
Member Author

hakamine commented Nov 25, 2017

This happens due to a bug in https://github.com/geerlingguy/ansible-role-nodejs/blob/4.1.1/tasks/main.yml#L8-L11 :

- name: Define nodejs_install_npm_user
  set_fact:
    nodejs_install_npm_user: "{{ ansible_user | default(lookup('env', 'USER')) }}"
  when: nodejs_install_npm_user is not defined

In recent versions of ansible (testing with 2.3.x) ansible_user is not defined (being replaced by ansible_user_id) so nodejs_install_npm_user is assigned the user on the ansible control machine. This fails if we are using a different user in the ansible target machine.

It's worth noting that this problem does not happen when doing a vagrant deployment using the archivematica playbook in deploy-pub (https://github.com/artefactual/deploy-pub/tree/master/playbooks/archivematica), but will likely happen when doing deployments when the ansible control machine and target machine are different.

Workaround is to assign ansible_user_id to nodejs_install_npm_user in the playbook vars, for example when invoking the archivematica-src playbook:

    - { role: "external-roles/artefactual.archivematica-src", 
        tags: ["archivematica-src"], 
        become: yes, 
        nodejs_install_npm_user: "{{ ansible_user_id }}"
        }

@hakamine
Copy link
Member Author

Fixed in #153, by adding a note to the README with a workaround

@sevein
Copy link
Member

sevein commented Nov 28, 2017

Have you considered submitting a PR to the original repo by geerlingguy?

@hakamine
Copy link
Member Author

hakamine commented Nov 28, 2017

Just submitted this PR: geerlingguy/ansible-role-nodejs#75
Also, related reading: ansible/ansible#23530

@sevein
Copy link
Member

sevein commented Nov 28, 2017

Way to go!!! @hakamine thanks

misilot added a commit to misilot/ansible-archivematica-src that referenced this issue Mar 29, 2021
Resolves Issue artefactual-labs#151 until it can be fixed upstream
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants