25
Puppet with Hiera Using hiera for variable management and encryption Scott Lackey 2014

Using hiera with puppet

Embed Size (px)

DESCRIPTION

Scott Lackey presents how to get started with hiera and puppet using many of the popular hiera backends.

Citation preview

Page 1: Using hiera with puppet

Puppet with HieraUsing hiera for variable management

and encryption

Scott Lackey 2014

Page 2: Using hiera with puppet

Who’s this guy?From: Nashville/SeattleSchool: CS dropoutWork: IBM, NASA, Sprint, SalesForceLanguages: Spanish, Russian

Page 3: Using hiera with puppet

Hiera is a framework for hierarchically organizing data, and abstracting it from your manifests.

What’s a Hiera?

Sticking value pairs into yaml files to play puppet plinko

Page 4: Using hiera with puppet
Page 5: Using hiera with puppet

With Hiera, you can externalize your data and

easily understand how configuration values are

assigned to your servers.

Page 6: Using hiera with puppet

Node inheritance: node mysql01.domain.com { $user = 'dbauser' $password = 'ermahgerd'}

Puppet’s recent evolution

Parameterized classes:class mysql( $user = $mysql::params::dbauser, $password = $mysql::params::password

Hiera:user : 'dbauser'password : 'ermahgerd'

Page 7: Using hiera with puppet

Hiera is now the default in Puppet version 3+

*You don’t need to install anything!

Page 8: Using hiera with puppet

You only need

two things

Page 9: Using hiera with puppet

The Hiera config + A Yaml file/etc/puppet/hiera.yaml /etc/puppet/hieradata/environment/prod/main.yaml

Page 10: Using hiera with puppet

example:yaml

Page 11: Using hiera with puppet

example:yaml

ls /environment/production:cache.yaml ldap.yaml main.yaml

Page 12: Using hiera with puppet

example:yaml

ls /environment/staging:cache.yaml ldap.yaml main.yaml

Page 13: Using hiera with puppet

example:yaml

ntp/manifests/init.pp

Page 14: Using hiera with puppet

example:yaml

special calling_module variable

Page 15: Using hiera with puppet

example:yaml

ls /environment/staging: ldap.yaml mysql.yaml

Page 16: Using hiera with puppet

Hiera can get data from more than just yaml files

eyamlHTTPmySQLPostgres

MongoJSONredismore..

Page 17: Using hiera with puppet

example:Postgres

Page 18: Using hiera with puppet

example:Postgres

path key value

'fqdn/foo.example.com' 'ntp::servers' 'ntp.mydomain.com’

'fqdn/bar.example.com' 'ntp::servers' ‘ntp2.mydomain.com’

'environment/production' 'ntp::servers' '[ prodntp1.mydomain.com, prodntp2.

mydomain.com ]'

'environment/staging' 'ntp::servers' 'stagingntp.mydomain.com'

The Postgres config table layout

Page 19: Using hiera with puppet

How do you manage credentials in Puppet?

Shared manifests secret credentials manifests

Puppet repo

Page 20: Using hiera with puppet

Hiera-eyaml

Page 21: Using hiera with puppet

example:eyaml

Page 22: Using hiera with puppet

example:eyaml

eyaml edit /puppet/hieradata/environment/staging/main.yaml --pkcs7-public-key public_key.pkcs7.pem-staging --pkcs7-private-key private_key.pkcs7.pem-staging

Page 23: Using hiera with puppet

example:erb templating

#manifest

#erb template

Page 24: Using hiera with puppet

Question/Answer

Page 25: Using hiera with puppet

● Hiera-eyaml encryption https://github.com/TomPoulton/hiera-eyaml

● When to Hiera: http://garylarizza.com/blog/2013/12/08/when-to-hiera/

● Hiera Postgres: https://github.com/dalen/hiera-psql

Further reading