Ask Your Question
0

Understanding Hiera settings and like it's working

asked 2016-06-14 07:49:32 -0500

Willie Cadete gravatar image

Hello,

I've recently found a structure of puppet ready and functional using hiera, but I don't know like it's working.

my hiera settings:

/etc/puppetlabs/code/hiera.yaml

:backends:
  - yaml
:yaml:
  :datadir: "/etc/puppetlabs/code/environments/%{environment}/hieradata"
:hierarchy:
  - "hostname/%{city}/%{trusted.certname}"
  - "profiles/%{::location}/%{::service}/%{::profileserver}"
  - "profiles/%{::location}/default"
  - "city/%{city}" 
  - "virtual_%{is_virtual}/%{virtual}"
  - "os/%{kernel}/%{osfamily}"
  - "os/%{kernel}/default"

#:merge_behavior: deeper

/etc/puppetlabs/code/environments/production/manifests/site.pp

$city          = define_server($trusted['certname'],'city')
$location      = define_server($trusted['certname'],'location')
$service       = define_server($trusted['certname'],'service')
$profileserver = define_server($trusted['certname'],'profile')

an example of settings in hiera hierarchy /etc/puppetlabs/code/environments/production/hieradata/profiles/aa/puppetmaster/master.yaml

---
######################################
#####     puppet-agent             ###
######################################
puppet_agent::master: true
puppet_agent::vardir: '/opt/puppetlabs/server/data/puppetserver'
#puppet_agent::logdir: '/var/log/puppetlabs/puppetserver'
puppet_agent::rundir: '/var/run/puppetlabs/puppetserver'
puppet_agent::pidfile: '/var/run/puppetlabs/puppetserver/puppetserver.pid'
puppet_agent::codedir: '/etc/puppetlabs/code'
puppet_agent::storeconfigs: true
puppet_agent::storeconfigs_backend: 'puppetdb'
puppet_agent::reports: 'puppetdb'

The question is, how the puppet knows what are the profiles, services and cities of the servers? I've already looked on facts of the agents but don't found this variable!

thanks.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-06-14 19:58:13 -0500

lavaman gravatar image

These variables are actually top-scope variables (as indicated by the :: in front). I'm guessing that they are being set in site.pp or in a node definition and this is how hiera is accessing them. If you want to use them in your hiera setup, you need to provide values for them yourself.

edit flag offensive delete link more
0

answered 2016-06-15 06:40:45 -0500

Willie Cadete gravatar image

This is the problem I don't find a node definition. it just these informations above and I know means this function define_server( ), I don't find information about this.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-06-14 07:49:32 -0500

Seen: 58 times

Last updated: Jun 15 '16