运行“puppet agent -t”commnad时无法从hieara

时间:2016-12-28 11:46:38

标签: puppet devops puppet-enterprise hiera

我在我的VM上安装了Puppet企业,在Virtualbox中运行。

安装顺利,但是当我尝试运行命令puppet agent -t时,我收到以下错误:

[root@puppetmaster ~]# puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Could not find data item role in any Hiera data file and no default supplied at /etc/puppetlabs/code/environments/production/manifests/site.pp:32:10 on node puppetmaster.localdomain
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

这是我的site.pp文件行,其中包含错误;

## site.pp ##

# This file (/etc/puppetlabs/puppet/manifests/site.pp) is the main entry point
# used when an agent connects to a master and asks for an updated configuration.
#
# Global objects like filebuckets and resource defaults should go in this file,
# as should the default node definition. (The default node can be omitted
# if you use the console and don't define any other nodes in site.pp. See
# http://docs.puppetlabs.com/guides/language_guide.html#nodes for more on
# node definitions.)

## Active Configurations ##

# Disable filebucket by default for all File resources:
#http://docs.puppetlabs.com/pe/latest/release_notes.html#filebucket-resource-no-longer-created-by-default
File { backup => false }

# DEFAULT NODE
# Node definitions in this file are merged with node data from the console. See
# http://docs.puppetlabs.com/guides/language_guide.html#nodes for more on
# node definitions.

# The default node definition matches any node lacking a more specific node
# definition. If there are no other nodes in this file, classes declared here
# will be included in every node's catalog, *in addition* to any classes
# specified in the console for that node.

node default {
 # This is where you can declare classes for all nodes.
 # Example:
 #   class { 'my_class': }
 $role = hiera('role')
 $location = hiera('location')
 notify{"in the top level site.pp : role is '${role}', location is '${location}'": }
 include "::roles::${role}"
}

1 个答案:

答案 0 :(得分:1)

如果您查看错误,则无法找到您在Could not find data item role in any Hiera data file and no default supplied at /etc/puppetlabs/code/environments/production/manifests/site.pp:32:10 on node puppetmaster.localdomain中要求的hiera密钥:

$role = hiera('role') $location = hiera('location')

在您的代码中,您有以下内容:

if ( $billingService->prepareSale($adapter, $sale) )
    {
        $totalAmount = floatval($sale->totalAmount * 100); //convert to kobo
        $saleHash = $sale->hash;
        $userEmail = $userService->findUserById($sale->userId)->getEmail();
        $metadata = array(
                'itemName' => $sale->entityDescription,
                'itemID' => $sale->entityKey,
        );

        $response = $paystack->transaction->initialize([
                'reference' => $saleHash,
                'amount' => $totalAmount, // in kobo
                'email' => $userEmail,
                'callback_url' => $fields['notify_url'],
                'metadata' => json_encode($metadata),
        ]);

        $url = $response->data->authorization_url;

        $masterPageFileDir = OW::getThemeManager()->getMasterPageTemplate('blank');
        OW::getDocument()->getMasterPage()->setTemplate($masterPageFileDir);

        header('Location: '.$url);

        $billingService->unsetSessionSale();

    }

这两个都是hiera调用,需要设置hiera并且相关密钥位于hieradata文件夹中。

帮助您诊断hiera问题的有用工具是hiera_explain,它向您展示了如何设置和配置hiera层次结构,并可能有助于解释代码的问题。