Setting node-specific data with Hiera
In our hierarchy defined in hiera.yaml
, we created an entry based on the hostname fact; in this section, we'll create yaml files in the hosts
subdirectory of Hiera data with information specific to a particular host.
Getting ready
Install and configure Hiera as in the last section and use the hierarchy defined in the previous recipe that includes a hosts/%{hostname}
entry.
How to do it...
The following are the steps:
- Create a file at
/etc/puppet/hieradata/hosts
that is the hostname of your test node. For example if your host is namedcookbook-test
, then the file would be namedcookbook-test.yaml
. - Insert a specific message in this file:
message: 'This is the test node for the cookbook'
- Run Puppet on two different test nodes to note the difference:
t@ckbk:~$ sudo puppet agent -t Info: Caching catalog for cookbook-test Notice: Message is This is the test node for the cookbook [root@hiera-test ~]# puppet agent -t Info: Caching catalog for hiera-test.example.com Notice: Message is Default Message
How it works...
Hiera searches the hierarchy for files that match the values returned by facter. In this case, the cookbook-test.yaml
file is found by substituting the hostname of the node into the search path /etc/puppet/hieradata/hosts/%{hostname}.yaml
.
Using Hiera, it is possible to greatly reduce the complexity of your Puppet code. We will use yaml
files for separate values, where previously you had large case
statements or nested if
statements.
- Hands-On Intelligent Agents with OpenAI Gym
- Java編程全能詞典
- Cinema 4D R13 Cookbook
- 商戰(zhàn)數(shù)據(jù)挖掘:你需要了解的數(shù)據(jù)科學(xué)與分析思維
- 西門子S7-200 SMART PLC從入門到精通
- Getting Started with MariaDB
- Learning Apache Cassandra(Second Edition)
- SharePoint 2010開發(fā)最佳實(shí)踐
- 統(tǒng)計(jì)學(xué)習(xí)理論與方法:R語言版
- 計(jì)算機(jī)網(wǎng)絡(luò)安全
- Blender 3D Printing by Example
- 網(wǎng)站入侵與腳本攻防修煉
- 云計(jì)算和大數(shù)據(jù)的應(yīng)用
- Learning Apache Apex
- 簡明學(xué)中文版Flash動(dòng)畫制作