summaryrefslogtreecommitdiff
path: root/provisioning/modules/pixelated/manifests/source/install_useragent.pp
blob: 0b19eeb307fcfa6a8653cf411335dbc62c8c0881 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# install useragent in a virtualenv, deploy helper script
# and make sure venv is activated on login
class pixelated::source::install_useragent {

  $virtualenv_path = '/home/vagrant/.venvs/pixua'

  exec { 'install-pixelated':
    # use of "user" parameter doesn't set env variables right,
    # see https://projects.puppetlabs.com/issues/23053
    # therefore we need to explicitily set them here
    environment => [ 'USERNAME=vagrant', 'HOME=/home/vagrant' ],
    command     => "/vagrant/install-pixelated.sh -v \"${virtualenv_path}\" -n /home/vagrant/boxed_node_modules",
    cwd         => '/vagrant',
    user        => 'vagrant',
    # to debug use this
    # logoutput   => true,
    timeout     => 0
  }

  file { '/home/vagrant/activate_custom_node_modules.sh':
    owner  => 'vagrant',
    mode   => '0755',
    source => 'puppet:///modules/pixelated/activate_custom_node_modules.sh',
  }

  exec { 'add_custom_node_modules_to_bashrc':
    command => "/bin/bash -c 'echo \"source ${virtualenv_path}/bin/activate\" >> /home/vagrant/.bashrc'",
    unless  => "/bin/grep \"source ${virtualenv_path}/bin/activate\" /home/vagrant/.bashrc",
    user    => 'vagrant',
    require => [Exec['install-pixelated'], File['/home/vagrant/activate_custom_node_modules.sh']]
  }
  exec { 'add_custom_node_path_to_bashrc':
    command => "/bin/bash -c 'echo NODE_PATH=/home/vagrant/boxed_node_modules/node_modules/ >> /home/vagrant/.bashrc'",
    unless  => "/bin/grep NODE_PATH /home/vagrant/.bashrc",
    user    => 'vagrant',
  }
}