0

I'm trying to run a nodejs script from ansible-playbook from AWX. the command works fine in regular cli, but when I run it from the playbook it fails!

ansible version:

ansible 2.5.1
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.15+ (default, Nov 27 2018, 23:36:35) [GCC 7.3.0]

here's the latest trail of the playbook:

---
- name: create a new domain in Digital Ocean.
  hosts: localhost
  connection: local
  tasks:
  - name: create a new domain in Digital Ocean.
    shell: "/var/lib/awx/projects/MY_USERNAME/modules/new-domain.js --name={{client_url|quote}} --ip={{server_ip|quote}}"
    args:
      executable: /usr/bin/node

thank you

AsimNet
  • 61
  • 1
  • 9

1 Answers1

0

The executable argument actually changes your shell, which is not what you want to do in your case. Just try:

  tasks:
  - name: create a new domain in Digital Ocean.
    shell: "/usr/bin/node /var/lib/awx/projects/MY_USERNAME/modules/new-domain.js --name={{client_url|quote}} --ip={{server_ip|quote}}"
Matt P
  • 2,452
  • 1
  • 12
  • 15
  • I already tried that, here's what I got: `/bin/sh: /usr/bin/node: No such file or directory` @matt-p – AsimNet Aug 05 '19 at 06:46
  • Why not use the ansible module to create domain ? https://docs.ansible.com/ansible/latest/modules/digital_ocean_domain_module.html – tux Aug 05 '19 at 06:56
  • @AsimNet then nodejs is either not installed, or it is installed in a different location. As tux mentioned though there is probably a better way to achieve what you want – Matt P Aug 05 '19 at 23:54
  • that's great! thank you!. when I run `which node` from the playbook, I got this result: `which: no node in (/var/lib/awx/venv/ansible/bin:/var/lib/awx/venv/awx/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)` – AsimNet Aug 06 '19 at 10:32