运算符'[]'不适用于Undef值

时间:2017-05-02 13:45:33

标签: puppet

[tom@pe-server] cat site.pp
node 'mynode.com' {
    include base::common::setup

    $svn_url_disable_uac = {
        svn_co_dir => 'automation/scripts/base/common',
        svn_url    => 'abc/trunk/automation/chv/modules/base/files/common/disable_uac.ps1',
    }
}
[tom@pe-server] cat disable_uac.pp
class base::common::disable_uac inherits base::common::param {
    base::common::svn::repo_checkout { 'Copy disable_uac PS script':
        svn_url_params => $svn_url_disable_uac,
    }

    util::executeps { 'Disable UAC':
        pspath    => $disable_uac,
        argument  => '',
        subscribe => Base::Common::Svn::Repo_checkout['Copy disable_uac PS script'],
    }
}
[tom@pe-server] cat setup.pp
class base::common::setup inherits base::common::param {
    include base::common::disable_uac
}
[tom@pe-server] cat param.pp
class base::common::param (
    $repo_checkout_ps = 'C:/puppet/automation/scripts/infra/repo_checkout.ps1',
    $disable_uac = 'C:/puppet/automation/scripts/base/common/disable_uac.ps1',
) {}

当我运行上面的代码时,我收到以下错误:

Error:
Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Operator '[]' is not applicable to an Undef Value. 
at /etc/puppetlabs/code/environments/client/modules/base/manifests/common/svn/repo_checkout.pp:7:19 
at /etc/puppetlabs/code/environments/client/modules/base/manifests/common/disable_uac.pp:2 on node mynode.com

需要注意的一点是,如果我将以下代码从base::common::disable_uac移至site.pp,那么一切正常:

   base::common::svn::repo_checkout { 'Copy disable_uac PS script':
        svn_url_params => $svn_url_disable_uac,
    }

更新: 对不起,我错过了把这部分放在帖子里。这是:

[tom@pe-server] cat repo_checkout.pp
define base::common::svn::repo_checkout (
    $svn_url_params,
) {
    include base::common::param
    $repo_checkout_ps = $base::common::param::repo_checkout_ps

    $svn_co_dir = $svn_url_params[svn_co_dir]    # Line 7
    $svn_url = $svn_url_params[svn_url]

    util::executeps { "Checking out build packet for URL \"$svn_url\"":
        pspath   => $repo_checkout_ps,
        argument => "\"$svn_co_dir\" \"$svn_url\"",
    }
}

我花了几个小时研究它但无法弄清楚问题。

0 个答案:

没有答案