ansible / ansible-modules-extras

Ansible extra modules - these modules ship with ansible
947 stars 1.46k forks source link

npm module fails on OS X #1347

Closed anthonygreen closed 7 years ago

anthonygreen commented 8 years ago
Issue Type:

Bug Report

Component Name:

npm module

Ansible Version:

Ansible 2.0.0 (stable-2.0)

Environment:

OS X 10.9.5 Python 2.7.11

Summary:

Ansible npm_module doesn't work on OS X

Steps To Reproduce:

This task fails

- npm: name=appium global=yes executable=/usr/local/bin/npm 
Expected Results:

ssh into the machine and running

/usr/local/bin/npm install -g appium

does work

Actual Results:
TASK [appium : npm executable=/usr/local/bin/npm global=yes name=appium] *******
task path: /Users/test/ansible/roles/appium/tasks/main.yml:8
<earth> ESTABLISH SSH CONNECTION FOR USER: ansible
<earth> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 -o ControlPath=/Users/test/.ansible/cp/ansible-ssh-%h-%p-%r -tt earth ( umask 22 && mkdir -p "$( echo $HOME/.ansible/tmp/ansible-tmp-1449589290.97-103049231967831 )" && echo "$( echo $HOME/.ansible/tmp/ansible-tmp-1449589290.97-103049231967831 )" )
<earth> PUT /var/folders/sm/vgbwtrps3yv2yl79n43t_f916ldxgl/T/tmpps7GAn TO /Users/ansible/.ansible/tmp/ansible-tmp-1449589290.97-103049231967831/npm
<earth> SSH: EXEC sftp -b - -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 -o ControlPath=/Users/test/.ansible/cp/ansible-ssh-%h-%p-%r [earth]
<earth> ESTABLISH SSH CONNECTION FOR USER: ansible
<earth> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 -o ControlPath=/Users/test/.ansible/cp/ansible-ssh-%h-%p-%r -tt earth LANG=en_GB.UTF-8 LC_ALL=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8 /usr/bin/python /Users/ansible/.ansible/tmp/ansible-tmp-1449589290.97-103049231967831/npm; rm -rf "/Users/ansible/.ansible/tmp/ansible-tmp-1449589290.97-103049231967831/" > /dev/null 2>&1
fatal: [earth]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_args": {"executable": "/usr/local/bin/npm", "global": "yes", "name": "appium"}, "module_name": "npm"}, "msg": "Traceback (most recent call last):\r\n  File \"/Users/ansible/.ansible/tmp/ansible-tmp-1449589290.97-103049231967831/npm\", line 2188, in <module>\r\n    main()\r\n  File \"/Users/ansible/.ansible/tmp/ansible-tmp-1449589290.97-103049231967831/npm\", line 245, in main\r\n    installed, missing = npm.list()\r\n  File \"/Users/ansible/.ansible/tmp/ansible-tmp-1449589290.97-103049231967831/npm\", line 169, in list\r\n    data = json.loads(self._exec(cmd, True, False))\r\n  File \"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py\", line 338, in loads\r\n    return _default_decoder.decode(s)\r\n  File \"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py\", line 366, in decode\r\n    obj, end = self.raw_decode(s, idx=_w(s, 0).end())\r\n  File \"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py\", line 384, in raw_decode\r\n    raise ValueError(\"No JSON object could be decoded\")\r\nValueError: No JSON object could be decoded\r\nOpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011\ndebug1: Reading configuration data /etc/ssh_config\r\ndebug1: /etc/ssh_config line 20: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 29940\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to earth closed.\r\n", "parsed": false}

PLAY RECAP *********************************************************************
earth                      : ok=16   changed=5    unreachable=0    failed=1   

Is this connected to https://github.com/ansible/ansible/issues/12982 ?

fubarhouse commented 8 years ago

I have also come across this as being a problem on RedHat, and I'm using version 2.1.0.0. For me though, I haven't experienced this problem on Darwin.

clegganator259 commented 8 years ago

I have also had this problem on OSX

johnelliott commented 8 years ago

@anthonygreen I also have this problem on OSX El Capitan using the most recent version of Ansbile installed via homebrew. The npm module gives this error related to JSON parsing. Initially found the issue you mentioned.

fatal: [host]: FAILED! => {"changed": false, "failed": true, "module_stderr": "", "module_stdout": "\r\nTraceback (most recent call last):\r\n  File \"/tmp/ansible_XNQzXM/ansible_module_npm.py\", line 269, in <module>\r\n    main()\r\n  File \"/tmp/ansible_XNQzXM/ansible_module_npm.py\", line 249, in main\r\n    installed, missing = npm.list()\r\n  File \"/tmp/ansible_XNQzXM/ansible_module_npm.py\", line 173, in list\r\n    data = json.loads(self._exec(cmd, True, False))\r\n  File \"/usr/lib/python2.7/json/__init__.py\", line 338, in loads\r\n    return _default_decoder.decode(s)\r\n  File \"/usr/lib/python2.7/json/decoder.py\", line 366, in decode\r\n    obj, end = self.raw_decode(s, idx=_w(s, 0).end())\r\n  File \"/usr/lib/python2.7/json/decoder.py\", line 384, in raw_decode\r\n    raise ValueError(\"No JSON object could be decoded\")\r\nValueError: No JSON object could be decoded\r\n", "msg": "MODULE FAILURE", "parsed": false}
bentruyman commented 8 years ago

What version of npm are you all using? You're likely running into npm/npm#8807. If you can upgrade to a more recent version of npm, it may resolve it for you. If you're stuck on early v3 or v2, you might be stuck using the shell module to "manually" install modules.

ansibot commented 8 years ago

@shane-walker, ping. This issue is still waiting on your response. click here for bot help

ansibot commented 8 years ago

@shane-walker, ping. This issue is still waiting on your response. click here for bot help

ansibot commented 7 years ago

@shane-walker, ping. This issue is still waiting on your response. click here for bot help

ansibot commented 7 years ago

@shane-walker, ping. This issue is still waiting on your response. click here for bot help

ansibot commented 7 years ago

@shane-walker, ping. This issue is still waiting on your response. click here for bot help

ansibot commented 7 years ago

This repository has been locked. All new issues and pull requests should be filed in https://github.com/ansible/ansible

Please read through the repomerge page in the dev guide. The guide contains links to tools which automatically move your issue or pull request to the ansible/ansible repo.

ansibot commented 7 years ago

This issue was migrated to https://github.com/ansible/ansible/issues/29248