Augeas, swiss knife resources for your puppet tree

Julien Pivotto
Julien PivottoOpen Source Consultant at Inuits
. 
AAuuggeeaass 
SSwwiissss--kknniiffee rreessoouurrcceess ffoorr yyoouurr ppuuppppeett ttrreeee 
Julien Pivotto 
Belgian Puppet User Group 
Holiday is over Meetup!!! - November 12th, 2014
. 
wwhhooaammii 
JJuulliieenn PPiivvoottttoo 
• Open-Source consultant at inuits.eu 
• FOSS defender since 2004 
• DevOps believer and evangelist 
• Puppet User since 2011 
• @roidelapluie on twitter/github
. 
. 
ınuits.eu
. 
. 
SSyyssaaddmmiinn 110011 
CC BY-SA 2.0 https://www.flickr.com/photos/arthur-caranta/2926332140
. 
SSeettttiinngg uupp aa sseerrvviiccee 
• Install the package 
• Change the configuration 
• Start the daemon
. 
3 steps. 
What can go wrong?
. 
PPaacckkaaggiinngg 
• Where is the package? 
• Which version do we need? 
• Does it conflict with something else?
. 
. 
DDeeppeennddeenncciieess HHeellll 
CC BY-SA 2.0 https://www.flickr.com/photos/coconinonationalforest/4587053982
. 
CCoonnffiigguurraattiioonn 
• Where is the file? 
• How many files? 
• Configuration is in the database? 
• The file is *huge*
. 
SSttaarrttiinngg tthhee sseerrvviiccee 
• Does not start 
▶ Bad config file 
▶ Stale lock file 
▶ Data corruption 
• High Availability 
• Replication
. 
LLeett''ss ttaallkk aabboouutt PPuuppppeett aanndd ffiilleess 
• Classical approach: File[] resource 
• Advanced approach: Concat[] define 
• Broken approach: Exec[sed] resource 
• Surgical approach: Augeas[] resource
. 
HHiiddddeenn wwaayyss ttoommaannaaggee ffiilleess 
• Ssh_authorized_key[] 
• Nagios_* 
• To purge or not to purge
. 
. 
TThhee FFiillee[[]] rreessoouurrccee 
CC BY 2.0 https://www.flickr.com/photos/80497449@N04/10567875696/
. 
FFiillee 
• Built-in puppet resource 
• Most used 
• Works with a lot of usecases 
• Text files, binary files
. 
. 
file{"${::icinga::confdir_server}/cgi.cfg": 
ensure => present, 
content => template('icinga/redhat/cgi.cfg.erb'), 
owner => $::icinga::server_user, 
group => $::icinga::server_group, 
require => Class['icinga::config'], 
notify => [ 
Service[$::icinga::service_client], 
Service[$::icinga::service_server], 
Exec['fix_collected_permissions'] 
], 
} 
.
. 
CCoonntteenntt ooff aa ffiillee 
• content => String, template(), file() 
• source => puppet:///, /local/file
. 
FFiillee[[]] bbeehhaavviioouurr 
• Array as "source": Puppet will pick the first 
available one 
• Multiple arguments to template(): Puppet 
will concatenate them all 
• File[/foo/bar] will autorequire File[/foo]
. 
DDoowwnnssiiddee ooff FFiillee[[]] 
• You can only have at one "content" 
• That resource describe the whole file 
• Works in almost every situation
. 
. 
concat 
Public Domain http://commons.wikimedia.org/wiki/File:Adhesive_tapes_clear.JPG
. 
CCoonnccaatt 
• A "reference" puppet module: 
puppetlabs/concat 
• https://github.com/puppetlabs/puppetlabs-concat 
• Provides definitions to manage file 
• Alternative modules: 
▶ onyxpoint/pupmod-concat 
▶ theforeman/puppet-concat (fork of onyxpoint)
. 
CCoonnccaatt?? 
• Concat takes a bunch of snippets 
• Assemble them info a file 
• Each snippet is a define 
• The final file is a define
. 
. 
concat { '/tmp/file': 
ensure => present, 
} 
concat::fragment { 'tmpfile': 
target => '/tmp/file', 
content => 'test contents', 
order => '01' 
} 
.
. 
BBaassee aanndd ffrraaggmmeennttss 
• Concat[] defines owner, ensure, mode of the 
file 
• Concat::Fragment[] defines the contents of 
the file 
• One Concat[] has multiple 
Concat::Fragment[]
. 
AAddvvaannttaaggeess ooff ccoonnccaatt 
• More flexibility 
▶ if 
▶ virtual resource 
▶ exported resources 
▶ create_resources 
• Mix templates and files
. 
DDiissaaddvvaannttaaggeess ooff ccoonnccaatt 
• External Puppet module 
• Concat[] is the whole file 
• Performances
. 
. 
Exec{sed: onlyif => grep} 
CC BY-SA 3.0 http://commons.wikimedia.org/wiki/File:Ca%C3%AFn_par_Henri_Vidal.jpg
. 
. 
https://github.com/search?o=desc&q=exec+sed+onlyif+grep+language%3APuppet
. 
eexxeecc[[sseedd]] iiss bbrr00kkeenn 
• Which options to pass to sed and grep? 
• You should use as few Exec[] as possible 
• grep .... 
• Escape, regexes…
. 
AAnnootthheerr aalltteerrnnaattiivvee:: ccoonnff..dd 
• Some services support conf.d directories 
• But it is hard to change existing parameters 
• In which order are the files read? 
• Don't forget to purge
. 
. 
Augeas 
CC BY-SA 3.0 http://commons.wikimedia.org/wiki/File:Students_assisting_surgery.JPG
. 
AAuuggeeaass 
• Configuration editing tool 
• First release in 2007 
• API coded in C 
• Command-line tools 
• bindings for different languages
. 
CCoonnffiigguurraattiioonn eeddiittiinngg ttooooll 
• Parsing the configuration files 
• Turning them into a tree 
• Edit the tree & save the configuration
. 
. 
$ cat /etc/nsswitch.conf 
# /etc/nsswitch.conf 
## 
Example configuration 
# 
passwd: db files 
group: db files 
initgroups: db [SUCCESS=continue] files 
shadow: db files 
gshadow: files 
.
. 
. 
augtool> ls /files/etc/nsswitch.conf/ 
#comment[1] = /etc/nsswitch.conf 
#comment[2] = Example configuration 
database[1]/ = passwd 
database[2]/ = group 
database[3]/ = initgroups 
database[4]/ = shadow 
database[5]/ = gshadow 
.
. 
. 
augtool> ls /files/etc/nsswitch.conf/database[1]/ 
service[1] = db 
service[2] = files 
.
. 
NNaattiivvee ffoorrmmaatt -->> ttrreeee 
• Augeas understand comments 
• Augeas does not care about empty lines 
• The cli tool (augtool) has autocomplete 
• It recognize a lot of formats
. 
. 
augtool> set /files/etc/nsswitch.conf/database[1]/ 
service[last()+1] ldap 
augtool> save 
Saved 1 file(s) 
.
. 
. 
$ cat /etc/nsswitch.conf 
# /etc/nsswitch.conf 
## 
Example configuration 
# 
passwd: db files ldap 
group: db files 
initgroups: db [SUCCESS=continue] files 
shadow: db files 
gshadow: files 
.
. 
. 
augtool> match /files/etc/nsswitch.conf/*/* ldap 
/files/etc/nsswitch.conf/database[1]/service[3] 
augtool> print /files/etc/nsswitch.conf/database[1] 
/files/etc/nsswitch.conf/database[1] = "passwd" 
/files/etc/nsswitch.conf/database[1]/service[1] = "db" 
/files/etc/nsswitch.conf/database[1]/service[2] = "files" 
/files/etc/nsswitch.conf/database[1]/service[3] = "ldap" 
.
. 
. 
augtool> rm /files/etc/nsswitch.conf/database[1]/service[3] 
rm : /files/etc/nsswitch.conf/database[1]/service[3] 1 
augtool> print /files/etc/nsswitch.conf/database[1] 
/files/etc/nsswitch.conf/database[1] = "passwd" 
/files/etc/nsswitch.conf/database[1]/service[1] = "db" 
/files/etc/nsswitch.conf/database[1]/service[2] = "files" 
augtool> save 
Saved 1 file(s) 
.
. 
OOnnee AAPPII ttoo eeddiitt tthheemmaallll 
• Can talk XML, ini, named, nginx, … 
• Only change what is needed 
• Ensure the syntax is right
. 
AAuuggeeaass LLeennsseess 
• Lenses are files that explain how to edit files 
• It contains paths and syntax 
• There are a lot of them available 
• You can write your own lenses
. 
”This brings the total number of lenses to 
178. […] It’s depressing to think that 
Linux/Unix systems have managed to grow 
this many special snowflake formats.” 
David Lutterkort, main developer 
about Augeas 1.3.0
. 
117788 lleennsseess 
activemq_conf activemq_xml aliases aptconf 
apt_update_manager backuppchosts bbhosts bootconf build 
carbon cgrules channels cobblermodules cobblersettings collectd 
crypttab cyrus_imapd darkice debctrl desktop device_map dhcpd 
dnsmasq dovecot dpkg dput ethers exports fai_diskconfig fonts 
fuse gdm grub gshadow hostname inetd inputrc interfaces iproute2 
iptables jaas jmxaccess keepalived known_hosts koji krb5 ldif limits 
login_defs logrotate mcollective memcached mke2fs 
mongodbserver mysql nagioscfg nagiosobjects netmasks nginx ntp 
ntpd odbc openshift_config openshift_http openvpn pam passwd 
pbuilder postfix_main postfix_transport postfix_virtual 
puppet_auth qpid rabbitmq resolv rmt securetty sep services shells 
shellvars_list sip_conf slapd smbusers squid sshd stunnel 
subversion sudoers sysconfig systemd thttpd up2date vfstab
. 
AA sshhoorrtt lleennssee 
. 
module Hostname = 
autoload xfm 
(* View: lns *) 
let lns = [ label "hostname" . store Rx.word . Util.eol ] 
(* View: filter *) 
let filter = incl "/etc/hostname" 
. incl "/etc/mailname" 
let xfm = transform lns filter 
.
. 
PPuuppppeett <<33 aauuggeeaass 
• Native "augeas" resource 
• Support for pluginsync 
• Helpers available
. 
PPuuppppeett eexxaammppllee 
. 
augeas { $name: 
context => "/files${fstab::variables::fstab_file}", 
changes => [ 
"rm ${fstab_match_line}", 
], 
onlyif => "match ${fstab_match_line} size > 0" 
} 
.
. 
RReeaall uusseeccaasseess 
• Change grub options 
• Modify /etc/hosts 
• Modify XML's (puppetlabs-tomcat) 
• Configure Jenkins
. 
PPlluuggiinnssyynncc 
• Puppet has pluginsync support for Augeas 
• Drop your lenses in your modules 
• lib/augeas/lenses 
• Use the "lens" parameter of the augeas 
resource
. 
PPuuppppeett eexxaammppllee 
. 
augeas{"jboss_conf": 
. 
context => "/files/etc/jbossas", 
changes => [ 
"set jbossas.conf/JBOSS_IP $ipaddress", 
"set jbossas.conf/JAVA_HOME /usr", 
], 
lens => "Jboss.aug", 
}
. 
AAuuggeeaass ccoommmmaannddss 
set rm mv clear insert …
. 
AAuuggeeaass ccoommppaarraattoorrss ((oonnllyyiiff)) 
match get
. 
AAuuggeeaasspprroovviiddeerrss 
• Helpers around augeas 
• Puppet modules 
• No augeas knowledge needed
. 
aappaacchhee 
. 
apache_setenv { "SPECIAL_PATH": 
ensure => present, 
value => "/foo/bin", 
} 
.
. 
kkeerrnneell__ppaarraammeetteerr 
. 
kernel_parameter { "quiet": 
ensure => present, 
bootmode => "normal", 
} 
.
. 
Conclusion
. 
DDiissaaddvvaannttaaggeess 
• Learning required 
• Library to install 
• Writing lenses is hard
. 
AAddvvaannttaaggeess 
• Augeas is a mature tool 
• Preserves comments in files 
• It fails (if needed) 
• Only changes what is needed 
• A lot of lenses available 
• Puppet integration 
• Helpers available
. 
FFiinnaall nnoottee 
Most of the time, File[] resources are the way 
to go. Augeas can help when you need to 
change files generated by an application or 
that you can not manage entirely.
. 
RReeaaddiinnggss 
• http://augeas.net/ 
• http://augeasproviders.com/ 
• https://docs.puppetlabs.com/
. 
TThhaannkk yyoouu 
Any question? 
Thanks to @raphink
. 
CCoonnttaacctt 
Julien Pivotto 
julien@inuits.eu 
@roidelapluie 
INUITS bvba 
Belgium 
+32 473 441 636 
https://inuits.eu
1 of 62

Recommended

Vagrant and CentOS 7 by
Vagrant and CentOS 7Vagrant and CentOS 7
Vagrant and CentOS 7Julien Pivotto
15.4K views67 slides
Ansible 實戰:top down 觀點 by
Ansible 實戰:top down 觀點Ansible 實戰:top down 觀點
Ansible 實戰:top down 觀點William Yeh
19.6K views118 slides
Configuration Surgery with Augeas by
Configuration Surgery with AugeasConfiguration Surgery with Augeas
Configuration Surgery with AugeasPuppet
12.7K views38 slides
Puppet for dummies - ZendCon 2011 Edition by
Puppet for dummies - ZendCon 2011 EditionPuppet for dummies - ZendCon 2011 Edition
Puppet for dummies - ZendCon 2011 EditionJoshua Thijssen
13K views82 slides
Puppet fundamentals by
Puppet fundamentalsPuppet fundamentals
Puppet fundamentalsMurali Boyapati
1.1K views62 slides
DevOps(4) : Ansible(2) - (MOSG) by
DevOps(4) : Ansible(2) - (MOSG)DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)Soshi Nemoto
851 views49 slides

More Related Content

What's hot

DevOps(3) : Ansible - (MOSG) by
DevOps(3) : Ansible - (MOSG)DevOps(3) : Ansible - (MOSG)
DevOps(3) : Ansible - (MOSG)Soshi Nemoto
822 views26 slides
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop by
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & HadoopPuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & HadoopWalter Heck
613 views38 slides
“warpdrive”, making Python web application deployment magically easy. by
“warpdrive”, making Python web application deployment magically easy.“warpdrive”, making Python web application deployment magically easy.
“warpdrive”, making Python web application deployment magically easy.Graham Dumpleton
1.1K views54 slides
Ansible not only for Dummies by
Ansible not only for DummiesAnsible not only for Dummies
Ansible not only for DummiesŁukasz Proszek
2.4K views89 slides
Preparation study of_docker - (MOSG) by
Preparation study of_docker  - (MOSG)Preparation study of_docker  - (MOSG)
Preparation study of_docker - (MOSG)Soshi Nemoto
597 views31 slides
Deploying Symfony2 app with Ansible by
Deploying Symfony2 app with AnsibleDeploying Symfony2 app with Ansible
Deploying Symfony2 app with AnsibleRoman Rodomansky
8K views60 slides

What's hot(20)

DevOps(3) : Ansible - (MOSG) by Soshi Nemoto
DevOps(3) : Ansible - (MOSG)DevOps(3) : Ansible - (MOSG)
DevOps(3) : Ansible - (MOSG)
Soshi Nemoto822 views
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop by Walter Heck
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & HadoopPuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
Walter Heck613 views
“warpdrive”, making Python web application deployment magically easy. by Graham Dumpleton
“warpdrive”, making Python web application deployment magically easy.“warpdrive”, making Python web application deployment magically easy.
“warpdrive”, making Python web application deployment magically easy.
Graham Dumpleton1.1K views
Preparation study of_docker - (MOSG) by Soshi Nemoto
Preparation study of_docker  - (MOSG)Preparation study of_docker  - (MOSG)
Preparation study of_docker - (MOSG)
Soshi Nemoto597 views
Puppet for SysAdmins by Puppet
Puppet for SysAdminsPuppet for SysAdmins
Puppet for SysAdmins
Puppet7.2K views
Making Your Capistrano Recipe Book by Tim Riley
Making Your Capistrano Recipe BookMaking Your Capistrano Recipe Book
Making Your Capistrano Recipe Book
Tim Riley6.8K views
Take control of your Jenkins jobs via job DSL. by Łukasz Proszek
Take control of your Jenkins jobs via job DSL.Take control of your Jenkins jobs via job DSL.
Take control of your Jenkins jobs via job DSL.
Łukasz Proszek3.4K views
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo... by Puppet
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
Puppet9.7K views
From Dev to DevOps - FOSDEM 2012 by Carlos Sanchez
From Dev to DevOps - FOSDEM 2012From Dev to DevOps - FOSDEM 2012
From Dev to DevOps - FOSDEM 2012
Carlos Sanchez6.8K views
Automate with Ansible basic (2/e, English) by Chu-Siang Lai
Automate with Ansible basic (2/e, English)Automate with Ansible basic (2/e, English)
Automate with Ansible basic (2/e, English)
Chu-Siang Lai1.1K views
Vagrant for real codemotion (moar tips! ;-)) by Michele Orselli
Vagrant for real codemotion (moar tips! ;-))Vagrant for real codemotion (moar tips! ;-))
Vagrant for real codemotion (moar tips! ;-))
Michele Orselli1K views
Fabric workshop(1) - (MOSG) by Soshi Nemoto
Fabric workshop(1) - (MOSG)Fabric workshop(1) - (MOSG)
Fabric workshop(1) - (MOSG)
Soshi Nemoto533 views
PuppetCamp SEA 1 - Use of Puppet by Walter Heck
PuppetCamp SEA 1 - Use of PuppetPuppetCamp SEA 1 - Use of Puppet
PuppetCamp SEA 1 - Use of Puppet
Walter Heck1.3K views
PuppetCamp SEA 1 - Puppet Deployment at OnApp by Walter Heck
PuppetCamp SEA 1 - Puppet Deployment  at OnAppPuppetCamp SEA 1 - Puppet Deployment  at OnApp
PuppetCamp SEA 1 - Puppet Deployment at OnApp
Walter Heck638 views
Dev ninja -> vagrant + virtualbox + chef-solo + git + ec2 by Yros
Dev ninja  -> vagrant + virtualbox + chef-solo + git + ec2Dev ninja  -> vagrant + virtualbox + chef-solo + git + ec2
Dev ninja -> vagrant + virtualbox + chef-solo + git + ec2
Yros2.8K views
Automated reproducible images on openstack using vagrant and packer by Jan Collijs
Automated reproducible images on openstack using vagrant and packerAutomated reproducible images on openstack using vagrant and packer
Automated reproducible images on openstack using vagrant and packer
Jan Collijs146 views
How to Develop Puppet Modules: From Source to the Forge With Zero Clicks by Carlos Sanchez
How to Develop Puppet Modules: From Source to the Forge With Zero ClicksHow to Develop Puppet Modules: From Source to the Forge With Zero Clicks
How to Develop Puppet Modules: From Source to the Forge With Zero Clicks
Carlos Sanchez1.5K views
Create your very own Development Environment with Vagrant and Packer by frastel
Create your very own Development Environment with Vagrant and PackerCreate your very own Development Environment with Vagrant and Packer
Create your very own Development Environment with Vagrant and Packer
frastel3.6K views

Similar to Augeas, swiss knife resources for your puppet tree

LXC Containers and AUFs by
LXC Containers and AUFsLXC Containers and AUFs
LXC Containers and AUFsDocker, Inc.
1.3K views51 slides
Developing IT infrastructures with Puppet by
Developing IT infrastructures with PuppetDeveloping IT infrastructures with Puppet
Developing IT infrastructures with PuppetAlessandro Franceschi
4.2K views30 slides
Provisioning with Puppet by
Provisioning with PuppetProvisioning with Puppet
Provisioning with PuppetJoe Ray
953 views17 slides
#WeSpeakLinux Session by
#WeSpeakLinux Session#WeSpeakLinux Session
#WeSpeakLinux SessionKellyn Pot'Vin-Gorman
594 views77 slides
Webinar - Managing Files with Puppet by
Webinar - Managing Files with PuppetWebinar - Managing Files with Puppet
Webinar - Managing Files with PuppetOlinData
753 views30 slides
Linux Fundamentals by
Linux FundamentalsLinux Fundamentals
Linux FundamentalsDianaWhitney4
243 views55 slides

Similar to Augeas, swiss knife resources for your puppet tree(20)

LXC Containers and AUFs by Docker, Inc.
LXC Containers and AUFsLXC Containers and AUFs
LXC Containers and AUFs
Docker, Inc.1.3K views
Provisioning with Puppet by Joe Ray
Provisioning with PuppetProvisioning with Puppet
Provisioning with Puppet
Joe Ray953 views
Webinar - Managing Files with Puppet by OlinData
Webinar - Managing Files with PuppetWebinar - Managing Files with Puppet
Webinar - Managing Files with Puppet
OlinData753 views
Puppet: Eclipsecon ALM 2013 by grim_radical
Puppet: Eclipsecon ALM 2013Puppet: Eclipsecon ALM 2013
Puppet: Eclipsecon ALM 2013
grim_radical1.2K views
An introduction to Rex - FLOSS UK DevOps York 2015 by Andy Beverley
An introduction to Rex - FLOSS UK DevOps York 2015An introduction to Rex - FLOSS UK DevOps York 2015
An introduction to Rex - FLOSS UK DevOps York 2015
Andy Beverley4K views
Bacula Overview by sambismo
Bacula OverviewBacula Overview
Bacula Overview
sambismo1.7K views
Puppet Modules: An Holistic Approach - Alessandro Franceschi of Lab42 - Puppe... by Puppet
Puppet Modules: An Holistic Approach - Alessandro Franceschi of Lab42 - Puppe...Puppet Modules: An Holistic Approach - Alessandro Franceschi of Lab42 - Puppe...
Puppet Modules: An Holistic Approach - Alessandro Franceschi of Lab42 - Puppe...
Puppet2K views
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf... by Puppet
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Puppet5K views
Gentoo Linux, or Why in the World You Should Compile Everything by Donnie Berkholz
Gentoo Linux, or Why in the World You Should Compile EverythingGentoo Linux, or Why in the World You Should Compile Everything
Gentoo Linux, or Why in the World You Should Compile Everything
Donnie Berkholz11.2K views
Puppet getting started by Dirk Götz by NETWAYS
Puppet getting started by Dirk GötzPuppet getting started by Dirk Götz
Puppet getting started by Dirk Götz
NETWAYS1.6K views
Hadoop 20111117 by exsuns
Hadoop 20111117Hadoop 20111117
Hadoop 20111117
exsuns1.3K views
Drupal Performance - SerBenfiquista.com Case Study by hernanibf
Drupal Performance - SerBenfiquista.com Case StudyDrupal Performance - SerBenfiquista.com Case Study
Drupal Performance - SerBenfiquista.com Case Study
hernanibf3K views
Operating System Practice : Meeting 4 - operasi file dan struktur direktori-s... by Syaiful Ahdan
Operating System Practice : Meeting 4 - operasi file dan struktur direktori-s...Operating System Practice : Meeting 4 - operasi file dan struktur direktori-s...
Operating System Practice : Meeting 4 - operasi file dan struktur direktori-s...
Syaiful Ahdan478 views

More from Julien Pivotto

The O11y Toolkit by
The O11y ToolkitThe O11y Toolkit
The O11y ToolkitJulien Pivotto
38 views24 slides
What's New in Prometheus and Its Ecosystem by
What's New in Prometheus and Its EcosystemWhat's New in Prometheus and Its Ecosystem
What's New in Prometheus and Its EcosystemJulien Pivotto
12 views42 slides
Prometheus: What is is, what is new, what is coming by
Prometheus: What is is, what is new, what is comingPrometheus: What is is, what is new, what is coming
Prometheus: What is is, what is new, what is comingJulien Pivotto
43 views27 slides
What's new in Prometheus? by
What's new in Prometheus?What's new in Prometheus?
What's new in Prometheus?Julien Pivotto
15 views10 slides
Introduction to Grafana Loki by
Introduction to Grafana LokiIntroduction to Grafana Loki
Introduction to Grafana LokiJulien Pivotto
200 views11 slides
Why you should revisit mgmt by
Why you should revisit mgmtWhy you should revisit mgmt
Why you should revisit mgmtJulien Pivotto
10 views46 slides

More from Julien Pivotto(20)

What's New in Prometheus and Its Ecosystem by Julien Pivotto
What's New in Prometheus and Its EcosystemWhat's New in Prometheus and Its Ecosystem
What's New in Prometheus and Its Ecosystem
Julien Pivotto12 views
Prometheus: What is is, what is new, what is coming by Julien Pivotto
Prometheus: What is is, what is new, what is comingPrometheus: What is is, what is new, what is coming
Prometheus: What is is, what is new, what is coming
Julien Pivotto43 views
Introduction to Grafana Loki by Julien Pivotto
Introduction to Grafana LokiIntroduction to Grafana Loki
Introduction to Grafana Loki
Julien Pivotto200 views
Observing the HashiCorp Ecosystem From Prometheus by Julien Pivotto
Observing the HashiCorp Ecosystem From PrometheusObserving the HashiCorp Ecosystem From Prometheus
Observing the HashiCorp Ecosystem From Prometheus
Julien Pivotto37 views
Monitoring in a fast-changing world with Prometheus by Julien Pivotto
Monitoring in a fast-changing world with PrometheusMonitoring in a fast-changing world with Prometheus
Monitoring in a fast-changing world with Prometheus
Julien Pivotto33 views
5 tips for Prometheus Service Discovery by Julien Pivotto
5 tips for Prometheus Service Discovery5 tips for Prometheus Service Discovery
5 tips for Prometheus Service Discovery
Julien Pivotto38 views
Prometheus and TLS - an Introduction by Julien Pivotto
Prometheus and TLS - an IntroductionPrometheus and TLS - an Introduction
Prometheus and TLS - an Introduction
Julien Pivotto15 views
HAProxy as Egress Controller by Julien Pivotto
HAProxy as Egress ControllerHAProxy as Egress Controller
HAProxy as Egress Controller
Julien Pivotto2.9K views
Improved alerting with Prometheus and Alertmanager by Julien Pivotto
Improved alerting with Prometheus and AlertmanagerImproved alerting with Prometheus and Alertmanager
Improved alerting with Prometheus and Alertmanager
Julien Pivotto4.5K views
SIngle Sign On with Keycloak by Julien Pivotto
SIngle Sign On with KeycloakSIngle Sign On with Keycloak
SIngle Sign On with Keycloak
Julien Pivotto10K views
Monitoring as an entry point for collaboration by Julien Pivotto
Monitoring as an entry point for collaborationMonitoring as an entry point for collaboration
Monitoring as an entry point for collaboration
Julien Pivotto1.3K views
Monitor your CentOS stack with Prometheus by Julien Pivotto
Monitor your CentOS stack with PrometheusMonitor your CentOS stack with Prometheus
Monitor your CentOS stack with Prometheus
Julien Pivotto712 views
Monitor your CentOS stack with Prometheus by Julien Pivotto
Monitor your CentOS stack with PrometheusMonitor your CentOS stack with Prometheus
Monitor your CentOS stack with Prometheus
Julien Pivotto704 views

Recently uploaded

Why and How CloudStack at weSystems - Stephan Bienek - weSystems by
Why and How CloudStack at weSystems - Stephan Bienek - weSystemsWhy and How CloudStack at weSystems - Stephan Bienek - weSystems
Why and How CloudStack at weSystems - Stephan Bienek - weSystemsShapeBlue
238 views13 slides
"Surviving highload with Node.js", Andrii Shumada by
"Surviving highload with Node.js", Andrii Shumada "Surviving highload with Node.js", Andrii Shumada
"Surviving highload with Node.js", Andrii Shumada Fwdays
56 views29 slides
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ... by
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...ShapeBlue
126 views10 slides
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ... by
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...ShapeBlue
119 views17 slides
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT by
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBITUpdates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBITShapeBlue
206 views8 slides
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue by
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlueShapeBlue
147 views23 slides

Recently uploaded(20)

Why and How CloudStack at weSystems - Stephan Bienek - weSystems by ShapeBlue
Why and How CloudStack at weSystems - Stephan Bienek - weSystemsWhy and How CloudStack at weSystems - Stephan Bienek - weSystems
Why and How CloudStack at weSystems - Stephan Bienek - weSystems
ShapeBlue238 views
"Surviving highload with Node.js", Andrii Shumada by Fwdays
"Surviving highload with Node.js", Andrii Shumada "Surviving highload with Node.js", Andrii Shumada
"Surviving highload with Node.js", Andrii Shumada
Fwdays56 views
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ... by ShapeBlue
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
ShapeBlue126 views
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ... by ShapeBlue
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
ShapeBlue119 views
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT by ShapeBlue
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBITUpdates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
ShapeBlue206 views
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue by ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
ShapeBlue147 views
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue by ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlueMigrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
ShapeBlue218 views
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ... by ShapeBlue
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
ShapeBlue166 views
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda... by ShapeBlue
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
ShapeBlue161 views
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ... by ShapeBlue
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
ShapeBlue186 views
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online by ShapeBlue
KVM Security Groups Under the Hood - Wido den Hollander - Your.OnlineKVM Security Groups Under the Hood - Wido den Hollander - Your.Online
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online
ShapeBlue221 views
Digital Personal Data Protection (DPDP) Practical Approach For CISOs by Priyanka Aash
Digital Personal Data Protection (DPDP) Practical Approach For CISOsDigital Personal Data Protection (DPDP) Practical Approach For CISOs
Digital Personal Data Protection (DPDP) Practical Approach For CISOs
Priyanka Aash158 views
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates by ShapeBlue
Keynote Talk: Open Source is Not Dead - Charles Schulz - VatesKeynote Talk: Open Source is Not Dead - Charles Schulz - Vates
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates
ShapeBlue252 views
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P... by ShapeBlue
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
ShapeBlue194 views
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f... by TrustArc
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc170 views
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or... by ShapeBlue
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
ShapeBlue198 views
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson160 views
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue by ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlueVNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
ShapeBlue203 views
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ... by ShapeBlue
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
ShapeBlue184 views

Augeas, swiss knife resources for your puppet tree

  • 1. . AAuuggeeaass SSwwiissss--kknniiffee rreessoouurrcceess ffoorr yyoouurr ppuuppppeett ttrreeee Julien Pivotto Belgian Puppet User Group Holiday is over Meetup!!! - November 12th, 2014
  • 2. . wwhhooaammii JJuulliieenn PPiivvoottttoo • Open-Source consultant at inuits.eu • FOSS defender since 2004 • DevOps believer and evangelist • Puppet User since 2011 • @roidelapluie on twitter/github
  • 4. . . SSyyssaaddmmiinn 110011 CC BY-SA 2.0 https://www.flickr.com/photos/arthur-caranta/2926332140
  • 5. . SSeettttiinngg uupp aa sseerrvviiccee • Install the package • Change the configuration • Start the daemon
  • 6. . 3 steps. What can go wrong?
  • 7. . PPaacckkaaggiinngg • Where is the package? • Which version do we need? • Does it conflict with something else?
  • 8. . . DDeeppeennddeenncciieess HHeellll CC BY-SA 2.0 https://www.flickr.com/photos/coconinonationalforest/4587053982
  • 9. . CCoonnffiigguurraattiioonn • Where is the file? • How many files? • Configuration is in the database? • The file is *huge*
  • 10. . SSttaarrttiinngg tthhee sseerrvviiccee • Does not start ▶ Bad config file ▶ Stale lock file ▶ Data corruption • High Availability • Replication
  • 11. . LLeett''ss ttaallkk aabboouutt PPuuppppeett aanndd ffiilleess • Classical approach: File[] resource • Advanced approach: Concat[] define • Broken approach: Exec[sed] resource • Surgical approach: Augeas[] resource
  • 12. . HHiiddddeenn wwaayyss ttoommaannaaggee ffiilleess • Ssh_authorized_key[] • Nagios_* • To purge or not to purge
  • 13. . . TThhee FFiillee[[]] rreessoouurrccee CC BY 2.0 https://www.flickr.com/photos/80497449@N04/10567875696/
  • 14. . FFiillee • Built-in puppet resource • Most used • Works with a lot of usecases • Text files, binary files
  • 15. . . file{"${::icinga::confdir_server}/cgi.cfg": ensure => present, content => template('icinga/redhat/cgi.cfg.erb'), owner => $::icinga::server_user, group => $::icinga::server_group, require => Class['icinga::config'], notify => [ Service[$::icinga::service_client], Service[$::icinga::service_server], Exec['fix_collected_permissions'] ], } .
  • 16. . CCoonntteenntt ooff aa ffiillee • content => String, template(), file() • source => puppet:///, /local/file
  • 17. . FFiillee[[]] bbeehhaavviioouurr • Array as "source": Puppet will pick the first available one • Multiple arguments to template(): Puppet will concatenate them all • File[/foo/bar] will autorequire File[/foo]
  • 18. . DDoowwnnssiiddee ooff FFiillee[[]] • You can only have at one "content" • That resource describe the whole file • Works in almost every situation
  • 19. . . concat Public Domain http://commons.wikimedia.org/wiki/File:Adhesive_tapes_clear.JPG
  • 20. . CCoonnccaatt • A "reference" puppet module: puppetlabs/concat • https://github.com/puppetlabs/puppetlabs-concat • Provides definitions to manage file • Alternative modules: ▶ onyxpoint/pupmod-concat ▶ theforeman/puppet-concat (fork of onyxpoint)
  • 21. . CCoonnccaatt?? • Concat takes a bunch of snippets • Assemble them info a file • Each snippet is a define • The final file is a define
  • 22. . . concat { '/tmp/file': ensure => present, } concat::fragment { 'tmpfile': target => '/tmp/file', content => 'test contents', order => '01' } .
  • 23. . BBaassee aanndd ffrraaggmmeennttss • Concat[] defines owner, ensure, mode of the file • Concat::Fragment[] defines the contents of the file • One Concat[] has multiple Concat::Fragment[]
  • 24. . AAddvvaannttaaggeess ooff ccoonnccaatt • More flexibility ▶ if ▶ virtual resource ▶ exported resources ▶ create_resources • Mix templates and files
  • 25. . DDiissaaddvvaannttaaggeess ooff ccoonnccaatt • External Puppet module • Concat[] is the whole file • Performances
  • 26. . . Exec{sed: onlyif => grep} CC BY-SA 3.0 http://commons.wikimedia.org/wiki/File:Ca%C3%AFn_par_Henri_Vidal.jpg
  • 28. . eexxeecc[[sseedd]] iiss bbrr00kkeenn • Which options to pass to sed and grep? • You should use as few Exec[] as possible • grep .... • Escape, regexes…
  • 29. . AAnnootthheerr aalltteerrnnaattiivvee:: ccoonnff..dd • Some services support conf.d directories • But it is hard to change existing parameters • In which order are the files read? • Don't forget to purge
  • 30. . . Augeas CC BY-SA 3.0 http://commons.wikimedia.org/wiki/File:Students_assisting_surgery.JPG
  • 31. . AAuuggeeaass • Configuration editing tool • First release in 2007 • API coded in C • Command-line tools • bindings for different languages
  • 32. . CCoonnffiigguurraattiioonn eeddiittiinngg ttooooll • Parsing the configuration files • Turning them into a tree • Edit the tree & save the configuration
  • 33. . . $ cat /etc/nsswitch.conf # /etc/nsswitch.conf ## Example configuration # passwd: db files group: db files initgroups: db [SUCCESS=continue] files shadow: db files gshadow: files .
  • 34. . . augtool> ls /files/etc/nsswitch.conf/ #comment[1] = /etc/nsswitch.conf #comment[2] = Example configuration database[1]/ = passwd database[2]/ = group database[3]/ = initgroups database[4]/ = shadow database[5]/ = gshadow .
  • 35. . . augtool> ls /files/etc/nsswitch.conf/database[1]/ service[1] = db service[2] = files .
  • 36. . NNaattiivvee ffoorrmmaatt -->> ttrreeee • Augeas understand comments • Augeas does not care about empty lines • The cli tool (augtool) has autocomplete • It recognize a lot of formats
  • 37. . . augtool> set /files/etc/nsswitch.conf/database[1]/ service[last()+1] ldap augtool> save Saved 1 file(s) .
  • 38. . . $ cat /etc/nsswitch.conf # /etc/nsswitch.conf ## Example configuration # passwd: db files ldap group: db files initgroups: db [SUCCESS=continue] files shadow: db files gshadow: files .
  • 39. . . augtool> match /files/etc/nsswitch.conf/*/* ldap /files/etc/nsswitch.conf/database[1]/service[3] augtool> print /files/etc/nsswitch.conf/database[1] /files/etc/nsswitch.conf/database[1] = "passwd" /files/etc/nsswitch.conf/database[1]/service[1] = "db" /files/etc/nsswitch.conf/database[1]/service[2] = "files" /files/etc/nsswitch.conf/database[1]/service[3] = "ldap" .
  • 40. . . augtool> rm /files/etc/nsswitch.conf/database[1]/service[3] rm : /files/etc/nsswitch.conf/database[1]/service[3] 1 augtool> print /files/etc/nsswitch.conf/database[1] /files/etc/nsswitch.conf/database[1] = "passwd" /files/etc/nsswitch.conf/database[1]/service[1] = "db" /files/etc/nsswitch.conf/database[1]/service[2] = "files" augtool> save Saved 1 file(s) .
  • 41. . OOnnee AAPPII ttoo eeddiitt tthheemmaallll • Can talk XML, ini, named, nginx, … • Only change what is needed • Ensure the syntax is right
  • 42. . AAuuggeeaass LLeennsseess • Lenses are files that explain how to edit files • It contains paths and syntax • There are a lot of them available • You can write your own lenses
  • 43. . ”This brings the total number of lenses to 178. […] It’s depressing to think that Linux/Unix systems have managed to grow this many special snowflake formats.” David Lutterkort, main developer about Augeas 1.3.0
  • 44. . 117788 lleennsseess activemq_conf activemq_xml aliases aptconf apt_update_manager backuppchosts bbhosts bootconf build carbon cgrules channels cobblermodules cobblersettings collectd crypttab cyrus_imapd darkice debctrl desktop device_map dhcpd dnsmasq dovecot dpkg dput ethers exports fai_diskconfig fonts fuse gdm grub gshadow hostname inetd inputrc interfaces iproute2 iptables jaas jmxaccess keepalived known_hosts koji krb5 ldif limits login_defs logrotate mcollective memcached mke2fs mongodbserver mysql nagioscfg nagiosobjects netmasks nginx ntp ntpd odbc openshift_config openshift_http openvpn pam passwd pbuilder postfix_main postfix_transport postfix_virtual puppet_auth qpid rabbitmq resolv rmt securetty sep services shells shellvars_list sip_conf slapd smbusers squid sshd stunnel subversion sudoers sysconfig systemd thttpd up2date vfstab
  • 45. . AA sshhoorrtt lleennssee . module Hostname = autoload xfm (* View: lns *) let lns = [ label "hostname" . store Rx.word . Util.eol ] (* View: filter *) let filter = incl "/etc/hostname" . incl "/etc/mailname" let xfm = transform lns filter .
  • 46. . PPuuppppeett <<33 aauuggeeaass • Native "augeas" resource • Support for pluginsync • Helpers available
  • 47. . PPuuppppeett eexxaammppllee . augeas { $name: context => "/files${fstab::variables::fstab_file}", changes => [ "rm ${fstab_match_line}", ], onlyif => "match ${fstab_match_line} size > 0" } .
  • 48. . RReeaall uusseeccaasseess • Change grub options • Modify /etc/hosts • Modify XML's (puppetlabs-tomcat) • Configure Jenkins
  • 49. . PPlluuggiinnssyynncc • Puppet has pluginsync support for Augeas • Drop your lenses in your modules • lib/augeas/lenses • Use the "lens" parameter of the augeas resource
  • 50. . PPuuppppeett eexxaammppllee . augeas{"jboss_conf": . context => "/files/etc/jbossas", changes => [ "set jbossas.conf/JBOSS_IP $ipaddress", "set jbossas.conf/JAVA_HOME /usr", ], lens => "Jboss.aug", }
  • 51. . AAuuggeeaass ccoommmmaannddss set rm mv clear insert …
  • 52. . AAuuggeeaass ccoommppaarraattoorrss ((oonnllyyiiff)) match get
  • 53. . AAuuggeeaasspprroovviiddeerrss • Helpers around augeas • Puppet modules • No augeas knowledge needed
  • 54. . aappaacchhee . apache_setenv { "SPECIAL_PATH": ensure => present, value => "/foo/bin", } .
  • 55. . kkeerrnneell__ppaarraammeetteerr . kernel_parameter { "quiet": ensure => present, bootmode => "normal", } .
  • 57. . DDiissaaddvvaannttaaggeess • Learning required • Library to install • Writing lenses is hard
  • 58. . AAddvvaannttaaggeess • Augeas is a mature tool • Preserves comments in files • It fails (if needed) • Only changes what is needed • A lot of lenses available • Puppet integration • Helpers available
  • 59. . FFiinnaall nnoottee Most of the time, File[] resources are the way to go. Augeas can help when you need to change files generated by an application or that you can not manage entirely.
  • 60. . RReeaaddiinnggss • http://augeas.net/ • http://augeasproviders.com/ • https://docs.puppetlabs.com/
  • 61. . TThhaannkk yyoouu Any question? Thanks to @raphink
  • 62. . CCoonnttaacctt Julien Pivotto julien@inuits.eu @roidelapluie INUITS bvba Belgium +32 473 441 636 https://inuits.eu