简体   繁体   English

如何通过Vagrant和Puppet安装RVM

[英]How to Install RVM via Vagrant and Puppet

I'm provisioning a new Vagrant box for Ruby on Rails development (using VirtualBox) and would like to add RVM + ruby 2.3.0 as part of the Vagrant provisioning process. 我正在为Ruby on Rails开发(使用VirtualBox)预配一个新的Vagrant框,并希望在Vagrant预配过程中添加RVM + ruby​​ 2.3.0。

My Vagrantfile: 我的Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
  config.vm.box = "ubuntu/trusty64"

  config.vm.network "forwarded_port", guest: 3000, host: 3000

  config.vm.provision :puppet do |puppet|
    puppet.manifests_path = "puppet/manifests"
    puppet.module_path    = "puppet/modules"
    puppet.manifest_file  = "development.pp"
  end

end

And puppet/manifests/development.pp: 和puppet / manifests / development.pp:

class requirements {
  group { "puppet": ensure => "present", }
  exec { "apt-update":
    command => "/usr/bin/apt-get -y update"
  }

  package {
    ["mysql-client", "mysql-server", "libmysqlclient-dev"]: 
      ensure => installed, require => Exec['apt-update']
  }
}

include requirements

This just installs mysql at the moment. 目前,这仅安装mysql。 I'd like to add RVM + install a default ruby (2.3.0 for example). 我想添加RVM +安装默认的ruby(例如2.3.0)。

There is this guide: http://blog.csanchez.org/2014/01/14/installing-rvm-and-multiple-ruby-versions-with-puppet/ 有此指南: http : //blog.csanchez.org/2014/01/14/installing-rvm-and-multiple-ruby-versions-with-puppet/

Which uses this puppet module: https://forge.puppetlabs.com/maestrodev/rvm 哪个使用此人偶模块: https : //forge.puppetlabs.com/maestrodev/rvm

I don't have puppet installed, because when I try to run: 我没有安装木偶,因为当我尝试运行时:

puppet module install maestrodev-rvm

I get "-bash: puppet: command not found". 我得到“ -bash:puppet:命令未找到”。

Looking through the Puppet docs, it appears rather complicated to install/setup a Puppet client/server. 查看Puppet文档,安装/设置Puppet客户端/服务器似乎相当复杂。 This seems like overkill just to use the RVM puppet module. 仅使用RVM人偶模块似乎有点过头了。 Also, designers on the team will be using this process so it needs to be as simple as possible. 同样,团队中的设计师将使用此过程,因此它需要尽可能简单。

Any help would be greatly appreciated. 任何帮助将不胜感激。

I don't have puppet installed 我没有安装木偶

Yes, you do - puppet is installed on your VM, otherwise you would not be able to provision mysql and other. 是的,您可以-虚拟机上已安装了puppet,否则您将无法置备mysql等。

You probably run the command puppet module install maestrodev-rvm from your host, while this needs to be run on the VM. 您可能从主机运行命令puppet module install maestrodev-rvm命令,而这需要在VM上运行。

There are different ways how people have the modules setup on the VM (librarian, some downloads all in module/ folder...) what I do is to create a shell provisioning which will install all the necessary modules. 人们在虚拟机上设置模块的方式有多种(图书馆员,有些下载全部在module /文件夹中...)我要做的是创建将安装所有必需模块的shell配置。 In your vagrantfile add 在您的vagrantfile中添加

config.vm.provision "shell", path: "puppet/script/install-puppet-modules.sh"

make sure this line is before your puppet provision - the install-puppet-modules.sh will be something like 确保此行在您的人偶设置之前-install-puppet-modules.sh将类似于

#!/bin/bash

mkdir -p /etc/puppet/modules;

if [ ! -d /etc/puppet/modules/maestrodev/rvm ]; then
  puppet module install maestrodev-rvm --version xxx
fi

I like to make a point to the version so if there's a new version of the module in the forge it might break, at least I know that version xxx has been tested. 我想指出一个版本,因此如果伪造模块中有一个新版本,它可能会崩溃,至少我知道xxx版本已经过测试。

So now you're able to add class { 'rvm': } and so on to install rvm and ruby in your puppet/manifests/development.pp file 因此,现在您可以添加class { 'rvm': }等,以在您的puppet/manifests/development.pp文件中安装rvm和ruby

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM