Curl Exec lein with Centup Vagrant上的Puppet没有这样的文件或目录

时间:2015-09-23 23:39:14

标签: clojure centos vagrant puppet leiningen

修改

这个sites.pp似乎有效。

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],
  }
}

我试图使用Puppet在Centos Vagrant上安装lein。

要安装lein,只需运行脚本即可。我尝试使用curl下载脚本,使其可执行,然后执行它,但我得到no such file or directory。我已经确认文件/usr/local/bin/lein存在,所以不确定我为什么会收到错误。

所以我想要完成的就是这个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

另外一方面,是否可以将exec作为非特权用户运行?

木偶/表现/ 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

3 个答案:

答案 0 :(得分:1)

  

另外一方面,是否可以将exec作为非特权用户运行?

是的,您可以在块中添加用户

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

答案 1 :(得分:0)

更为简单的说明:你试过滚边吗?

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'],
  }
}

答案 2 :(得分:0)

我通过删除两个exec的路径并使用命令的绝对路径来实现它。 lein也需要HOME环境设置,否则它会尝试将文件下载到/.lein并且需要以流浪汉的形式运行

成功 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