Shaheen Ahmad
Shaheen Ahmad

Reputation: 41

Ansible - using npm with a proxy

I have this Ansible code:

- name: Installing project files
  shell: |
    cd /opt/ewd-server
    npm install
  become_user: prod-{{SITE}}

Every time I run the code and it reaches that part it keeps saying that the server doesn't have the proxy up. Even thought I executed 2 commands before that:

npm config set https-proxy
npm config set proxy

The values are actually the companies IP's, but redacted for obvious reasons.

The code keeps running until it reaches the 'npm install' task, stays for about half an hour, then Ansible gives the error 'ENOENT'.

NOTE: when I run the npm install command in the server without Ansible it works.

If anyone knows any replacement for npm that works with Ansible, or a solution for this issue please help.

Upvotes: 4

Views: 630

Answers (1)

Kevin C
Kevin C

Reputation: 5750

Try configuring the environment variables 'http_proxy' and 'https_proxy':

 - name: Installing project files, using a specific proxy
     shell: |
              cd /opt/ewd-server
              npm install
     become_user: prod-{{SITE}}
     environment:
       http_proxy: http://proxy.adres
       https_proxy: http://proxy.adres

Of course, edit the proxy values.

Upvotes: 2

Related Questions