Skip to content

Instantly share code, notes, and snippets.

@hfm
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hfm/958d8951ac630f819077 to your computer and use it in GitHub Desktop.
Save hfm/958d8951ac630f819077 to your computer and use it in GitHub Desktop.
puppet hieraとは何か

Hiera

http://docs.puppetlabs.com/hiera/1/index.html

外観

Hieraはkey/value型(yaml, json)の設定データ検索ツール。 ノードごとの設定値をHieraに記述することで、マニフェストからノード固有設定を分離する。

例:

  • MySQLやbasic認証のパスワード
  • オリジナルyumserverのアドレス
  • production, integration, development環境において値の異なる変数

導入

RHEL系ならyumから入る。 詳細はこちら

設定ファイル

hiera.yaml

http://docs.puppetlabs.com/hiera/1/configuring.html

hieraに関するデータディレクトリやデータ形式を決定するメタデータhiera.yamlの設置場所は、デフォルトで$confdir/hiera.yaml OpenSource版のPuppetなら/etc/puppet/hiera.yamlに設置しても読み込まれる。 また、puppet.confにhiera.yamlの位置を指定することも可能。

例えば以下のような設定が記述される。デフォルト値から変更しないものは省いても良い。

---
:yaml:
  :datadir: "%{settings::confdir}/hieradata/%{::environment}"
:hierarchy:
  - common
  • :yaml:にはデータディレクトリの位置を書いている
  • %{settings::confdir}は、puppetmasterが所持しているReserved Variables
  • %{::environment}は、例えばproductiondevelopment等を設定し、hieradataディレクトリ以下に名前に対応したディレクトリを設置する。

:hierarchy

hiera.yamlのトップレベルに:hierarchyキーとその値を設定することで、Hieraはヒエラルキデータをロードすることが出来る。

例:

:hierarchy:
  - one
  - two
  - three

この場合、Hieraは 上から順番に 探していく。 oneの中に目的のデータがなければ次のtwoへ、同様の結果であればその次のthreeへと検索対象が遷移する。 (あるいはoneそのものが見つからない場合も次の対象を検索するようになるらしい。)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment