Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Puppet 流浪汉;傀儡配置失败_Puppet_Vagrant - Fatal编程技术网

Puppet 流浪汉;傀儡配置失败

Puppet 流浪汉;傀儡配置失败,puppet,vagrant,Puppet,Vagrant,我第一次尝试使用Vagrant+Puppet配置脚本来改进我的开发工作流程 我目前正在尝试为L4开发设置一个开发框,并且正在使用and 按照说明: 克隆灯箱: git clone git://github.com/paolooo/vagrant-lamp.git lamp cd lamp 添加傀儡配置脚本: git submodule add https://github.com/paolooo/puppet-laravel.git extras/modules/laravel 然后更新子模

我第一次尝试使用Vagrant+Puppet配置脚本来改进我的开发工作流程

我目前正在尝试为L4开发设置一个开发框,并且正在使用and

按照说明:

克隆灯箱:

git clone git://github.com/paolooo/vagrant-lamp.git lamp
cd lamp
添加傀儡配置脚本:

git submodule add https://github.com/paolooo/puppet-laravel.git extras/modules/laravel
然后更新子模块:

git submodule update --init --recursive
到目前为止很好-简单的东西

现在准备好运行
vagrant up
——这似乎可以很好地配置VM,并引导它

然而,我的问题似乎是从init.pp脚本运行时开始的。当
apt-get
运行时,我得到了很多404

我的第一个想法是网络接口可能已经关闭了,但是查看日志后,
mysql客户端
download工作正常(我想)

我在OSX和Windows机器上试过这个

任何帮助都将不胜感激——我不想在第一关就摔倒

我的木偶剧本:

# Default path
Exec { path => ['/usr/bin', '/bin', '/usr/sbin', '/sbin', '/usr/local/bin', '/usr/local/sbin', '/opt/local/bin'] }
exec { 'apt-get update':
  command => '/usr/bin/apt-get update --fix-missing',
  require => Exec['add php54 apt-repo']
}

# Configuration
if $db_name == '' { $db_name = 'development' }
if $db_location == '' { $db_location  = '/vagrant/db/development.sqlite' }
if $username == '' { $username = 'root' }
if $password == '' { $password = '123' }
if $host == '' { $host = 'localhost' }

# Setup

## PHP
include php54
class { 'php': version => latest, }

## APACHE2
include apache
class {'apache::mod::php': }

## PACKAGES
## 'vim','curl','unzip','git','php5-mysql','php5-sqlite','php5-mcrypt','php5-memcache',
## 'php5-suhosin','php5-xsl','php5-tidy','php5-dev','php5-pgsql','php5-odbc', 'php5-ldap','php5-xmlrpc','php5-intl','php5-fpm'
package { ['vim','curl','unzip','git','php5-mcrypt','php5-memcached']:
  ensure  => installed,
  require => Exec['apt-get update'],
}

package { ['php5-mysql','php5-sqlite']:
  ensure  => installed,
  require => Exec['apt-get update'],
}

include pear
include composer

### Apache
apache::vhost { $fqdn:
  priority  => '20',
  port => '80',
  docroot => $docroot,
  logroot => $docroot, # access_log and error_log
  configure_firewall  => false,
}
a2mod { 'rewrite': ensure => present }

## Ruby
class { "ruby": 
  gems_version => "latest"
}

## Nodejs
class { "nodejs": }

## PHP MODULES
php::module { ['curl', 'gd']:
  notify  => [ Service['httpd'], ],
}

## PEAR
pear::package { "PEAR": }
pear::package { "PHPUnit": 
  version     => "latest",
  repository  => "pear.phpunit.de",
  require     => Pear::Package["PEAR"],
}
pear::package { "Yaml": 
  version     => "latest",
  repository  => "pear.symfony.com",
  require     => Pear::Package["PEAR"]
}

## DB
### MySQL
class { 'mysql::server':
  config_hash => { 'root_password' => "${password}" }
}
class { 'mysql': }
mysql::db { "${db_name}":
  user  => "${username}",
  password  => "${password}",
  host  =>  "${host}",
  grant => ['all'],
  charset => 'utf8',
}

### PostgreSQL
class { 'postgresql':
  version => 'latest',
}
class { 'postgresql::server': }
postgresql::db { "${db_name}":
  owner => "${username}",
  password  => "${password}",
}

### SQLite Config
class { 'sqlite': }
define sqlite::db(
    $location   = '',
    $owner      = 'root',
    $group      = 0,
    $mode       = '755',
    $ensure     = present,
    $sqlite_cmd = 'sqlite3'
  ) {

      file { $safe_location:
        ensure  => $ensure,
        owner   => $owner,
        group   => $group,
        notify  => Exec['create_development_db']
      }

      exec { 'create_development_db':
        command     => "${sqlite_cmd} $db_location",
        path        => '/usr/bin:/usr/local/bin',
        refreshonly => true,
      }
  }

## phpmyadmin
class { 'phpmyadmin': } 
我的流浪汉档案:

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

Vagrant::Config.run do |config|
  # All Vagrant configuration is done here. The most common configuration
  # options are documented and commented below. For a complete reference,
  # please see the online documentation at vagrantup.com.

  # Every Vagrant virtual environment requires a box to build off of.
  config.vm.box = "precise32"

  # The url from where the 'config.vm.box' box will be fetched if it
  # doesn't already exist on the user's system.
  config.vm.box_url = "http://files.vagrantup.com/precise32.box"

  # Boot with a GUI so you can see the screen. (Default is headless)
  # config.vm.boot_mode = :gui

  # Assign this VM to a host-only network IP, allowing you to access it
  # via the IP. Host-only networks can talk to the host machine as well as
  # any other machines on the same network, but cannot be accessed (through this
  # network interface) by any external networks.
  config.vm.network :hostonly, "192.168.33.10"

  # Assign this VM to a bridged network, allowing you to connect directly to a
  # network using the host's network device. This makes the VM appear as another
  # physical device on your network.
  # config.vm.network :bridged

  # Forward a port from the guest to the host, which allows for outside
  # computers to access the VM, whereas host only networking does not.
  config.vm.forward_port 80, 8082

  # Share an additional folder to the guest VM. The first argument is
  # an identifier, the second is the path on the guest to mount the
  # folder, and the third is the path on the host to the actual folder.
  config.vm.share_folder "v-data", "/vagrant/db", "./db"
  config.vm.share_folder "v-web", "/vagrant/www", "c:\\www"

  # Enable provisioning with Puppet stand alone.  Puppet manifests
  # are contained in a directory path relative to this Vagrantfile.
  # You will need to create the manifests directory and a manifest in
  # the file base.pp in the manifests_path directory.
  #
  # An example Puppet manifest to provision the message of the day:
  #
  # # group { "puppet":
  # #   ensure => "present",
  # # }
  # #
  # # File { owner => 0, group => 0, mode => 0644 }
  # #
  # # file { '/etc/motd':
  # #   content => "Welcome to your Vagrant-built virtual machine!
  # #               Managed by Puppet.\n"
  # # }
  #
  config.vm.provision :puppet do |puppet|
    puppet.facter = {
      "fqdn"      => "dev.lamp.mysql",
      "hostname"  => "www",
      "docroot"   => "/vagrant/www",
      "host"      => 'localhost',
      "username"  => 'root',
      "password"  => '123',
      "db_name"   => "development",
      "db_location" => "/vagrant/db/development.sqlite"
    }
    puppet.manifests_path = "puppet/manifests"
    puppet.module_path = ["puppet/modules", "extras/modules"]
    puppet.manifest_file  = "init.pp"
  end

  # Enable provisioning with chef solo, specifying a cookbooks path, roles
  # path, and data_bags path (all relative to this Vagrantfile), and adding 
  # some recipes and/or roles.
  #
  # config.vm.provision :chef_solo do |chef|
  #   chef.cookbooks_path = "../my-recipes/cookbooks"
  #   chef.roles_path = "../my-recipes/roles"
  #   chef.data_bags_path = "../my-recipes/data_bags"
  #   chef.add_recipe "mysql"
  #   chef.add_role "web"
  #
  #   # You may also specify custom JSON attributes:
  #   chef.json = { :mysql_password => "foo" }
  # end

  # Enable provisioning with chef server, specifying the chef server URL,
  # and the path to the validation key (relative to this Vagrantfile).
  #
  # The Opscode Platform uses HTTPS. Substitute your organization for
  # ORGNAME in the URL and validation key.
  #
  # If you have your own Chef Server, use the appropriate URL, which may be
  # HTTP instead of HTTPS depending on your configuration. Also change the
  # validation key to validation.pem.
  #
  # config.vm.provision :chef_client do |chef|
  #   chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
  #   chef.validation_key_path = "ORGNAME-validator.pem"
  # end
  #
  # If you're using the Opscode platform, your validator client is
  # ORGNAME-validator, replacing ORGNAME with your organization name.
  #
  # IF you have your own Chef Server, the default validation client name is
  # chef-validator, unless you changed the configuration.
  #
  #   chef.validation_client_name = "ORGNAME-validator"
end
config.vm.provision :shell, :inline => "apt-get update --fix-missing"

问题似乎是正在执行apt get update注释,不确定为什么会出现这种情况,因为我的傀儡脚本似乎已正确配置为调用它

但是,我通过在我的Vagrant文件中添加以下行来解决此问题:

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

Vagrant::Config.run do |config|
  # All Vagrant configuration is done here. The most common configuration
  # options are documented and commented below. For a complete reference,
  # please see the online documentation at vagrantup.com.

  # Every Vagrant virtual environment requires a box to build off of.
  config.vm.box = "precise32"

  # The url from where the 'config.vm.box' box will be fetched if it
  # doesn't already exist on the user's system.
  config.vm.box_url = "http://files.vagrantup.com/precise32.box"

  # Boot with a GUI so you can see the screen. (Default is headless)
  # config.vm.boot_mode = :gui

  # Assign this VM to a host-only network IP, allowing you to access it
  # via the IP. Host-only networks can talk to the host machine as well as
  # any other machines on the same network, but cannot be accessed (through this
  # network interface) by any external networks.
  config.vm.network :hostonly, "192.168.33.10"

  # Assign this VM to a bridged network, allowing you to connect directly to a
  # network using the host's network device. This makes the VM appear as another
  # physical device on your network.
  # config.vm.network :bridged

  # Forward a port from the guest to the host, which allows for outside
  # computers to access the VM, whereas host only networking does not.
  config.vm.forward_port 80, 8082

  # Share an additional folder to the guest VM. The first argument is
  # an identifier, the second is the path on the guest to mount the
  # folder, and the third is the path on the host to the actual folder.
  config.vm.share_folder "v-data", "/vagrant/db", "./db"
  config.vm.share_folder "v-web", "/vagrant/www", "c:\\www"

  # Enable provisioning with Puppet stand alone.  Puppet manifests
  # are contained in a directory path relative to this Vagrantfile.
  # You will need to create the manifests directory and a manifest in
  # the file base.pp in the manifests_path directory.
  #
  # An example Puppet manifest to provision the message of the day:
  #
  # # group { "puppet":
  # #   ensure => "present",
  # # }
  # #
  # # File { owner => 0, group => 0, mode => 0644 }
  # #
  # # file { '/etc/motd':
  # #   content => "Welcome to your Vagrant-built virtual machine!
  # #               Managed by Puppet.\n"
  # # }
  #
  config.vm.provision :puppet do |puppet|
    puppet.facter = {
      "fqdn"      => "dev.lamp.mysql",
      "hostname"  => "www",
      "docroot"   => "/vagrant/www",
      "host"      => 'localhost',
      "username"  => 'root',
      "password"  => '123',
      "db_name"   => "development",
      "db_location" => "/vagrant/db/development.sqlite"
    }
    puppet.manifests_path = "puppet/manifests"
    puppet.module_path = ["puppet/modules", "extras/modules"]
    puppet.manifest_file  = "init.pp"
  end

  # Enable provisioning with chef solo, specifying a cookbooks path, roles
  # path, and data_bags path (all relative to this Vagrantfile), and adding 
  # some recipes and/or roles.
  #
  # config.vm.provision :chef_solo do |chef|
  #   chef.cookbooks_path = "../my-recipes/cookbooks"
  #   chef.roles_path = "../my-recipes/roles"
  #   chef.data_bags_path = "../my-recipes/data_bags"
  #   chef.add_recipe "mysql"
  #   chef.add_role "web"
  #
  #   # You may also specify custom JSON attributes:
  #   chef.json = { :mysql_password => "foo" }
  # end

  # Enable provisioning with chef server, specifying the chef server URL,
  # and the path to the validation key (relative to this Vagrantfile).
  #
  # The Opscode Platform uses HTTPS. Substitute your organization for
  # ORGNAME in the URL and validation key.
  #
  # If you have your own Chef Server, use the appropriate URL, which may be
  # HTTP instead of HTTPS depending on your configuration. Also change the
  # validation key to validation.pem.
  #
  # config.vm.provision :chef_client do |chef|
  #   chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
  #   chef.validation_key_path = "ORGNAME-validator.pem"
  # end
  #
  # If you're using the Opscode platform, your validator client is
  # ORGNAME-validator, replacing ORGNAME with your organization name.
  #
  # IF you have your own Chef Server, the default validation client name is
  # chef-validator, unless you changed the configuration.
  #
  #   chef.validation_client_name = "ORGNAME-validator"
end
config.vm.provision :shell, :inline => "apt-get update --fix-missing"

不过,我很想知道puppet配置有什么问题,因为如果能够避免将其放在Vagrant文件中,那就太好了。

首先,您引用了一些未包含在帖子中的类,因此我无法对这些类进行评论

看起来你有一个木偶订购问题;我建议再次运行它,确定哪些特定的包部署失败,并确定它们属于哪个类。因此,例如,如果类y中的某个包x失败,请在所讨论的类的右括号之前将以下内容添加到init脚本中-

class y {

    package { "x":

       ensure  => installed,
    }

    Exec["apt-get update"] -> Class["y"]  

}
上述操作将确保在运行任何类“y”配置之前完成apt get update

或者,对于包资源类型,您可以继续添加-

require=>Exec['apt-get-update'],但我发现类的顺序更整洁