流浪者提供不在Windows上工作但在Ubuntu上工作

时间:2015-06-23 16:03:11

标签: apache ubuntu vagrant puppet

我有vagrant / puppet配置脚本,当我的主机是Windows时(当在Ubuntu上托管时似乎没有这个问题时)看到有问题。我可以看到使用apache ports.conf文件的apache :: concat有问题。我在两个地方都使用了相同的访客箱(ubuntu服务器14.04)。据我所知,木偶在客人机器上运行。

我的问题是为什么我在配置期间出现此警告和错误?

==> default: Running provisioner: puppet...
==> default: Running Puppet with default.pp...
==> default: stdin: is not a tty
==> default: Notice: Compiled catalog for eclectic.vm in environment production in 7.06 seconds
==> default: Notice: /Stage[main]/Main/Exec[apt-update]/returns: executed successfully
==> default: Notice: /Stage[main]/Main/Exec[git-checkout-drush]/returns: executed successfully
==> default: Notice: /Stage[main]/Main/File[/var/www/vhosts/eclectic.ca]/mode: mode changed '0777' to '0775'
==> default: Notice: /Stage[main]/Main/Apache::Vhost[ca.eclectic.vm]/File[/var/www/vhosts/eclectic.ca/public_html]/owner: owner changed 'www-data' to 'root'
==> default: Notice: /Stage[main]/Main/Apache::Vhost[ca.eclectic.vm]/File[/var/www/vhosts/eclectic.ca/public_html]/group: group changed 'vagrant' to 'root'
==> default: Error: /Stage[main]/Apache/Concat[/etc/apache2/ports.conf]/Exec[concat_/etc/apache2/ports.conf]: Could not evaluate: /usr/bin/env: ruby
: No such file or directory
==> default: Notice: /Stage[main]/Apache/Concat[/etc/apache2/ports.conf]/File[/etc/apache2/ports.conf]: Dependency Exec[concat_/etc/apache2/ports.conf] has failures: true
==> default: Warning: /Stage[main]/Apache/Concat[/etc/apache2/ports.conf]/File[/etc/apache2/ports.conf]: Skipping because of failed dependencies
==> default: Notice: /Stage[main]/Main/Exec[composer-install-drush]/returns: executed successfully
==> default: Error: /Stage[main]/Main/Apache::Vhost[ssl-ca.eclectic.vm]/Concat[25-ssl-ca.eclectic.vm.conf]/Exec[concat_25-ssl-ca.eclectic.vm.conf]: Could not evaluate: /usr/bin/env: ruby
: No such file or directory
==> default: Notice: /Stage[main]/Main/Apache::Vhost[ssl-ca.eclectic.vm]/Concat[25-ssl-ca.eclectic.vm.conf]/File[25-ssl-ca.eclectic.vm.conf]: Dependency Exec[concat_25-ssl-ca.eclectic.vm.conf] has failures: true
==> default: Warning: /Stage[main]/Main/Apache::Vhost[ssl-ca.eclectic.vm]/Concat[25-ssl-ca.eclectic.vm.conf]/File[25-ssl-ca.eclectic.vm.conf]: Skipping because of failed dependencies
==> default: Notice: /Stage[main]/Main/Apache::Vhost[ssl-ca.eclectic.vm]/File[25-ssl-ca.eclectic.vm.conf symlink]: Dependency Exec[concat_25-ssl-ca.eclectic.vm.conf] has failures: true
==> default: Warning: /Stage[main]/Main/Apache::Vhost[ssl-ca.eclectic.vm]/File[25-ssl-ca.eclectic.vm.conf symlink]: Skipping because of failed dependencies
==> default: Error: /Stage[main]/Main/Apache::Vhost[ca.eclectic.vm]/Concat[25-ca.eclectic.vm.conf]/Exec[concat_25-ca.eclectic.vm.conf]: Could not evaluate: /usr/bin/env: ruby
: No such file or directory
==> default: Notice: /Stage[main]/Main/Apache::Vhost[ca.eclectic.vm]/Concat[25-ca.eclectic.vm.conf]/File[25-ca.eclectic.vm.conf]: Dependency Exec[concat_25-ca.eclectic.vm.conf] has failures: true
==> default: Warning: /Stage[main]/Main/Apache::Vhost[ca.eclectic.vm]/Concat[25-ca.eclectic.vm.conf]/File[25-ca.eclectic.vm.conf]: Skipping because of failed dependencies
==> default: Notice: /Stage[main]/Main/Apache::Vhost[ca.eclectic.vm]/File[25-ca.eclectic.vm.conf symlink]: Dependency Exec[concat_25-ca.eclectic.vm.conf] has failures: true
==> default: Warning: /Stage[main]/Main/Apache::Vhost[ca.eclectic.vm]/File[25-ca.eclectic.vm.conf symlink]: Skipping because of failed dependencies
==> default: Notice: /Stage[main]/Apache::Service/Service[httpd]: Dependency Exec[concat_/etc/apache2/ports.conf] has failures: true
==> default: Notice: /Stage[main]/Apache::Service/Service[httpd]: Dependency Exec[concat_25-ca.eclectic.vm.conf] has failures: true
==> default: Notice: /Stage[main]/Apache::Service/Service[httpd]: Dependency Exec[concat_25-ssl-ca.eclectic.vm.conf] has failures: true
==> default: Warning: /Stage[main]/Apache::Service/Service[httpd]: Skipping because of failed dependencies
==> default: Notice: Finished catalog run in 18.24 seconds

我的木偶文件

# execute 'apt-get update'
exec { 'apt-update':
  command => 'apt-get update',
  path    => ["/usr/bin"],
}

# Install and configure apache2

class { 'apache':                # use the "apache" module
  default_vhost => false,        # don't use the default vhost
  default_mods => false,         # don't load default mods
  mpm_module => 'prefork',        # use the "prefork" mpm_module
  service_ensure => 'running',
}

include apache::mod::php
include apache::mod::rewrite

# Enable not define apache mods
# https://forge.puppetlabs.com/puppetlabs/apache#defined-type-apachemod
apache::mod { 'access_compat': }

# http eclectic version
apache::vhost { 'com.domain.vm':
  port        => '80',
  docadmin     => '/var/www/vhosts/domain.com/public_html',
  override    => ['all'],
  serveraliases => [
    'www.com.domain.vm',
  ],
}

# https eclectic version
apache::vhost { 'ssl-com.domain.vm':
  servername  =>  'com.domain.vm',
  port        => '443',
  docadmin     => '/var/www/vhosts/domain.com/public_html',
  override    => ['all'],
  ssl         => true,
  serveraliases => [
    'www.com.domain.vm',
  ],
}

# Setting up custom web eclectic direcotry
file { [
    "/var/www",
    "/var/www/vhosts",
    "/var/www/vhosts/domain.com"
  ]:
  ensure => "directory",
  owner  => "www-data",
  group  => "vagrant",
  mode   => 775,
}


# Add virtual host domain in /etc/hosts
host { 'com.domain.vm':
  ensure => present,
  ip => '127.0.0.1',
  host_aliases => 'www.com.domain.vm',
}


# install mysql-server package
package { 'mysql-server':
  require => Exec['apt-update'],        # require 'apt-update' before installing
  ensure => installed,
}

# ensure mysql service is running
service { 'mysql':
  ensure => running,
  require => Package['mysql-server'],
}


$packages = [
  'vim',
  'nano',
  'htop',
  'tree',
  'pv',
  'wget',
  'curl',
  'git',
  'php5',
  'php5-cli',
  'php5-gd',
  'php5-curl',
  'php5-mysql',
  'php5-mcrypt',
]

package { $packages:
  require => Exec['apt-update'],        # require 'apt-update' before installing
  ensure => installed,
}

exec { 'set-mysql-password':
  command => 'mysqladmin -u admin password "admin"',
  path    => ["/usr/bin"],
  logoutput => true,
  unless => 'mysqladmin -uadmin -padmin version',
  require => Service['mysql'],
}

package { 'php-pear':
  require => Exec['apt-update'],        # require 'apt-update' before installing
  ensure => installed,
  notify  => [
    Exec['pear-discover-channel-phing'],
    Exec['pear-install-Console_Table'],
    Exec['pear-install-Console_Color2'],
  ]
}


# http://puppet-php.readthedocs.org/en/latest/composer.html#installation
# Install to different destination
class { 'php::composer':
  destination => '/usr/bin/composer',
  notify  => Exec['composer-install-drush']
}

exec { "pear-discover-channel-phing":
  command => "pear channel-discover pear.phing.info",
  path    => ["/usr/bin"],
  logoutput => true,
  unless => 'pear channel-info pear.phing.info',
  require => Package['php-pear'],
  notify  => Exec['pear-install-phing'],
}

exec { "pear-install-phing":
  command => "pear install phing/phing",
  unless => "which phing",
  path    => ["/usr/bin"],
  logoutput => false,
  require => Exec['pear-discover-channel-phing'],
}

exec { "pear-install-Console_Table":
  command => "pear install Console_Table",
  unless => "pear info Console_Table",
  path    => ["/usr/bin"],
  logoutput => true,
}

exec { "pear-install-Console_Color2":
  command => "pear install Console_Color2-0.1.2",
  unless => "pear info Console_Color2-0.1.2",
  path    => ["/usr/bin"],
  logoutput => true,
}


####################################
# Install drush
exec { "git-clone-drush":
  command => "git clone https://github.com/drush-ops/drush.git /usr/local/src/drush",
  path    => ["/usr/bin"],
  unless  => 'test -d /usr/local/src/drush',
  notify  => Exec['git-checkout-drush']
}

exec { "git-checkout-drush":
  command => "git checkout 6.6.0",
  cwd     => "/usr/local/src/drush",
  path    => ["/usr/bin"],
  require => Exec['git-clone-drush'],
  notify  => File['/usr/bin/drush']
}

file { "/usr/bin/drush":
  ensure => 'link',
  target => '/usr/local/src/drush/drush',
  require => Exec['git-checkout-drush'],
  notify  => Exec['composer-install-drush']
}

exec { "composer-install-drush":
  environment => [ "COMPOSER_HOME=/usr/local/src/drush" ],
  command => "composer install",
  cwd     => "/usr/local/src/drush",
  path    => ["/usr/bin"],
  require => File['/usr/bin/drush']
}


# Copy ssh config vagrant file
file { '/home/vagrant/.ssh/config':
  ensure => present,
  mode   => 600,
  source => "puppet:///files/ssh/config/default-config",
}

2 个答案:

答案 0 :(得分:1)

你的问题可能和我的问题一样,我花了最近几天。在我的情况下,问题出在windows git 程序中。

在Windows下安装git时会询问您是否要配置CRLF< - > LF转换 - 有3个选项:

  1. 默认, Checkout Windows风格,提交Unix风格的行结尾 - 这意味着在签出时将LF转换为CRLF,并在提交时将CRLF转换为LF,
  2. 按原样结账,提交Unix风格的线路编码 - 不要在结账时转换,并在提交时将CRLF转换为LF,
  3. 按原样结帐,按原样提交 - 根本不进行转换。
  4. 起初我选择了(1),所以git在检查其中一个模块 icinga-vagrant \ modules \ concat 时将LF转换为CRLF,特别是脚本文件 icinga-流浪\模块\的concat \文件\ concatfragments.rb 即可。然后该脚本将被复制(不转换)到目标Linux虚拟机,并且不会在那里运行,因为/ usr / bin / env没有理解什么" ruby​​< CR>&#34 ;意味着,这就是为什么错误消息中有换行符的原因:

    ... Could not evaluate: /usr/bin/env: ruby
    : No such file or directory
    

    解决方案是使用选项nr(2)重新安装git,虽然它可能无需重新安装即可更改 - 我有点懒。现在,git按原样检查脚本,只在行结束时使用LF,因此在Linux上运行没有问题。

答案 1 :(得分:0)

你是否在傀儡中包含了模块stdlib? concat是其中的一个功能。如果您按Puppetfile

管理伪造模块,可以告诉我librarian-puppet

似乎依赖是问题。应该在安装后解决您的问题。