Ansible2.2 npm moduleでexecutableが効かないエラー | onox blog

onox blog

Ansible2.2 npm moduleでexecutableが効かないエラー

January 17, 2019

ansible 2.2.1.0にて、npmモジュールのexecutableオプションが効かなった時の対処法を記載する

  • エラー内容抜粋
ValueError: No JSON object could be decoded
"module_stdout": "", "msg": "MODULE FAILURE"

環境

ansible: 2.2.1.0
nodejs: 10.15.0

対処法

Npm module gives errors · Issue #29240 · ansible/ansibleを参考に、environmentオプションを利用することで突破した。ansibleのバージョン起因かどうかは不明だが、今後も代替策として使える。

- name: Install yarn to global
  become: true
  npm:
    name: yarn
    global: yes
    # executable: "/home/{{ app.user }}/.nodebrew/current/bin/npm" > not working
  environment:
    PATH: "/home/{{ app.user }}/.nodebrew/current/bin:{{ ansible_env.PATH }}"