SlideShare a Scribd company logo
1 of 104
Download to read offline
Package Managers
and Puppet
Joe Damato
packagecloud.io
slides available at:
blog.packagecloud.io
hi, i’m joe
i like computers
i once had a blog
called timetobleed.com
@joedamato
packagecloud.io
@packagecloudio
marc falardeau, https://flic.kr/p/8gKeGS
Wade M, https://flic.kr/p/5aghr9
Why?
• Central to maintaining, building, and testing
infrastructure.
• Packages are a primitive in Puppet.
• Understanding where packages come from, and how
to store them properly is a requirement for
infrastructure of any size.
• Packages and packaging are much trickier than they
seem!
Overview
• what is a package?
• what is a package manager?
• ./configure && make && make install pattern
• open source tools for package repositories
• HOWTO manage repos in your infra with puppet
What is a package?
Beck Gusler, https://flic.kr/p/4A15jm
Flavors
• packages come in many flavors
• 2 relatively important flavors
are…
RPM deb
RPM Internals
• Used on CentOS, RHEL, Scientific Linux, Fedora,
…
• files typically have the “.rpm” file extension
• can be inspected, installed, and removed with rpm
• are actually a:
• header structure (binary data)
• CPIO archive
sounds simple
but it barely works
• librpm CPIO reader lolz
• GPG signing/verifying RPMs
story time
gpg v3 signatures
%__gpg_sign_cmd %{__gpg} 
gpg --force-v3-sigs --digest-
algo=sha1 --batch --no-verbose --no-
armor --passphrase-fd 3 --no-secmem-
warning -u "%{_gpg_name}" -sbo %
{__signature_filename} %
{__plaintext_filename}
(hi)
man 8 rpm
for more lies info:
deb internals
• Deb packages:
• Used on Ubuntu, Debian, Knoppix, …
• files typically have the “.deb” file extension
• can be inspected, installed, and removed with
dpkg
deb internals
• Deb packages:
• are actually an AR archive with:
• version file: the debian format version
• data.tar.gz: the actual files to write to the
filesystem
• control.tar.gz: the package metadata
sounds simple
but it barely works
• debsigs vs dpkg-sig
• gpg signing is pointless
• XML policy documents
story time
/etc/debsig/policies/
DDDF2F4CE732A79A/hi.pol
<?xml version="1.0"?>
<!DOCTYPE Policy SYSTEM "http://www.debian.org/debsig/1.0/policy.dtd">
<Policy xmlns="http://www.debian.org/debsig/1.0/">
!
<Origin Name="test" id="DDDF2F4CE732A79A" Description="Test package"/>
!
<Selection>
<Required Type="origin" File="debsig.gpg" id="DDDF2F4CE732A79A"/>
</Selection>
!
<Verification MinOptional="0">
<Required Type="origin" File="debsig.gpg" id="DDDF2F4CE732A79A"/>
</Verification>
</Policy>
(hi)
man 1 dpkg
for more lies info:
anw
Lots of flavors
• There are lots more! (ruby gems, npm, java,
python, …)
• Some packaging systems also have source
packages.
What is a source package?
• A source package consists of:
• metadata (version, architecture(s), build deps,
etc).
• source files (C source, C++ source, py scripts,
etc).
• Allows you to rebuild a binary package easily.
Install packages with puppet
Use the resource type ‘package’:
package { 'pygpgme':
ensure => latest,
}
Install packages with puppet
package { 'pygpgme':
ensure => ‘0.3-11’,
}
Specify the version you want:
Summary
• Packages are a collection of files with metadata.
• The metadata usually has info like:
• architecture
• version
• dependency info
• and more.
• Installation is easy if you don’t have dependencies.
Dependencies
Nick Sieger, https://flic.kr/p/qQu1e
Dependencies
• Installing 1 package is as easy as:
• dpkg -i filename.deb
• rpm -ivh filename.rpm
• Of course, you should use puppet instead :D
• But what if your program needs other programs?
• For example: nginx depends on libssl, zlib, …
r-hol, https://flic.kr/p/6UZb98
So, what’s a package
manager?
Package manager
• A package manager is a collection of software
that allows you to:
• install, upgrade, remove packages
• query package info from local system or repos
• Some tools include more advanced features like
mirroring or more advanced caching features.
Common package managers
http://en.wikipedia.org/wiki/
Yellowdog_Updater,_Modified#mediaviewer/File:Yum.png
• yum (Yellowdog Updater, Modified)
• Common on RHEL, CentOS, Fedora, …
• Used for installing, removing, configuring, and
querying RPM packages and dependencies.
Common package managers
Common package managers
APT
Common package managers
• APT (Advanced Package Tool)
• Common on Debian, Ubuntu, KNOPPIX, …
• Used for installing, removing, configuring, and
querying Debian packages and dependencies.
Install packages with puppet
• puppet automatically detects which package
manager to use.
• Don’t need to worry about which command to
run, or what options to pass; puppet will take
care of that for you!
Summary
• package managers help you install software and
associated dependencies
• easily remove, upgrade, and query packages
• Puppet will automatically detect the system’s
package manager when you install a package.
almost forgot…
neither actually work
• https
• more GPG madness
story time
Kellie Parker, https://flic.kr/p/mtNMb
A problem
• You run Ubuntu 10.04 LTS
• You want to install redis
• Ubuntu 10.04 comes with redis-server 1.2.0-1
• That’s too old! You need 2.8.19!
• So, now what?
Common (not great) solution
• A common solution to this sort of problem is
building redis (or ruby, or …) from source in your
puppet manifest
• Like this….
exec { 'install-redis':
command => "make && make install PREFIX=${redis_bin_dir}",
cwd => $redis_src_dir,
path => '/bin:/usr/bin',
unless => "test $(${redis_bin_dir}/bin/redis-server --version | cut -d
' ' -f 1) = ‘Redis'",
require => [ Exec['unpack-redis'], Class['gcc'] ],
}
Common (not great) solution
Why?
• It’s easy!
• ./configure && make && make install
• It works!
• I’m using puppet so it’s reproducible!
But…
• What happens if you need to:
• completely remove Redis?
• install a security update?
• install a new version?
• install the same exact Redis on 200 machines?
The not-so great side
• Not all Makefiles have uninstall targets, so you
have to remove files manually
• Leaving artifacts on the filesystem can cause
really, really hard to debug problems later
• If the build process changes version to version,
it can be painful to rollback
The not-so great side
• Rebuilding the same source does not necessarily
get you the same byte-for-byte binary
• If the binaries aren’t identical, you can end up
with bugs in some of the compiled binaries but
not others
• Painful to recreate source builds inside of puppet
• Makes writing tests for manifests painful
Make a package
• Install the same binary on every machine
• When the package is removed, all installed files are
removed
• Versioning of build process built in (with most tools)
• Keep your puppet manifests about config
management
• Your build steps are “factored out” into the package
Your new puppet manifest
package { 'redis':
ensure => latest,
}
Your package
• Your build steps get encapsulated in the package
itself
• Makes iterating on the build more straight forward
• Don’t need to apply (potentially) a bunch of
manifests to a machine every time you do a build
Duncan Hull, https://flic.kr/p/iVLZt
“How do I make a package?”
OZinOH, https://flic.kr/p/bRHn2v
Use tools!
• debbuild
• rpmbuild
• fpm
• mock and pbuilder (more advanced)
Tradeoffs
• Takes time to learn new tools
• Takes time to understand packaging
• No one ever has enough time
BUT…
Tradeoffs
• Once you learn how to make packages you can
build reproducible infrastructure much more
easily
• You can use your prod environment in dev and
test
• You can more easily build tests for your
infrastructure with beaker/kitchen.ci
Duncan Hull, https://flic.kr/p/iVLZt
“How do I store and
organize my packages?”
Package repositories
• Major linux distributions keep repositories of
packages for users:
• EPEL
• Ubuntu / Debian official repositories
• You can store a package and its dependencies to
make it easy to install them all on your infrastructure
OZinOH, https://flic.kr/p/bRHn2v
Package repositories
• createrepo: creates yum repositories
• reprepro: creates apt repositories
• Many other free tools available!
• Read the documentation carefully. Lots of tricky
options.
• I’ll show some examples to get you started!
createrepo
http://en.wikipedia.org/wiki/
Yellowdog_Updater,_Modified#mediaviewer/File:Yum.png
createrepo
• mkdir /var/www/myrepo
• cp /path/to/rpms/*.rpm /var/www/myrepo
• createrepo /var/www/myrepo
• gpg --detach-sign --armor /var/www/my/repo/repomd.xml
GPG is important
• Using GPG to sign the generated repository
guarantees that you generated the repository.
• This is important.
• This means that no one else modified, removed, or
inserted a package other than you.
• GPG signing the repository is not a very well known
security measure, but it is incredibly important!
• This is NOT the same as using rpmsign/rpm --sign.
Secure YUM repos
• Sign repository metadata with GPG
• Sign packages with GPG (use rpmsign)
• Serve repositories over SSL
• Enable all the right options for SSL verification,
repository GPG checking, AND package GPG
checking.
Wouldn’t it be cool to do all
that with Puppet instead?
Good news: you can!
createrepo via puppet
Puppet can create YUM repositories for you!
$ puppet module install palli-createrepo
createrepo { 'yumrepo':
repository_dir => '/var/yumrepos/yumrepo',
repo_cache_dir => '/var/cache/yumrepos/yumrepo'
}
createrepo via puppet
You still need to GPG sign
the repository yourself :(
exec { “gpg_sign_yumrepo”:
command => “gpg --detach-sign --armor
/var/yumrepos/yumrepo/repodata/repomd.xml“,
}
Once the repository is created, it must
be added to the client machines.
Add YUM repos with puppet
yumrepo { 'my_repo':
baseurl => "http://myurl.com/repo",
gpgcheck => 1,
repo_gpgcheck => 1,
gpgkey => “http://myurl.com/gpg.pub.key”,
sslverify => 1,
sslcacert => “/etc/pki/tls/certs/ca-bundle.crt”,
enabled => 1,
}
most people never turn on repo_gpgcheck or
sslverify, or set the ssl certificate path, but you
should!!
But that’s not all!
• You MUST have the ‘pygpgme’ package
installed on the system that will verify the
signatures.
• Without pygpgme, yum will not be able to verify
signatures!
• Some versions of CentOS / RHEL do not
automatically install pygpgme with yum!!
Make sure to install pygpgme
package { 'pygpgme':
ensure => latest,
}
OR
just use packagecloud.io
instead
reprepro
APT
reprepro
• mkdir /var/www/myrepo
• mkdir /var/www/myrepo/conf
• Create a file named “distributions” in the conf
directory
reprepro
Codename: precise
Components: main
Architectures: i386 amd64
SignWith: 7ABDB001
/var/www/myrepo/conf/distributions:
reprepro
• You can add more sections if you need more code
names (lucid, trusty, etc).
• SignWith specifies which GPG key to use for signing
repository metadata
• You can get your gpg key ID by looking at the output
of gpg —list-keys
• This is not the same as using debsigs/debsign !!!
reprepro
import your Ubuntu 12.04 packages:
reprepro -b /var/www/myrepo/ includedeb precise filename.deb
Wouldn’t it be cool to do all
that with Puppet instead?
Good news: you can!
reprepro via puppet
Puppet can create APT repositories for you!
$ puppet module install jtopjian-reprepro
# Base Directory shortcut
$basedir = '/var/lib/apt/repo'
!
# Main reprepro class
class { 'reprepro':
basedir => $basedir,
}
!
# Set up a repository
reprepro::repository { 'localpkgs':
ensure => present,
basedir => $basedir,
options => ['basedir .'],
}
reprepro via puppet
# Create a distribution within that repository
reprepro::distribution { 'precise':
basedir => $basedir,
repository => 'localpkgs',
origin => 'Foobar',
label => 'Foobar',
suite => 'precise',
architectures => 'amd64 i386',
components => 'main contrib non-free',
description => ‘My repo',
sign_with => 'F4D5DAA8',
not_automatic => 'No',
}
reprepro via puppet
Add APT repos with puppet
apt::source { 'myrepo':
location => ‘http://myurl.com/repo',
release => 'precise',
repos => 'main',
key => '7ABDB001',
key_source => ‘http://myurl.com/gpg.pub.key',
include_src => true,
}
$ puppet module install puppetlabs-apt
But that’s not all!
• You MUST have the ‘apt-transport-https’ package
installed on the system if your repository is served
over HTTPS!
• Without apt-transport-https, you can’t install
packages over HTTPS.
• You definitely want this.
Make sure to install apt-transport-https
package { ‘apt-transport-https‘:
ensure => latest,
}
OR
just use packagecloud.io
instead
Alosh Bennett, https://flic.kr/p/WJ7rE
Success
• You can now use beaker/kitchen.ci/etc to test your
infrastructure.
• Determine if the packages you need are actually
installed after your manifests are applied.
• Determine if the repositories you added are
actually added after your manifests are applied.
• Don’t need to wait forever for Ruby, redis, et al to
build during a test run.
BEST OF ALL !!!!
• You can now run Puppet on your development
VM using the same manifests you use in
production
• The manifests are applied and you are running
the same exact binaries you run in production
• Won’t catch ALL production bugs, but getting
closer to production during development is
super useful
Summary
• Creating package repositories can be tricky. Make
sure to GPG sign repository metadata.
• 99% of package repositories get this wrong.
• Carefully read the documentation of createrepo and
reprepro.
• Make sure to install necessary libraries for verifying
signatures and accessing repositories via HTTPS.
• Always serve up your repositories over HTTPS.
Use puppet to automate this.
?@packagecloudio
https://packagecloud.io
joe@packagecloud.io

More Related Content

What's hot

DiUS Computing Lca Rails Final
DiUS  Computing Lca Rails FinalDiUS  Computing Lca Rails Final
DiUS Computing Lca Rails FinalRobert Postill
 
Puppet for SysAdmins
Puppet for SysAdminsPuppet for SysAdmins
Puppet for SysAdminsPuppet
 
Automate Yo'self -- SeaGL
Automate Yo'self -- SeaGL Automate Yo'self -- SeaGL
Automate Yo'self -- SeaGL John Anderson
 
Cfgmgmt Challenges aren't technical anymore
Cfgmgmt Challenges aren't technical anymoreCfgmgmt Challenges aren't technical anymore
Cfgmgmt Challenges aren't technical anymoreJulien Pivotto
 
Modern Perl for the Unfrozen Paleolithic Perl Programmer
Modern Perl for the Unfrozen Paleolithic Perl ProgrammerModern Perl for the Unfrozen Paleolithic Perl Programmer
Modern Perl for the Unfrozen Paleolithic Perl ProgrammerJohn Anderson
 
Porting your favourite cmdline tool to Android
Porting your favourite cmdline tool to AndroidPorting your favourite cmdline tool to Android
Porting your favourite cmdline tool to AndroidVlatko Kosturjak
 
Ripping web accessible .git files
Ripping web accessible .git filesRipping web accessible .git files
Ripping web accessible .git filesVlatko Kosturjak
 
Wonderful world of (distributed) SCM or VCS
Wonderful world of (distributed) SCM or VCSWonderful world of (distributed) SCM or VCS
Wonderful world of (distributed) SCM or VCSVlatko Kosturjak
 
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...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...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...
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...Puppet
 
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...Jérôme Petazzoni
 
Puppet at DemonWare - Ruaidhri Power - Puppetcamp Dublin '12
Puppet at DemonWare - Ruaidhri Power - Puppetcamp Dublin '12Puppet at DemonWare - Ruaidhri Power - Puppetcamp Dublin '12
Puppet at DemonWare - Ruaidhri Power - Puppetcamp Dublin '12Puppet
 
Puppet Camp Atlanta 2014: DEV Toolsets for Ops (Beginner) -
Puppet Camp Atlanta 2014: DEV Toolsets for Ops (Beginner) - Puppet Camp Atlanta 2014: DEV Toolsets for Ops (Beginner) -
Puppet Camp Atlanta 2014: DEV Toolsets for Ops (Beginner) - Puppet
 
Aucklug slides - desktop tips and tricks
Aucklug slides - desktop tips and tricksAucklug slides - desktop tips and tricks
Aucklug slides - desktop tips and tricksGlen Ogilvie
 
Puppet Camp Berlin 2015: Felix Frank | Rapid Testing Setups for Puppet
Puppet Camp Berlin 2015: Felix Frank | Rapid Testing Setups for PuppetPuppet Camp Berlin 2015: Felix Frank | Rapid Testing Setups for Puppet
Puppet Camp Berlin 2015: Felix Frank | Rapid Testing Setups for PuppetNETWAYS
 
Building Open-source React Components
Building Open-source React ComponentsBuilding Open-source React Components
Building Open-source React ComponentsZack Argyle
 
Building Open-Source React Components
Building Open-Source React ComponentsBuilding Open-Source React Components
Building Open-Source React ComponentsZack Argyle
 
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::SynchronyFast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::SynchronyKyle Drake
 

What's hot (20)

DiUS Computing Lca Rails Final
DiUS  Computing Lca Rails FinalDiUS  Computing Lca Rails Final
DiUS Computing Lca Rails Final
 
Docker perl build
Docker perl buildDocker perl build
Docker perl build
 
Puppet for SysAdmins
Puppet for SysAdminsPuppet for SysAdmins
Puppet for SysAdmins
 
Automate Yo'self -- SeaGL
Automate Yo'self -- SeaGL Automate Yo'self -- SeaGL
Automate Yo'self -- SeaGL
 
Cfgmgmt Challenges aren't technical anymore
Cfgmgmt Challenges aren't technical anymoreCfgmgmt Challenges aren't technical anymore
Cfgmgmt Challenges aren't technical anymore
 
Modern Perl for the Unfrozen Paleolithic Perl Programmer
Modern Perl for the Unfrozen Paleolithic Perl ProgrammerModern Perl for the Unfrozen Paleolithic Perl Programmer
Modern Perl for the Unfrozen Paleolithic Perl Programmer
 
Porting your favourite cmdline tool to Android
Porting your favourite cmdline tool to AndroidPorting your favourite cmdline tool to Android
Porting your favourite cmdline tool to Android
 
Automate Yo' Self
Automate Yo' SelfAutomate Yo' Self
Automate Yo' Self
 
Ripping web accessible .git files
Ripping web accessible .git filesRipping web accessible .git files
Ripping web accessible .git files
 
Wonderful world of (distributed) SCM or VCS
Wonderful world of (distributed) SCM or VCSWonderful world of (distributed) SCM or VCS
Wonderful world of (distributed) SCM or VCS
 
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...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
 
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...
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
 
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...
 
Puppet at DemonWare - Ruaidhri Power - Puppetcamp Dublin '12
Puppet at DemonWare - Ruaidhri Power - Puppetcamp Dublin '12Puppet at DemonWare - Ruaidhri Power - Puppetcamp Dublin '12
Puppet at DemonWare - Ruaidhri Power - Puppetcamp Dublin '12
 
Puppet Camp Atlanta 2014: DEV Toolsets for Ops (Beginner) -
Puppet Camp Atlanta 2014: DEV Toolsets for Ops (Beginner) - Puppet Camp Atlanta 2014: DEV Toolsets for Ops (Beginner) -
Puppet Camp Atlanta 2014: DEV Toolsets for Ops (Beginner) -
 
Aucklug slides - desktop tips and tricks
Aucklug slides - desktop tips and tricksAucklug slides - desktop tips and tricks
Aucklug slides - desktop tips and tricks
 
Puppet Camp Berlin 2015: Felix Frank | Rapid Testing Setups for Puppet
Puppet Camp Berlin 2015: Felix Frank | Rapid Testing Setups for PuppetPuppet Camp Berlin 2015: Felix Frank | Rapid Testing Setups for Puppet
Puppet Camp Berlin 2015: Felix Frank | Rapid Testing Setups for Puppet
 
Building Open-source React Components
Building Open-source React ComponentsBuilding Open-source React Components
Building Open-source React Components
 
Building Open-Source React Components
Building Open-Source React ComponentsBuilding Open-Source React Components
Building Open-Source React Components
 
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::SynchronyFast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
 

Similar to Package manages and Puppet - PuppetConf 2015

Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)Puppet
 
Package Management and Chef - ChefConf 2015
Package Management and Chef - ChefConf 2015Package Management and Chef - ChefConf 2015
Package Management and Chef - ChefConf 2015Chef
 
Open Source Tools for Leveling Up Operations FOSSET 2014
Open Source Tools for Leveling Up Operations FOSSET 2014Open Source Tools for Leveling Up Operations FOSSET 2014
Open Source Tools for Leveling Up Operations FOSSET 2014Mandi Walls
 
Package anything with fpm cookery
Package anything with fpm cookeryPackage anything with fpm cookery
Package anything with fpm cookeryMarcelo Pinheiro
 
Using nu get the way you should svcc
Using nu get the way you should   svccUsing nu get the way you should   svcc
Using nu get the way you should svccMaarten Balliauw
 
Build and deployment
Build and deploymentBuild and deployment
Build and deploymentWO Community
 
2015 TechSummit Web & Cloud - Gem, NPM, Bower, Nuget, Paket - Päckchen hier, ...
2015 TechSummit Web & Cloud - Gem, NPM, Bower, Nuget, Paket - Päckchen hier, ...2015 TechSummit Web & Cloud - Gem, NPM, Bower, Nuget, Paket - Päckchen hier, ...
2015 TechSummit Web & Cloud - Gem, NPM, Bower, Nuget, Paket - Päckchen hier, ...Daniel Fisher
 
Packaging perl (LPW2010)
Packaging perl (LPW2010)Packaging perl (LPW2010)
Packaging perl (LPW2010)p3castro
 
Course 102: Lecture 22: Package Management
Course 102: Lecture 22: Package Management Course 102: Lecture 22: Package Management
Course 102: Lecture 22: Package Management Ahmed El-Arabawy
 
Django dev-env-my-way
Django dev-env-my-wayDjango dev-env-my-way
Django dev-env-my-wayRobert Lujo
 
Habitat Overview
Habitat OverviewHabitat Overview
Habitat OverviewMandi Walls
 
Deploying software at Scale
Deploying software at ScaleDeploying software at Scale
Deploying software at ScaleKris Buytaert
 
Go for SysAdmins - LISA 2015
Go for SysAdmins - LISA 2015Go for SysAdmins - LISA 2015
Go for SysAdmins - LISA 2015Chris McEniry
 
Using Vagrant, Puppet, Testing & Hadoop
Using Vagrant, Puppet, Testing & HadoopUsing Vagrant, Puppet, Testing & Hadoop
Using Vagrant, Puppet, Testing & HadoopPuppet
 
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & HadoopPuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & HadoopWalter Heck
 
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & HadoopPuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & HadoopOlinData
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014biicode
 
Joe Damato
Joe DamatoJoe Damato
Joe DamatoOntico
 
OSDC 2016 - Continous Integration in Data Centers - Further 3 Years later by ...
OSDC 2016 - Continous Integration in Data Centers - Further 3 Years later by ...OSDC 2016 - Continous Integration in Data Centers - Further 3 Years later by ...
OSDC 2016 - Continous Integration in Data Centers - Further 3 Years later by ...NETWAYS
 
The New Frontend Toolchain
The New Frontend ToolchainThe New Frontend Toolchain
The New Frontend ToolchainBruno Abrantes
 

Similar to Package manages and Puppet - PuppetConf 2015 (20)

Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
 
Package Management and Chef - ChefConf 2015
Package Management and Chef - ChefConf 2015Package Management and Chef - ChefConf 2015
Package Management and Chef - ChefConf 2015
 
Open Source Tools for Leveling Up Operations FOSSET 2014
Open Source Tools for Leveling Up Operations FOSSET 2014Open Source Tools for Leveling Up Operations FOSSET 2014
Open Source Tools for Leveling Up Operations FOSSET 2014
 
Package anything with fpm cookery
Package anything with fpm cookeryPackage anything with fpm cookery
Package anything with fpm cookery
 
Using nu get the way you should svcc
Using nu get the way you should   svccUsing nu get the way you should   svcc
Using nu get the way you should svcc
 
Build and deployment
Build and deploymentBuild and deployment
Build and deployment
 
2015 TechSummit Web & Cloud - Gem, NPM, Bower, Nuget, Paket - Päckchen hier, ...
2015 TechSummit Web & Cloud - Gem, NPM, Bower, Nuget, Paket - Päckchen hier, ...2015 TechSummit Web & Cloud - Gem, NPM, Bower, Nuget, Paket - Päckchen hier, ...
2015 TechSummit Web & Cloud - Gem, NPM, Bower, Nuget, Paket - Päckchen hier, ...
 
Packaging perl (LPW2010)
Packaging perl (LPW2010)Packaging perl (LPW2010)
Packaging perl (LPW2010)
 
Course 102: Lecture 22: Package Management
Course 102: Lecture 22: Package Management Course 102: Lecture 22: Package Management
Course 102: Lecture 22: Package Management
 
Django dev-env-my-way
Django dev-env-my-wayDjango dev-env-my-way
Django dev-env-my-way
 
Habitat Overview
Habitat OverviewHabitat Overview
Habitat Overview
 
Deploying software at Scale
Deploying software at ScaleDeploying software at Scale
Deploying software at Scale
 
Go for SysAdmins - LISA 2015
Go for SysAdmins - LISA 2015Go for SysAdmins - LISA 2015
Go for SysAdmins - LISA 2015
 
Using Vagrant, Puppet, Testing & Hadoop
Using Vagrant, Puppet, Testing & HadoopUsing Vagrant, Puppet, Testing & Hadoop
Using Vagrant, Puppet, Testing & Hadoop
 
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & HadoopPuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
 
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & HadoopPuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014
 
Joe Damato
Joe DamatoJoe Damato
Joe Damato
 
OSDC 2016 - Continous Integration in Data Centers - Further 3 Years later by ...
OSDC 2016 - Continous Integration in Data Centers - Further 3 Years later by ...OSDC 2016 - Continous Integration in Data Centers - Further 3 Years later by ...
OSDC 2016 - Continous Integration in Data Centers - Further 3 Years later by ...
 
The New Frontend Toolchain
The New Frontend ToolchainThe New Frontend Toolchain
The New Frontend Toolchain
 

Recently uploaded

Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Hararemasabamasaba
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 

Recently uploaded (20)

Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 

Package manages and Puppet - PuppetConf 2015

  • 1. Package Managers and Puppet Joe Damato packagecloud.io
  • 3. hi, i’m joe i like computers i once had a blog called timetobleed.com @joedamato
  • 7. Why? • Central to maintaining, building, and testing infrastructure. • Packages are a primitive in Puppet. • Understanding where packages come from, and how to store them properly is a requirement for infrastructure of any size. • Packages and packaging are much trickier than they seem!
  • 8. Overview • what is a package? • what is a package manager? • ./configure && make && make install pattern • open source tools for package repositories • HOWTO manage repos in your infra with puppet
  • 9. What is a package? Beck Gusler, https://flic.kr/p/4A15jm
  • 10.
  • 11.
  • 12.
  • 13. Flavors • packages come in many flavors • 2 relatively important flavors are…
  • 15.
  • 16. RPM Internals • Used on CentOS, RHEL, Scientific Linux, Fedora, … • files typically have the “.rpm” file extension • can be inspected, installed, and removed with rpm • are actually a: • header structure (binary data) • CPIO archive
  • 17. sounds simple but it barely works
  • 18. • librpm CPIO reader lolz • GPG signing/verifying RPMs story time
  • 19. gpg v3 signatures %__gpg_sign_cmd %{__gpg} gpg --force-v3-sigs --digest- algo=sha1 --batch --no-verbose --no- armor --passphrase-fd 3 --no-secmem- warning -u "%{_gpg_name}" -sbo % {__signature_filename} % {__plaintext_filename}
  • 20. (hi)
  • 21. man 8 rpm for more lies info:
  • 22.
  • 23. deb internals • Deb packages: • Used on Ubuntu, Debian, Knoppix, … • files typically have the “.deb” file extension • can be inspected, installed, and removed with dpkg
  • 24. deb internals • Deb packages: • are actually an AR archive with: • version file: the debian format version • data.tar.gz: the actual files to write to the filesystem • control.tar.gz: the package metadata
  • 25. sounds simple but it barely works
  • 26. • debsigs vs dpkg-sig • gpg signing is pointless • XML policy documents story time
  • 27. /etc/debsig/policies/ DDDF2F4CE732A79A/hi.pol <?xml version="1.0"?> <!DOCTYPE Policy SYSTEM "http://www.debian.org/debsig/1.0/policy.dtd"> <Policy xmlns="http://www.debian.org/debsig/1.0/"> ! <Origin Name="test" id="DDDF2F4CE732A79A" Description="Test package"/> ! <Selection> <Required Type="origin" File="debsig.gpg" id="DDDF2F4CE732A79A"/> </Selection> ! <Verification MinOptional="0"> <Required Type="origin" File="debsig.gpg" id="DDDF2F4CE732A79A"/> </Verification> </Policy>
  • 28. (hi)
  • 29. man 1 dpkg for more lies info:
  • 30. anw
  • 31. Lots of flavors • There are lots more! (ruby gems, npm, java, python, …) • Some packaging systems also have source packages.
  • 32. What is a source package? • A source package consists of: • metadata (version, architecture(s), build deps, etc). • source files (C source, C++ source, py scripts, etc). • Allows you to rebuild a binary package easily.
  • 33. Install packages with puppet Use the resource type ‘package’: package { 'pygpgme': ensure => latest, }
  • 34. Install packages with puppet package { 'pygpgme': ensure => ‘0.3-11’, } Specify the version you want:
  • 35. Summary • Packages are a collection of files with metadata. • The metadata usually has info like: • architecture • version • dependency info • and more. • Installation is easy if you don’t have dependencies.
  • 37. Dependencies • Installing 1 package is as easy as: • dpkg -i filename.deb • rpm -ivh filename.rpm • Of course, you should use puppet instead :D • But what if your program needs other programs? • For example: nginx depends on libssl, zlib, …
  • 39. So, what’s a package manager?
  • 40. Package manager • A package manager is a collection of software that allows you to: • install, upgrade, remove packages • query package info from local system or repos • Some tools include more advanced features like mirroring or more advanced caching features.
  • 42. • yum (Yellowdog Updater, Modified) • Common on RHEL, CentOS, Fedora, … • Used for installing, removing, configuring, and querying RPM packages and dependencies. Common package managers
  • 44. Common package managers • APT (Advanced Package Tool) • Common on Debian, Ubuntu, KNOPPIX, … • Used for installing, removing, configuring, and querying Debian packages and dependencies.
  • 45. Install packages with puppet • puppet automatically detects which package manager to use. • Don’t need to worry about which command to run, or what options to pass; puppet will take care of that for you!
  • 46. Summary • package managers help you install software and associated dependencies • easily remove, upgrade, and query packages • Puppet will automatically detect the system’s package manager when you install a package.
  • 49. • https • more GPG madness story time
  • 51. A problem • You run Ubuntu 10.04 LTS • You want to install redis • Ubuntu 10.04 comes with redis-server 1.2.0-1 • That’s too old! You need 2.8.19! • So, now what?
  • 52. Common (not great) solution • A common solution to this sort of problem is building redis (or ruby, or …) from source in your puppet manifest • Like this….
  • 53. exec { 'install-redis': command => "make && make install PREFIX=${redis_bin_dir}", cwd => $redis_src_dir, path => '/bin:/usr/bin', unless => "test $(${redis_bin_dir}/bin/redis-server --version | cut -d ' ' -f 1) = ‘Redis'", require => [ Exec['unpack-redis'], Class['gcc'] ], } Common (not great) solution
  • 54. Why? • It’s easy! • ./configure && make && make install • It works! • I’m using puppet so it’s reproducible!
  • 55. But… • What happens if you need to: • completely remove Redis? • install a security update? • install a new version? • install the same exact Redis on 200 machines?
  • 56. The not-so great side • Not all Makefiles have uninstall targets, so you have to remove files manually • Leaving artifacts on the filesystem can cause really, really hard to debug problems later • If the build process changes version to version, it can be painful to rollback
  • 57. The not-so great side • Rebuilding the same source does not necessarily get you the same byte-for-byte binary • If the binaries aren’t identical, you can end up with bugs in some of the compiled binaries but not others • Painful to recreate source builds inside of puppet • Makes writing tests for manifests painful
  • 58. Make a package • Install the same binary on every machine • When the package is removed, all installed files are removed • Versioning of build process built in (with most tools) • Keep your puppet manifests about config management • Your build steps are “factored out” into the package
  • 59. Your new puppet manifest package { 'redis': ensure => latest, }
  • 60. Your package • Your build steps get encapsulated in the package itself • Makes iterating on the build more straight forward • Don’t need to apply (potentially) a bunch of manifests to a machine every time you do a build
  • 62. “How do I make a package?”
  • 64. Use tools! • debbuild • rpmbuild • fpm • mock and pbuilder (more advanced)
  • 65. Tradeoffs • Takes time to learn new tools • Takes time to understand packaging • No one ever has enough time
  • 67. Tradeoffs • Once you learn how to make packages you can build reproducible infrastructure much more easily • You can use your prod environment in dev and test • You can more easily build tests for your infrastructure with beaker/kitchen.ci
  • 69. “How do I store and organize my packages?”
  • 70. Package repositories • Major linux distributions keep repositories of packages for users: • EPEL • Ubuntu / Debian official repositories • You can store a package and its dependencies to make it easy to install them all on your infrastructure
  • 72. Package repositories • createrepo: creates yum repositories • reprepro: creates apt repositories • Many other free tools available! • Read the documentation carefully. Lots of tricky options. • I’ll show some examples to get you started!
  • 74. createrepo • mkdir /var/www/myrepo • cp /path/to/rpms/*.rpm /var/www/myrepo • createrepo /var/www/myrepo • gpg --detach-sign --armor /var/www/my/repo/repomd.xml
  • 75. GPG is important • Using GPG to sign the generated repository guarantees that you generated the repository. • This is important. • This means that no one else modified, removed, or inserted a package other than you. • GPG signing the repository is not a very well known security measure, but it is incredibly important! • This is NOT the same as using rpmsign/rpm --sign.
  • 76. Secure YUM repos • Sign repository metadata with GPG • Sign packages with GPG (use rpmsign) • Serve repositories over SSL • Enable all the right options for SSL verification, repository GPG checking, AND package GPG checking.
  • 77. Wouldn’t it be cool to do all that with Puppet instead? Good news: you can!
  • 78. createrepo via puppet Puppet can create YUM repositories for you! $ puppet module install palli-createrepo
  • 79. createrepo { 'yumrepo': repository_dir => '/var/yumrepos/yumrepo', repo_cache_dir => '/var/cache/yumrepos/yumrepo' } createrepo via puppet
  • 80. You still need to GPG sign the repository yourself :( exec { “gpg_sign_yumrepo”: command => “gpg --detach-sign --armor /var/yumrepos/yumrepo/repodata/repomd.xml“, }
  • 81. Once the repository is created, it must be added to the client machines.
  • 82. Add YUM repos with puppet yumrepo { 'my_repo': baseurl => "http://myurl.com/repo", gpgcheck => 1, repo_gpgcheck => 1, gpgkey => “http://myurl.com/gpg.pub.key”, sslverify => 1, sslcacert => “/etc/pki/tls/certs/ca-bundle.crt”, enabled => 1, } most people never turn on repo_gpgcheck or sslverify, or set the ssl certificate path, but you should!!
  • 83. But that’s not all! • You MUST have the ‘pygpgme’ package installed on the system that will verify the signatures. • Without pygpgme, yum will not be able to verify signatures! • Some versions of CentOS / RHEL do not automatically install pygpgme with yum!!
  • 84. Make sure to install pygpgme package { 'pygpgme': ensure => latest, }
  • 87. reprepro • mkdir /var/www/myrepo • mkdir /var/www/myrepo/conf • Create a file named “distributions” in the conf directory
  • 88. reprepro Codename: precise Components: main Architectures: i386 amd64 SignWith: 7ABDB001 /var/www/myrepo/conf/distributions:
  • 89. reprepro • You can add more sections if you need more code names (lucid, trusty, etc). • SignWith specifies which GPG key to use for signing repository metadata • You can get your gpg key ID by looking at the output of gpg —list-keys • This is not the same as using debsigs/debsign !!!
  • 90. reprepro import your Ubuntu 12.04 packages: reprepro -b /var/www/myrepo/ includedeb precise filename.deb
  • 91. Wouldn’t it be cool to do all that with Puppet instead? Good news: you can!
  • 92. reprepro via puppet Puppet can create APT repositories for you! $ puppet module install jtopjian-reprepro
  • 93. # Base Directory shortcut $basedir = '/var/lib/apt/repo' ! # Main reprepro class class { 'reprepro': basedir => $basedir, } ! # Set up a repository reprepro::repository { 'localpkgs': ensure => present, basedir => $basedir, options => ['basedir .'], } reprepro via puppet
  • 94. # Create a distribution within that repository reprepro::distribution { 'precise': basedir => $basedir, repository => 'localpkgs', origin => 'Foobar', label => 'Foobar', suite => 'precise', architectures => 'amd64 i386', components => 'main contrib non-free', description => ‘My repo', sign_with => 'F4D5DAA8', not_automatic => 'No', } reprepro via puppet
  • 95. Add APT repos with puppet apt::source { 'myrepo': location => ‘http://myurl.com/repo', release => 'precise', repos => 'main', key => '7ABDB001', key_source => ‘http://myurl.com/gpg.pub.key', include_src => true, } $ puppet module install puppetlabs-apt
  • 96. But that’s not all! • You MUST have the ‘apt-transport-https’ package installed on the system if your repository is served over HTTPS! • Without apt-transport-https, you can’t install packages over HTTPS. • You definitely want this.
  • 97. Make sure to install apt-transport-https package { ‘apt-transport-https‘: ensure => latest, }
  • 100. Success • You can now use beaker/kitchen.ci/etc to test your infrastructure. • Determine if the packages you need are actually installed after your manifests are applied. • Determine if the repositories you added are actually added after your manifests are applied. • Don’t need to wait forever for Ruby, redis, et al to build during a test run.
  • 101. BEST OF ALL !!!! • You can now run Puppet on your development VM using the same manifests you use in production • The manifests are applied and you are running the same exact binaries you run in production • Won’t catch ALL production bugs, but getting closer to production during development is super useful
  • 102. Summary • Creating package repositories can be tricky. Make sure to GPG sign repository metadata. • 99% of package repositories get this wrong. • Carefully read the documentation of createrepo and reprepro. • Make sure to install necessary libraries for verifying signatures and accessing repositories via HTTPS. • Always serve up your repositories over HTTPS.
  • 103. Use puppet to automate this.