Vagrant Error:评估错误:空字符串标题为0.标题字符串的长度必须大于零

时间:2016-04-21 07:01:04

标签: vagrant puphpet

当我运行“流浪汉”时,我收到了以下错误。

  

错误:评估错误:空字符串标题为0.标题字符串必须   长度大于零。在   /tmp/vagrant-puppet/manifests-75f35e3bc7e32744860c4bb229c88812/Firewall.pp:68:37   在节点上

请帮助我,这个问题的解决方法是什么?

如果您需要任何其他来源,请告诉我。

以下是Firewall.pp中的代码:

class puphpet_firewall (   $firewall,   $vm ) {

  Firewall {
    before  => Class['puphpet::firewall::post'],
    require => Class['puphpet::firewall::pre'],   }

  class { ['puphpet::firewall::pre', 'puphpet::firewall::post', 'firewall']: }

  # config file could contain no rules key   $rules = array_true($firewall, 'rules') ? {
    true    => $firewall['rules'],
    default => { }   }

  each( $rules ) |$key, $rule| {
    if is_string($rule['port']) {
      $ports = [$rule['port']]
    } else {
      $ports = $rule['port']
    }

    each( $ports ) |$port| {
      if ! defined(Puphpet::Firewall::Port["${port}"]) {
        if has_key($rule, 'priority') {
          $priority = $rule['priority']
        } else {
          $priority = 100
        }

        puphpet::firewall::port { "${port}":
          protocol => $rule['proto'],
          priority => $priority,
          action   => $rule['action'],
        }
      }
    }   }

  # Opens up SSH port defined in `vagrantfile-*` section   if has_key($vm, 'ssh') and has_key($vm['ssh'], 'port') {
    $vm_ssh_port = array_true($vm['ssh'], 'port') ? {
      true  => $vm['ssh']['port'],
      false => 22,
    }   } else {
    $vm_ssh_port = 22   }

  if ! defined(Puphpet::Firewall::Port["${vm_ssh_port}"]) {
    puphpet::firewall::port { "${vm_ssh_port}": }   }

  # Opens up forwarded ports on locale machines; remote servers won't have these keys   if array_true($vm['vm']['provider'], 'local') {
    each( $vm['vm']['provider']['local']['machines'] ) |$mId, $machine| {
      # config file could contain no forwarded ports
      $forwarded_ports = array_true($machine['network'], 'forwarded_port') ? {
        true    => $machine['network']['forwarded_port'],
        default => { }
      }

      each( $forwarded_ports ) |$pId, $port| {
        if ! defined(Puphpet::Firewall::Port["${port['guest']}"]) {
          puphpet::firewall::port { "${port['guest']}": }
        }
      }
    }   }

}

谢谢!

1 个答案:

答案 0 :(得分:0)

在资源标题中使用有时尚未设置的变量时,我看到了这个错误。

以此行为例......如果散列port不包含密钥'guest',则资源标题将为空并导致错误:

  

puphpet::firewall::port { "${port['guest']}": }