SlideShare a Scribd company logo
A brief introduction to Casual Config Fridays
seminars and the idea behind them
S M T W T F S
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
< October >
CONFIG TRAINING
A comprehensive introduction
to the Puppet infrastructure
Hostgroups
And we can keep specializing…
It’s everything about grouping
it-puppet-hostgroup-webstuff
webstuff/backendwebstuff/frontend
webstuff/frontend/atlas webstuff/frontend/cms
Welcome to the training
Why are we here?
Puppet infrastructure
Get to know the infrastructure and all the
components that allow us to offer
Configuration management at CERN.
High availability
As part of the training you’ll learn how to
define alias to ensure that at any moment
multiple machines can attend your users’
requests.
Handle secrets in your configuration
No one wants to share a password with people
who shouldn’t have access. Let’s use secrets!
Configure just once
Learning how to configure your services is as
important as defining configuration in a way that
you can replicate it easily across your machines.
Learn the mechanism to share code
Why spend time on tasks that other people in
the community have solved before?
Solve your questions
We’ll cover what we think is important for you to
know, but we are here to solve your questions.
Don’t hesitate to raise your hand if you have any!
Environments
Differences between them
10
production qa new
Production
Machines in this environment will
get all the config from the
master branch of the repositories
and is designed for production
machines that focus on stability.
QA
This environment is usually used
by a portion of the production
machines to test new shared
changes. All the code will come
from qa branches.
New
At any point you can create a
new environment to test
changes in a more isolated way.
4 1
Introduction to the basic concepts of Hiera, usage
examples and description of the priority chain
/haɪra/
06
First things first
Yeah, pretty much everyone says it wrong…
07
Hiera 101
What it is and how it works
A key/value store abstraction based in YAML files
A key lookup resolution mechanism
A hierarchical data organization
A data composition mechanism (defaults,
overrides, merges…)
08
punch/puppet/ps.yaml
---
osrepos_epel_exclude_pkgs:
- puppetserver
pluginsync_filter:
- archive
- puppetdbquery
- puppetserver
cernpuppet::puppetdb::puppetdb_server: "constable.cern.ch"
A simple
Hiera file
A simple
Hiera file
Understanding the hierarchy
The global layer from the most to the least specific
Fully qualified domain name
Data can be assigned to a
specific hostname
Subhostgroups
Searched from most to
least specific
Hostgroup and environment
Different data can be assigned to,
for example, production and qa
Hostgroup and operating system
Each hostgroup has hieradata
available for operating sytem
Toplevel hostgroup
Has the last lookup in
the hostgroup tree
10
Environment
Data specific to the
Puppet environment
Operatingsystem
Global operating
system variables
Hardware vendor
Specific to the vendor (or maintainer)
of the hardware
Module
Data for the module
Common
Global data
Datacenter
Target the different
datacenters (i.e. meyrin)
Learning to fetch your data using automatic lookups,
useful functions and command line tools
12
Getting your data
Two different lookup mechanisms
Automatic lookup
Puppet automatically looks for
class parameters values using the
fully qualified name when those are
not explicitly provided
Explicit lookup
Uses Hiera to retrieve the value for
a key, allowing data validation and
different strategies to define how to
fetch data
13
Automatic
class
parameter
lookup
hg_webserver/manifests/backend.pp
class hg_webserver::backend {
include ::yum
}
webserver/backend.yaml
---
yum::clean_old_kernels: false
yum/manifests/init.pp
class yum (
Boolean $clean_old_kernels = true,
) {
...
}
14
code/manifest/webserver/frontend.pp
class hg_webserver::frontend {
$backend_url = lookup('backend_url')
$backend_port = lookup('backend_port', {
'default_value' => 80,
'merge' => 'first',
})
}
webserver/backend.yaml
---
backend_port: 8080
backend_url: "mywebserver.cern.ch"
The lookup
function
15
Merging data
Four different merge behaviors
First
No merge. First found, first used
Unique (array merge)
Combines any number of array
and scalar values into an array
Hash
Combines keys and values of any
number of hashes to return a
merged hash
Deep
Similar to hash, but if the same key
exists in multiple source hashes,
Hiera recursively merges them
16
location/pdx.yaml
profile::server::time_servers: "time.pdx.example.com"
common.yaml
profile::server::time_servers:
- 0.pool.ntp.org
- 1.pool.ntp.org
lookup('profile::server::time_servers', {merge => 'first'})
'time.pdx.example.com’
First
strategy
17
location/pdx.yaml
profile::server::time_servers: "time.pdx.example.com"
common.yaml
profile::server::time_servers:
- 0.pool.ntp.org
- 1.pool.ntp.org
lookup('profile::server::time_servers', {merge => 'unique'})
[
'time.pdx.example.com’,
'0.pool.ntp.org',
'1.pool.ntp.org’,
]
Unique
strategy
18
lookup('site_users', {merge => 'hash'})
{
"ash" => { group => "common", uid => 502, shell => "/bin/zsh" }
"bob" => { group => "ops", uid => 1000 },
"jen" => { group => "ops", uid => 503, shell => "/bin/zsh" },
}
groups/ops.yaml
site_users:
bob:
group: ops
uid: 1000
jen:
group: ops
shell: /bin/zsh
uid: 503
common.yaml
site_users:
ash:
group: common
shell: /bin/zsh
uid: 502
bob:
shell: /bin/bash
uid: 501
Hash
strategy
19
lookup('site_users', {merge => 'deep'})
{
"ash" => { group => "common", uid => 502, shell => "/bin/zsh" }
"bob" => { group => "ops", uid => 1000, shell => "/bin/bash" },
"jen" => { group => "ops", uid => 503, shell => "/bin/zsh" },
}
groups/ops.yaml
site_users:
bob:
group: ops
uid: 1000
jen:
group: ops
shell: /bin/zsh
uid: 503
common.yaml
site_users:
ash:
group: common
shell: /bin/zsh
uid: 502
bob:
shell: /bin/bash
uid: 501
Deep
strategy
20
Deprecated functions
Time to update your manifests
hiera_array
(141 uses)
hiera
(4381 uses)
hiera_hash
(258 uses)
hiera_include
(6 uses)
Definition of not-so-static Hiera values using
variables and functions interpolations
23
Interpolating variables
Four different possible sources
Puppet variables
Most common way. Get’s the
value from a Puppet variable
Trusted hash
Accurate values extracted from
the node’s certificate
Facts hash
Contains all node’s facts.
Structured ones are shown up as a
nested structure
22
webserver/backend.yaml
---
# Puppet variable interpolation
server_name: "%{servername}"
# Facts hash interpolation
smtpserver: "mail.%{facts.networking.domain}" # mail.cern.ch
# Trusted hash interpolation
webserver::frontend::backend_url: "%{trusted.hostname}.cern.ch"
Interpolating
variables
24
Interpolating functions
Lookups and beyond
lookup
Looks up a key using Hiera, and
interpolates the values into a string
scope
An alternative way to interpolate a
variable. Not generally useful
literal
A way to write a literal percent
sign (%) without accidentally
interpolating something
alias
Looks up a key using Hiera, and
uses the value as a replacement
for the enclosing
25
webserver/backend.yaml
---
# lookup interpolation
webserver::backend::database_server: "%{lookup('mysql::public_hostname')}"
# scope interpolation
smtpserver: "mail.%{facts.domain}"
smtpserver: "mail.%{scope('facts.domain')}"
# literal interpolation
server_name_string: "%{literal('%')}{SERVER_NAME}"
# alias interpolation
original:
- 'one'
- 'two'
aliased: "%{alias('original’)}"
Interpolating
functions
Upgrading and cleaning our code with Hiera 5 and
defining custom strategies
27
Global, environment and module
Three different layers of configuration
Global layer
Define all the levels of
the hierarchy
Environment layer
Merged with the global
layer in our deployment
Module layer
Allows to set defaults for a
module’s class parameters
28
Implementing Hiera 5
The hiera.yaml format
Module level data is defined in a hiera.yaml file
Must include the version (v5)
The hierarchy key configures the data hierarchy
The defaults key define default values for the
backend and datadir keys
29
hiera.yaml
---
version: 5
defaults:
datadir: 'data'
data_hash: 'yaml_data'
hierarchy:
- name: 'Full Version'
path: '%{facts.os.name}-%{facts.os.release.full}.yaml'
- name: 'Major Version'
path: '%{facts.os.name}-%{facts.os.release.major}.yaml'
- name: 'Operating System Family'
path: '%{facts.os.family}-family.yaml'
- name: 'common'
path: 'common.yaml'
A hiera.yaml
example
30
Defining strategies
The lookup_options key
Any data source can set a lookup_options key
This key controls the merge behavior of other keys
Puppet lookups will first check for lookup_options
The lookup_options keys are merged by Puppet
using hash merge before deciding a merge behavior
31
Defining
strategies
code/data/common.yaml
lookup_options:
ntp::servers:
merge: unique
"^profile::(.*)::users$":
merge: deep
ntp::servers: "ntp.cern.ch"
code/data/rhel-7.yaml
lookup_options:
"^profile::(.*)::users$":
merge: hash
# Actual values after the hash_merge
{
"ntp::servers" => { merge => "unique" }
"^profile::(.*)::users$" => { merge => "hash" },
}
Things to remember…
Just an small summary
32
34
Some useful links
Click & Go
Migrating to Hiera 5
Best module to use us an example of best practices
Automatic class parameter lookup
Hiera documentation in configdocs
35
And some more…
Again, Click & Go
Interesting talk on Hiera by Hendrik Lindberg
Further options for deep strategy behaviour
More information on interpolation
Deprecated functions and alternatives

More Related Content

What's hot

Set up Hadoop Cluster on Amazon EC2
Set up Hadoop Cluster on Amazon EC2Set up Hadoop Cluster on Amazon EC2
Set up Hadoop Cluster on Amazon EC2IMC Institute
 
RHive tutorial - Installation
RHive tutorial - InstallationRHive tutorial - Installation
RHive tutorial - Installation
Aiden Seonghak Hong
 
Introduction To Terraform
Introduction To TerraformIntroduction To Terraform
Introduction To Terraform
Sasitha Iresh
 
Hive data migration (export/import)
Hive data migration (export/import)Hive data migration (export/import)
Hive data migration (export/import)
Bopyo Hong
 
HaskellとDebianの辛くて甘い関係
HaskellとDebianの辛くて甘い関係HaskellとDebianの辛くて甘い関係
HaskellとDebianの辛くて甘い関係
Kiwamu Okabe
 
Refactoring terraform
Refactoring terraformRefactoring terraform
Refactoring terraform
Nell Shamrell-Harrington
 
Terraform 0.9 + good practices
Terraform 0.9 + good practicesTerraform 0.9 + good practices
Terraform 0.9 + good practices
Radek Simko
 
Everything as Code with Terraform
Everything as Code with TerraformEverything as Code with Terraform
Everything as Code with Terraform
Mitchell Pronschinske
 
Hadoop spark performance comparison
Hadoop spark performance comparisonHadoop spark performance comparison
Hadoop spark performance comparison
arunkumar sadhasivam
 
Stack kicker devopsdays-london-2013
Stack kicker devopsdays-london-2013Stack kicker devopsdays-london-2013
Stack kicker devopsdays-london-2013Simon McCartney
 
Move spfile from asm to file system
Move spfile from asm to file systemMove spfile from asm to file system
Move spfile from asm to file systemraviranchi02
 
R hive tutorial supplement 3 - Rstudio-server setup for rhive
R hive tutorial supplement 3 - Rstudio-server setup for rhiveR hive tutorial supplement 3 - Rstudio-server setup for rhive
R hive tutorial supplement 3 - Rstudio-server setup for rhiveAiden Seonghak Hong
 
Oracle database - Get external data via HTTP, FTP and Web Services
Oracle database - Get external data via HTTP, FTP and Web ServicesOracle database - Get external data via HTTP, FTP and Web Services
Oracle database - Get external data via HTTP, FTP and Web Services
Kim Berg Hansen
 
Python mongo db-training-europython-2011
Python mongo db-training-europython-2011Python mongo db-training-europython-2011
Python mongo db-training-europython-2011
Andreas Jung
 
DevOps Enabling Your Team
DevOps Enabling Your TeamDevOps Enabling Your Team
DevOps Enabling Your Team
GR8Conf
 

What's hot (16)

Set up Hadoop Cluster on Amazon EC2
Set up Hadoop Cluster on Amazon EC2Set up Hadoop Cluster on Amazon EC2
Set up Hadoop Cluster on Amazon EC2
 
RHive tutorial - Installation
RHive tutorial - InstallationRHive tutorial - Installation
RHive tutorial - Installation
 
extending-php
extending-phpextending-php
extending-php
 
Introduction To Terraform
Introduction To TerraformIntroduction To Terraform
Introduction To Terraform
 
Hive data migration (export/import)
Hive data migration (export/import)Hive data migration (export/import)
Hive data migration (export/import)
 
HaskellとDebianの辛くて甘い関係
HaskellとDebianの辛くて甘い関係HaskellとDebianの辛くて甘い関係
HaskellとDebianの辛くて甘い関係
 
Refactoring terraform
Refactoring terraformRefactoring terraform
Refactoring terraform
 
Terraform 0.9 + good practices
Terraform 0.9 + good practicesTerraform 0.9 + good practices
Terraform 0.9 + good practices
 
Everything as Code with Terraform
Everything as Code with TerraformEverything as Code with Terraform
Everything as Code with Terraform
 
Hadoop spark performance comparison
Hadoop spark performance comparisonHadoop spark performance comparison
Hadoop spark performance comparison
 
Stack kicker devopsdays-london-2013
Stack kicker devopsdays-london-2013Stack kicker devopsdays-london-2013
Stack kicker devopsdays-london-2013
 
Move spfile from asm to file system
Move spfile from asm to file systemMove spfile from asm to file system
Move spfile from asm to file system
 
R hive tutorial supplement 3 - Rstudio-server setup for rhive
R hive tutorial supplement 3 - Rstudio-server setup for rhiveR hive tutorial supplement 3 - Rstudio-server setup for rhive
R hive tutorial supplement 3 - Rstudio-server setup for rhive
 
Oracle database - Get external data via HTTP, FTP and Web Services
Oracle database - Get external data via HTTP, FTP and Web ServicesOracle database - Get external data via HTTP, FTP and Web Services
Oracle database - Get external data via HTTP, FTP and Web Services
 
Python mongo db-training-europython-2011
Python mongo db-training-europython-2011Python mongo db-training-europython-2011
Python mongo db-training-europython-2011
 
DevOps Enabling Your Team
DevOps Enabling Your TeamDevOps Enabling Your Team
DevOps Enabling Your Team
 

Similar to CCF #1: Taking the reins of your data with Hiera 5

Introduction To Apache Mesos
Introduction To Apache MesosIntroduction To Apache Mesos
Introduction To Apache Mesos
Joe Stein
 
Python (Jinja2) Templates for Network Automation
Python (Jinja2) Templates for Network AutomationPython (Jinja2) Templates for Network Automation
Python (Jinja2) Templates for Network Automation
Rick Sherman
 
Puppet overview
Puppet overviewPuppet overview
Puppet overview
Mike_Foto
 
SaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
SaltConf14 - Ben Cane - Using SaltStack in High Availability EnvironmentsSaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
SaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
SaltStack
 
High Performance Computing (HPC) in cloud
High Performance Computing (HPC) in cloudHigh Performance Computing (HPC) in cloud
High Performance Computing (HPC) in cloud
Accubits Technologies
 
Cloud Meetup - Automation in the Cloud
Cloud Meetup - Automation in the CloudCloud Meetup - Automation in the Cloud
Cloud Meetup - Automation in the Cloud
petriojala123
 
Foreman presentation
Foreman presentationForeman presentation
Foreman presentation
Glen Ogilvie
 
Reusable, composable, battle-tested Terraform modules
Reusable, composable, battle-tested Terraform modulesReusable, composable, battle-tested Terraform modules
Reusable, composable, battle-tested Terraform modules
Yevgeniy Brikman
 
Data manipulation for configuration management using Ansible
Data manipulation for configuration management using AnsibleData manipulation for configuration management using Ansible
Data manipulation for configuration management using Ansible
Joel W. King
 
Ansible
AnsibleAnsible
Ansible
Michal Haták
 
NOSQL and Cassandra
NOSQL and CassandraNOSQL and Cassandra
NOSQL and Cassandrarantav
 
Learning Puppet basic thing
Learning Puppet basic thing Learning Puppet basic thing
Learning Puppet basic thing
DaeHyung Lee
 
Streamline Hadoop DevOps with Apache Ambari
Streamline Hadoop DevOps with Apache AmbariStreamline Hadoop DevOps with Apache Ambari
Streamline Hadoop DevOps with Apache Ambari
Alejandro Fernandez
 
Going beyond Code: Driving automation with data via Hiera
Going beyond Code: Driving automation with data via HieraGoing beyond Code: Driving automation with data via Hiera
Going beyond Code: Driving automation with data via Hiera
Dylan Cochran
 
Going beyond Code: Driving automation with data via Hiera
Going beyond Code: Driving automation with data via HieraGoing beyond Code: Driving automation with data via Hiera
Going beyond Code: Driving automation with data via Hiera
OnyxPoint Inc
 
Using hiera with puppet
Using hiera with puppetUsing hiera with puppet
Using hiera with puppet
Scott Lackey
 
CfgMgmtCamp 2023 - Puppet is YAML.pdf
CfgMgmtCamp 2023 - Puppet is YAML.pdfCfgMgmtCamp 2023 - Puppet is YAML.pdf
CfgMgmtCamp 2023 - Puppet is YAML.pdf
Martin Alfke
 
Elasticsearch
ElasticsearchElasticsearch
Elasticsearch
Andrii Gakhov
 
Bare Metal to OpenStack with Razor and Chef
Bare Metal to OpenStack with Razor and ChefBare Metal to OpenStack with Razor and Chef
Bare Metal to OpenStack with Razor and Chef
Matt Ray
 
Ansible automation tool with modules
Ansible automation tool with modulesAnsible automation tool with modules
Ansible automation tool with modulesmohamedmoharam
 

Similar to CCF #1: Taking the reins of your data with Hiera 5 (20)

Introduction To Apache Mesos
Introduction To Apache MesosIntroduction To Apache Mesos
Introduction To Apache Mesos
 
Python (Jinja2) Templates for Network Automation
Python (Jinja2) Templates for Network AutomationPython (Jinja2) Templates for Network Automation
Python (Jinja2) Templates for Network Automation
 
Puppet overview
Puppet overviewPuppet overview
Puppet overview
 
SaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
SaltConf14 - Ben Cane - Using SaltStack in High Availability EnvironmentsSaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
SaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
 
High Performance Computing (HPC) in cloud
High Performance Computing (HPC) in cloudHigh Performance Computing (HPC) in cloud
High Performance Computing (HPC) in cloud
 
Cloud Meetup - Automation in the Cloud
Cloud Meetup - Automation in the CloudCloud Meetup - Automation in the Cloud
Cloud Meetup - Automation in the Cloud
 
Foreman presentation
Foreman presentationForeman presentation
Foreman presentation
 
Reusable, composable, battle-tested Terraform modules
Reusable, composable, battle-tested Terraform modulesReusable, composable, battle-tested Terraform modules
Reusable, composable, battle-tested Terraform modules
 
Data manipulation for configuration management using Ansible
Data manipulation for configuration management using AnsibleData manipulation for configuration management using Ansible
Data manipulation for configuration management using Ansible
 
Ansible
AnsibleAnsible
Ansible
 
NOSQL and Cassandra
NOSQL and CassandraNOSQL and Cassandra
NOSQL and Cassandra
 
Learning Puppet basic thing
Learning Puppet basic thing Learning Puppet basic thing
Learning Puppet basic thing
 
Streamline Hadoop DevOps with Apache Ambari
Streamline Hadoop DevOps with Apache AmbariStreamline Hadoop DevOps with Apache Ambari
Streamline Hadoop DevOps with Apache Ambari
 
Going beyond Code: Driving automation with data via Hiera
Going beyond Code: Driving automation with data via HieraGoing beyond Code: Driving automation with data via Hiera
Going beyond Code: Driving automation with data via Hiera
 
Going beyond Code: Driving automation with data via Hiera
Going beyond Code: Driving automation with data via HieraGoing beyond Code: Driving automation with data via Hiera
Going beyond Code: Driving automation with data via Hiera
 
Using hiera with puppet
Using hiera with puppetUsing hiera with puppet
Using hiera with puppet
 
CfgMgmtCamp 2023 - Puppet is YAML.pdf
CfgMgmtCamp 2023 - Puppet is YAML.pdfCfgMgmtCamp 2023 - Puppet is YAML.pdf
CfgMgmtCamp 2023 - Puppet is YAML.pdf
 
Elasticsearch
ElasticsearchElasticsearch
Elasticsearch
 
Bare Metal to OpenStack with Razor and Chef
Bare Metal to OpenStack with Razor and ChefBare Metal to OpenStack with Razor and Chef
Bare Metal to OpenStack with Razor and Chef
 
Ansible automation tool with modules
Ansible automation tool with modulesAnsible automation tool with modules
Ansible automation tool with modules
 

Recently uploaded

Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Enhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZEnhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZ
Globus
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 

Recently uploaded (20)

Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Enhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZEnhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZ
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 

CCF #1: Taking the reins of your data with Hiera 5

  • 1.
  • 2. A brief introduction to Casual Config Fridays seminars and the idea behind them
  • 3. S M T W T F S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 < October >
  • 4. CONFIG TRAINING A comprehensive introduction to the Puppet infrastructure Hostgroups And we can keep specializing… It’s everything about grouping it-puppet-hostgroup-webstuff webstuff/backendwebstuff/frontend webstuff/frontend/atlas webstuff/frontend/cms Welcome to the training Why are we here? Puppet infrastructure Get to know the infrastructure and all the components that allow us to offer Configuration management at CERN. High availability As part of the training you’ll learn how to define alias to ensure that at any moment multiple machines can attend your users’ requests. Handle secrets in your configuration No one wants to share a password with people who shouldn’t have access. Let’s use secrets! Configure just once Learning how to configure your services is as important as defining configuration in a way that you can replicate it easily across your machines. Learn the mechanism to share code Why spend time on tasks that other people in the community have solved before? Solve your questions We’ll cover what we think is important for you to know, but we are here to solve your questions. Don’t hesitate to raise your hand if you have any! Environments Differences between them 10 production qa new Production Machines in this environment will get all the config from the master branch of the repositories and is designed for production machines that focus on stability. QA This environment is usually used by a portion of the production machines to test new shared changes. All the code will come from qa branches. New At any point you can create a new environment to test changes in a more isolated way. 4 1
  • 5. Introduction to the basic concepts of Hiera, usage examples and description of the priority chain
  • 6. /haɪra/ 06 First things first Yeah, pretty much everyone says it wrong…
  • 7. 07 Hiera 101 What it is and how it works A key/value store abstraction based in YAML files A key lookup resolution mechanism A hierarchical data organization A data composition mechanism (defaults, overrides, merges…)
  • 8. 08 punch/puppet/ps.yaml --- osrepos_epel_exclude_pkgs: - puppetserver pluginsync_filter: - archive - puppetdbquery - puppetserver cernpuppet::puppetdb::puppetdb_server: "constable.cern.ch" A simple Hiera file A simple Hiera file
  • 9. Understanding the hierarchy The global layer from the most to the least specific Fully qualified domain name Data can be assigned to a specific hostname Subhostgroups Searched from most to least specific Hostgroup and environment Different data can be assigned to, for example, production and qa Hostgroup and operating system Each hostgroup has hieradata available for operating sytem Toplevel hostgroup Has the last lookup in the hostgroup tree
  • 10. 10 Environment Data specific to the Puppet environment Operatingsystem Global operating system variables Hardware vendor Specific to the vendor (or maintainer) of the hardware Module Data for the module Common Global data Datacenter Target the different datacenters (i.e. meyrin)
  • 11. Learning to fetch your data using automatic lookups, useful functions and command line tools
  • 12. 12 Getting your data Two different lookup mechanisms Automatic lookup Puppet automatically looks for class parameters values using the fully qualified name when those are not explicitly provided Explicit lookup Uses Hiera to retrieve the value for a key, allowing data validation and different strategies to define how to fetch data
  • 13. 13 Automatic class parameter lookup hg_webserver/manifests/backend.pp class hg_webserver::backend { include ::yum } webserver/backend.yaml --- yum::clean_old_kernels: false yum/manifests/init.pp class yum ( Boolean $clean_old_kernels = true, ) { ... }
  • 14. 14 code/manifest/webserver/frontend.pp class hg_webserver::frontend { $backend_url = lookup('backend_url') $backend_port = lookup('backend_port', { 'default_value' => 80, 'merge' => 'first', }) } webserver/backend.yaml --- backend_port: 8080 backend_url: "mywebserver.cern.ch" The lookup function
  • 15. 15 Merging data Four different merge behaviors First No merge. First found, first used Unique (array merge) Combines any number of array and scalar values into an array Hash Combines keys and values of any number of hashes to return a merged hash Deep Similar to hash, but if the same key exists in multiple source hashes, Hiera recursively merges them
  • 16. 16 location/pdx.yaml profile::server::time_servers: "time.pdx.example.com" common.yaml profile::server::time_servers: - 0.pool.ntp.org - 1.pool.ntp.org lookup('profile::server::time_servers', {merge => 'first'}) 'time.pdx.example.com’ First strategy
  • 17. 17 location/pdx.yaml profile::server::time_servers: "time.pdx.example.com" common.yaml profile::server::time_servers: - 0.pool.ntp.org - 1.pool.ntp.org lookup('profile::server::time_servers', {merge => 'unique'}) [ 'time.pdx.example.com’, '0.pool.ntp.org', '1.pool.ntp.org’, ] Unique strategy
  • 18. 18 lookup('site_users', {merge => 'hash'}) { "ash" => { group => "common", uid => 502, shell => "/bin/zsh" } "bob" => { group => "ops", uid => 1000 }, "jen" => { group => "ops", uid => 503, shell => "/bin/zsh" }, } groups/ops.yaml site_users: bob: group: ops uid: 1000 jen: group: ops shell: /bin/zsh uid: 503 common.yaml site_users: ash: group: common shell: /bin/zsh uid: 502 bob: shell: /bin/bash uid: 501 Hash strategy
  • 19. 19 lookup('site_users', {merge => 'deep'}) { "ash" => { group => "common", uid => 502, shell => "/bin/zsh" } "bob" => { group => "ops", uid => 1000, shell => "/bin/bash" }, "jen" => { group => "ops", uid => 503, shell => "/bin/zsh" }, } groups/ops.yaml site_users: bob: group: ops uid: 1000 jen: group: ops shell: /bin/zsh uid: 503 common.yaml site_users: ash: group: common shell: /bin/zsh uid: 502 bob: shell: /bin/bash uid: 501 Deep strategy
  • 20. 20 Deprecated functions Time to update your manifests hiera_array (141 uses) hiera (4381 uses) hiera_hash (258 uses) hiera_include (6 uses)
  • 21. Definition of not-so-static Hiera values using variables and functions interpolations
  • 22. 23 Interpolating variables Four different possible sources Puppet variables Most common way. Get’s the value from a Puppet variable Trusted hash Accurate values extracted from the node’s certificate Facts hash Contains all node’s facts. Structured ones are shown up as a nested structure
  • 23. 22 webserver/backend.yaml --- # Puppet variable interpolation server_name: "%{servername}" # Facts hash interpolation smtpserver: "mail.%{facts.networking.domain}" # mail.cern.ch # Trusted hash interpolation webserver::frontend::backend_url: "%{trusted.hostname}.cern.ch" Interpolating variables
  • 24. 24 Interpolating functions Lookups and beyond lookup Looks up a key using Hiera, and interpolates the values into a string scope An alternative way to interpolate a variable. Not generally useful literal A way to write a literal percent sign (%) without accidentally interpolating something alias Looks up a key using Hiera, and uses the value as a replacement for the enclosing
  • 25. 25 webserver/backend.yaml --- # lookup interpolation webserver::backend::database_server: "%{lookup('mysql::public_hostname')}" # scope interpolation smtpserver: "mail.%{facts.domain}" smtpserver: "mail.%{scope('facts.domain')}" # literal interpolation server_name_string: "%{literal('%')}{SERVER_NAME}" # alias interpolation original: - 'one' - 'two' aliased: "%{alias('original’)}" Interpolating functions
  • 26. Upgrading and cleaning our code with Hiera 5 and defining custom strategies
  • 27. 27 Global, environment and module Three different layers of configuration Global layer Define all the levels of the hierarchy Environment layer Merged with the global layer in our deployment Module layer Allows to set defaults for a module’s class parameters
  • 28. 28 Implementing Hiera 5 The hiera.yaml format Module level data is defined in a hiera.yaml file Must include the version (v5) The hierarchy key configures the data hierarchy The defaults key define default values for the backend and datadir keys
  • 29. 29 hiera.yaml --- version: 5 defaults: datadir: 'data' data_hash: 'yaml_data' hierarchy: - name: 'Full Version' path: '%{facts.os.name}-%{facts.os.release.full}.yaml' - name: 'Major Version' path: '%{facts.os.name}-%{facts.os.release.major}.yaml' - name: 'Operating System Family' path: '%{facts.os.family}-family.yaml' - name: 'common' path: 'common.yaml' A hiera.yaml example
  • 30. 30 Defining strategies The lookup_options key Any data source can set a lookup_options key This key controls the merge behavior of other keys Puppet lookups will first check for lookup_options The lookup_options keys are merged by Puppet using hash merge before deciding a merge behavior
  • 31. 31 Defining strategies code/data/common.yaml lookup_options: ntp::servers: merge: unique "^profile::(.*)::users$": merge: deep ntp::servers: "ntp.cern.ch" code/data/rhel-7.yaml lookup_options: "^profile::(.*)::users$": merge: hash # Actual values after the hash_merge { "ntp::servers" => { merge => "unique" } "^profile::(.*)::users$" => { merge => "hash" }, }
  • 32. Things to remember… Just an small summary 32
  • 33.
  • 34. 34 Some useful links Click & Go Migrating to Hiera 5 Best module to use us an example of best practices Automatic class parameter lookup Hiera documentation in configdocs
  • 35. 35 And some more… Again, Click & Go Interesting talk on Hiera by Hendrik Lindberg Further options for deep strategy behaviour More information on interpolation Deprecated functions and alternatives