Reputation: 2257
EDIT
This sites.pp seems to work.
class lein {
$lein = "/usr/local/bin/lein"
$url = 'https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein'
exec { 'download lein':
command => "/usr/bin/curl -sL -o ${lein} ${url}",
creates => $lein,
}
file { $lein:
mode => '0755',
require => Exec['download lein'],
}
exec { 'install lein':
command => $lein,
require => File[$lein],
}
}
I'm trying to install lein on a Centos Vagrant using Puppet.
To install lein you just run the script. I'm trying to dowload the script with curl, make it executable and then executing it but I'm getting no such file or directory
. I have verified that the file /usr/local/bin/lein
exists, so not sure why I'm getting the error.
So what I'm trying to accomplish is the puppet equivalent of this shell:
curl -sL -o /usr/local/bin/lein https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein
chmod 0755 /usr/bin/local/lein
/usr/local/bin/lein
Also on a side note, is it possible to run exec as a non-privileged user?
puppet/manifests/site.pp
class lein {
exec { 'download lein':
command => 'curl -sL -o /usr/local/bin/lein https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein',
path => '/usr/bin',
}
file { '/usr/local/bin/lein':
mode => '0755',
require => Exec['download lein'],
}
exec { 'install lein':
command => 'lein',
path => '/usr/local/bin',
require => File['/usr/local/bin/lein'],
}
}
Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "puphpet/centos65-x64"
config.vm.provision "puppet" do |p|
p.module_path = "puppet/modules"
p.manifests_path = "puppet/manifests"
p.manifest_file = "site.pp"
end
end
Upvotes: 0
Views: 605
Reputation: 2257
I got it to work by removing the path to both execs and using absolute paths for the commands. Also lein needs the HOME environment set or else it will try and download files to /.lein and it needs to be ran as vagrant
Successful sites.pp
class { 'jdk_oracle': }class lein {
$lein = "/usr/local/bin/lein"
$url = 'https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein'
$leinhome = '/home/vagrant'
exec { 'download lein':
command => "/usr/bin/curl -sL -o ${lein} ${url}",
creates => $lein,
require => Class['jdk_oracle']
}
file { $lein:
mode => '0755',
require => Exec['download lein'],
}
exec { 'install lein':
environment => ["HOME=${leinhome}"],
command => $lein,
require => File[$lein],
creates => "${leinhome}/.lein/self-installs/leiningen-2.5.3-standalone.jar",
user => 'vagrant',
}
}
include jdk_oracle
include lein
Upvotes: 0
Reputation: 53713
Also on a side note, is it possible to run exec as a non-privileged user?
Yes, you can, add the user in your block
class lein {
$lein = "/usr/local/bin/lein"
$url = 'https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein'
exec { 'download lein':
command => "/usr/bin/curl -sL -o ${lein} ${url}",
creates => $lein,
user => "vagrant";
}
file { $lein:
mode => '0755',
require => Exec['download lein'],
}
exec { 'install lein':
command => $lein,
require => File[$lein],
user => "vagrant";
}
}
include lein
Upvotes: 1
Reputation: 4012
On a much simpler note: have you tried piping?
class lein {
$command = 'curl -sL https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein | bash -s install'
package { 'curl':
ensure => 'installed',
}
exec { 'download lein':
command => $command,
path => $::path,
require => Package['curl'],
}
}
Upvotes: 0