Question

I use Vagrant + puppet

There is init.pp

class { 'apt':
  always_apt_update    => true,
  proxy_host           => 'some.proxy',
  proxy_port           => '222'
}

apt::ppa { 'ppa:chris-lea/node.js':  }

package {
  [
    'nodejs'
  ]:
  ensure => "installed",
  require => Apt::Ppa['ppa:chris-lea/node.js']
}

exec { 'npm_proxy':
  command => 'npm config set proxy http://some.proxy:222',
  path => '/usr/bin/:/bin/',
  require => Package['nodejs'],
}

Seems OK. Command has executed successfully. But when I connect to box (vagrant ssh) npm proxy is null...

Was it helpful?

Solution

Probably the npm proxy has been set for root.

Puppet runs with root credentials, while vagrant ssh logs you in as vagrant user. So if you want to run the command for vagrant you should specify it:

exec { 'npm_proxy':
  command => 'npm config set proxy http://some.proxy:222',
  path => '/usr/bin/:/bin/',
  require => Package['nodejs'],
  user => 'vagrant'
}

Another option could be to set the npm proxy globally with the --global flag.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top