1

我正在尝试将以下elasticsearch模块用于 puppet(带有 hiera)。

我正在尝试配置node.name例如,可以在instance.pp文件中看到。

elasticsearch::instance然而,它不是一个类,它只是被定义并且它似乎被用于其他类(特别是 elasticsearch,in init.pp)。

我尝试将其实例化为一个类,并通过以下方式进行配置:

elasticsearch::elasticsearch::instance::node.name: 'myname'在我的 .yaml 中,但无济于事。

4

2 回答 2

3

I will try to explain all problems you mentioned.

  1. Class vs define. The main difference is that classes are singletons in puppet.

  2. If you want to create an instance of elasticsearch::instance just add to your puppet manifest:

elasticsearch::instance { 'some_name': }

exactly the same as in examples.

  1. The purpose of using hiera with puppet is to provide proper values to puppet manifests depend on deployment environment. You cannot create a resource just by defining it in hiera. If you define some resource in hiera, use create_resource function to create an instance. Please read the following article. As in example, the equivalent of making an instance in puppet manifest:

    users { 'gary':
      ensure   => present,
      uid      => '5001',
      gid      => 'gary',
      shell    => 'zsh',
      password => $password,
    }
    

is, the following definition in hiera

#some.yaml
users:
  gary:
    ensure: 'present'
    uid: '5001'
    gid: 'gary'
    shell: 'zsh'
    password: 'biglongpasswordhash'

with instantiation in puppet manifest:

$users = hiera('users')
create_resources('users')
于 2015-05-30T10:04:25.597 回答
0

class从您的描述中,您似乎了解和之间的区别define。要直接回答您的问题,应将其组织为:

---
elasticsearch::instances:
  es-01:
    config:
      node.name: 'es-01'
  es-02:
    config:
      node.name: 'es-02'

多个实例.yaml

于 2015-05-31T02:41:44.803 回答