Revert "Use "make install" to install useragent from source"
[pixelated-user-agent.git] / provisioning / modules / pixelated / manifests / source / install_useragent.pp
1 # install useragent in a virtualenv, deploy helper script
2 # and make sure venv is activated on login
3 class pixelated::source::install_useragent {
4
5   $virtualenv_path = '/home/vagrant/.venvs/pixua'
6
7   exec { 'install-pixelated':
8     # use of "user" parameter doesn't set env variables right,
9     # see https://projects.puppetlabs.com/issues/23053
10     # therefore we need to explicitily set them here
11     environment => [ 'USERNAME=vagrant', 'HOME=/home/vagrant' ],
12     command     => "/vagrant/install-pixelated.sh -v \"${virtualenv_path}\" -n /home/vagrant/boxed_node_modules",
13     cwd         => '/vagrant',
14     user        => 'vagrant',
15     # to debug use this
16     # logoutput   => true,
17     timeout     => 0
18   }
19
20   file { '/home/vagrant/activate_custom_node_modules.sh':
21     owner  => 'vagrant',
22     mode   => '0755',
23     source => 'puppet:///modules/pixelated/activate_custom_node_modules.sh',
24   }
25
26   exec { 'add_custom_node_modules_to_bashrc':
27     command => "/bin/bash -c 'echo \"source ${virtualenv_path}/bin/activate\" >> /home/vagrant/.bashrc'",
28     unless  => "/bin/grep \"source ${virtualenv_path}/bin/activate\" /home/vagrant/.bashrc",
29     user    => 'vagrant',
30     require => [Exec['install-pixelated'], File['/home/vagrant/activate_custom_node_modules.sh']]
31   }
32   exec { 'add_custom_node_path_to_bashrc':
33     command => "/bin/bash -c 'echo NODE_PATH=/home/vagrant/boxed_node_modules/node_modules/ >> /home/vagrant/.bashrc'",
34     unless  => '/bin/grep NODE_PATH /home/vagrant/.bashrc',
35     user    => 'vagrant',
36   }
37   exec { 'add_rule_to_change_to_vagrant_folder_on_login':
38     command => "/bin/echo 'cd /vagrant' >> /home/vagrant/.bashrc",
39     unless  => "/bin/grep 'cd /vagrant' /home/vagrant/.bashrc",
40     user    => 'vagrant',
41   }
42 }