apache - vagrant provisining 在 Windows 上不起作用,但在 Ubuntu 上起作用

标签 apache ubuntu vagrant puppet

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

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

==> 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

我的 puppet 文件
# 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",
}

最佳答案

您的问题可能与我的问题相同,我在过去几天都在解决这个问题。就我而言,问题出在窗口 上。混帐程序。

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

  • 默认, checkout Windows 风格,提交 Unix 风格的行尾 - 这意味着在 checkout 时将 LF 转换为 CRLF,并在提交时将 CRLF 转换为 LF,
  • 按原样结帐,提交 Unix 风格的行编码 - checkout 时不转换,提交时将 CRLF 转换为 LF,
  • 按原样结帐,按原样提交 - 根本不转换。

  • 一开始我选择了(1),所以git在 checkout 其中一个模块时将LF转换为CRLF, icinga-vagrant\modules\concat ,特别是脚本文件 icinga-vagrant\modules\concat\files\concatfragments.rb .然后该脚本将被复制(无需转换)到目标 Linux 虚拟机,并且不会在那里运行,因为/usr/bin/env 不理解“ruby”的含义,这就是错误消息的原因其中有一个换行符:
    ... Could not evaluate: /usr/bin/env: ruby
    : No such file or directory
    

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

    关于apache - vagrant provisining 在 Windows 上不起作用,但在 Ubuntu 上起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31007883/

    相关文章:

    python - Apache mod_wsgi 和 python 2.7

    database - 使用 RubyMine 通过 Vagrant 连接到数据库

    ruby - Vagrant 显然没有正确合并 Vagrantfiles,Chef 配置丢失

    c# - 如何在 Ubuntu 上安装最新版本的 Mono 和 MonoDevelop?

    amazon-web-services - 自动配置新的 Kubernetes 节点

    unix - 我的服务器无法在端口 80 上监听

    chef-infra - 如何在 Vagrant 中使用新的 opscode 存储库?

    apache - mod_jk 与 mod_rewrite 冲突

    angularjs - Ionic 应用程序的跨源资源共享问题

    mysql - 从 ubuntu 中的桌面脚本启动 apache 和 mysql