infrastructure as data - puppetconf 2013
DESCRIPTION
"Infrastructure as Data" by Nick Lewis, Software Developer, Puppet Labs. Presentation Overview: We all know the benefits of infrastructure as code - version control, reusability, shareability, documentation, and so on. Another popular notion is that of code as data, by which code can be introspected, modified, and used for decision making. Combining the two ideas, the natural implication is that infrastructure is also data, and can be similarly introspected, modified, and used for decision making. In other words, we can do math on infrastructure. We'll look at some interesting ways this data can be filtered, combined, and applied to achieve results which would be difficult to describe directly in code. Speaker Bio: Nick Lewis is a software developer at Puppet Labs and one of the co-authors of PuppetDB.TRANSCRIPT
Infrastructure as DataNick LewisDeveloper | Puppet Labs @nick_lewis
Friday, August 23, 13
puppetconf.com #puppetconf
Infrastructure as Data
• Specified data• Manifests
• Hiera
• Node classification
• Observed data• Facts
• Generated/derived data• Catalogs
• Reports
Friday, August 23, 13
puppetconf.com #puppetconf
as aminecraft addict
I would liketime to be correct on my computer
so thatI can stop playing minecraft and go to sleep
Friday, August 23, 13
puppetconf.com #puppetconf
Infrastructure as Code
• tangible artifact
• easy to change
• documented
• repeatable
• idempotent
Friday, August 23, 13
puppetconf.com #puppetconf
yum install -y ntpif ! grep 'server 0.pool.ntp.org' /etc/ntp.conf; then echo 'server 0.pool.ntp.org' >> /etc/ntp.conffi/etc/init.d/ntpd status || /etc/init.d/ntpd start
Friday, August 23, 13
puppetconf.com #puppetconf
yum check-update ntpif [ $? -eq 100 ]; then yum install -y ntp && restart_ntp='y'fi
if ! grep 'server 0.pool.ntp.org' /etc/ntp.conf; then echo 'server 0.pool.ntp.org' >> /etc/ntp.conf restart_ntp='y'fi
if [ -n "$restart_ntp" ]; then /etc/init.d/ntpd restartelif ! /etc/init.d/ntpd status; then /etc/init.d/ntpd startfi
Friday, August 23, 13
puppetconf.com #puppetconf
Infrastructure as Bash
• platform-specific
• imperative
• ad-hoc relationships
• brittle in the face of failure
Friday, August 23, 13
puppetconf.com #puppetconf
if install_package ntp; then restart_ntp='y'fi
if add_file_line 'server 0.pool.ntp.org'; then /etc/ntp.conf && restart_ntp='y'fi
if [ 'y' = "$restart_ntp" ]; then restart_service ntpelse start_service ntpfi
Friday, August 23, 13
puppetconf.com #puppetconf
Infrastructure as Bash
• platform-specific
• slightly less imperative
• ad-hoc relationships
• brittle in the face of failure
Friday, August 23, 13
puppetconf.com #puppetconf
Infrastructure as Bash
• platform-specific
• slightly less imperative
• ad-hoc relationships
• brittle in the face of failure
Friday, August 23, 13
puppetconf.com #puppetconf
package { 'ntp': ensure => 'present', notify => Service[ntp], } file_line { 'ntp server': path => '/etc/ntp.conf', line => 'server 0.pool.ntp.org', require => Package[ntp], notify => Service[ntp], } service { 'ntp': ensure => 'running', }
Friday, August 23, 13
puppetconf.com #puppetconf
Infrastructure as Puppet
• platform-independent
• mostly declarative
• relationships are explicit
• understands failure
Friday, August 23, 13
puppetconf.com #puppetconf
class ntp { package { 'ntp': ensure => 'present', notify => Service[ntp], } file_line { 'ntp server': path => '/etc/ntp.conf', line => 'server 0.pool.ntp.org', require => Package[ntp], notify => Service[ntp], } service { 'ntp': ensure => 'running', }
Friday, August 23, 13
puppetconf.com #puppetconf
include ntp
Friday, August 23, 13
puppetconf.com #puppetconf
tell me what you wantwhat you really really want
Friday, August 23, 13
puppetconf.com #puppetconf
include magical_time_synchronization
Friday, August 23, 13
puppetconf.com #puppetconf
configuration managementthe art of making your monitoring checks pass
Friday, August 23, 13
puppetconf.com #puppetconf
abstractiongiving a name to something and then cutting it out of your life
Friday, August 23, 13
puppetconf.com #puppetconf
class ntp { package { 'ntp': ensure => 'present', notify => Service[ntp], } file_line { 'ntp server': path => '/etc/ntp.conf', line => 'server 0.pool.ntp.org', require => Package[ntp], notify => Service[ntp], } service { 'ntp': ensure => 'running', }
Friday, August 23, 13
puppetconf.com #puppetconf
package { 'ntp': }
file_line { 'ntp server': }
service { 'ntp': }
Friday, August 23, 13
puppetconf.com #puppetconf
Friday, August 23, 13
puppetconf.com #puppetconf
Friday, August 23, 13
puppetconf.com #puppetconf
time sync
Friday, August 23, 13
puppetconf.com #puppetconf
time sync
ntpd service
Friday, August 23, 13
puppetconf.com #puppetconf
time sync
ntpd service
ntp package
Friday, August 23, 13
puppetconf.com #puppetconf
time sync
ntpd service
ntp package ntp.conf
Friday, August 23, 13
puppetconf.com #puppetconf
time sync
ntpd service
ntp package ntp.conf
yum
Friday, August 23, 13
puppetconf.com #puppetconf
time sync
ntpd service
ntp package ntp.conf
yum
python
Friday, August 23, 13
puppetconf.com #puppetconf
time sync
ntpd service
ntp package ntp.conf
yum
rpmpython
Friday, August 23, 13
puppetconf.com #puppetconf
time sync
ntpd service
ntp package ntp.conf
yum
rpmpython
...
Friday, August 23, 13
puppetconf.com #puppetconf
time sync
ntpd service
ntp package ntp.conf
yum
rpmpythonntp server...
Friday, August 23, 13
puppetconf.com #puppetconf
time sync
ntpd service
ntp package ntp.conf
yum
rpmpython networkntp server...
Friday, August 23, 13
puppetconf.com #puppetconf
time sync
ntpd service
ntp package ntp.conf
yum
rpmpython networkntp server...
...
Friday, August 23, 13
puppetconf.com #puppetconf
time sync
ntpd service
ntp package ntp.conf
filesystem
yum
rpmpython networkntp server...
...
Friday, August 23, 13
puppetconf.com #puppetconf
time sync
ntpd service
ntp package ntp.conf
filesystem
yum
rpmpython networkntp server...
......
Friday, August 23, 13
puppetconf.com #puppetconf
time sync
ntpd service
ntp package ntp.conf
filesystem
yum
rpmpythonelectricity
networkntp server...
......
Friday, August 23, 13
puppetconf.com #puppetconf
time sync
ntpd service
ntp package ntp.conf
filesystem
yum
rpmpythonelectricity
networkntp server...
...... ...
Friday, August 23, 13
puppetconf.com #puppetconf
time sync
ntpd service
ntp package ntp.conf
filesystem
yum
rpmpythonelectricity
networkntp server...
...... ...
the very concept of time itself
Friday, August 23, 13
puppetconf.com #puppetconf
if you wanna be my loveryou gotta apt-get with my
friends
Friday, August 23, 13
puppetconf.com #puppetconf
requiresubscribe
Friday, August 23, 13
puppetconf.com #puppetconf
Package installs ServiceFile is the source of PackageUser owns FileFile configures ServiceUser is a member of GroupFile is the directory of FileFile is executed by Exec
Friday, August 23, 13
puppetconf.com #puppetconf
File / FileFile / UserFile / GroupUser / GroupCron / UserExec / FileExec / User
?
Friday, August 23, 13
puppetconf.com #puppetconf
file { "/home/sweet/home": ensure => present, owner => sweet, require => User[sweet],}
user { "sweet": ensure => present,}
Friday, August 23, 13
puppetconf.com #puppetconf
file { "/home/sweet/home": ensure => absent, owner => sweet, require => User[sweet],}
user { "sweet": ensure => absent,}
Friday, August 23, 13
puppetconf.com #puppetconf
file { "/home/sweet/home": ensure => present, owner => sweet, require => User[sweet],}
user { "sweet": ensure => absent,}
Friday, August 23, 13
puppetconf.com #puppetconf
file { "/home/sweet/home": ensure => present, owner => User[sweet],}
user { "sweet": ensure => absent,}
Friday, August 23, 13
puppetconf.com #puppetconf
user { "sweet": ensure => absent,}
file { "/home/sweet/home": ensure => present,}
Friday, August 23, 13
puppetconf.com #puppetconf
user { "sweet": ensure => absent,}
file { "/home/sweet/home": ensure => present,}
--ordering manifest
Friday, August 23, 13
puppetconf.com #puppetconf
user { "sweet": ensure => absent,}
file { "/home/sweet/home": ensure => present,}
--ordering random
Friday, August 23, 13
puppetconf.com #puppetconf
concat { "/etc/motd": }
concat::fragment { "motd_hello": target => "/etc/motd", content => "Hello PuppetConf!\n", order => 1,}
concat::fragment { "motd_goodbye": target => "/etc/motd", content => "Goodbye PuppetConf :(", order => 2,}
Friday, August 23, 13
puppetconf.com #puppetconf
file { "/etc/motd": ensure => present, content => "Hello PuppetConf!\nGoodbye PuppetConf :(",}
Friday, August 23, 13
puppetconf.com #puppetconf
concat::fragment { "motd_hello": target => "/etc/motd", content => "Hello PuppetConf!\n", order => 1,}
concat::fragment { "motd_goodbye": target => "/etc/motd", content => "Goodbye PuppetConf :(", order => 2,}
file { "/etc/motd": ensure => present, content => "Hello PuppetConf!\nGoodbyePuppetConf :(",
Friday, August 23, 13
Thank YouNick LewisDeveloper | Puppet Labs @nick_lewis
Collaborate. Automate. Ship.
Friday, August 23, 13
Follow us on Twitter @puppetlabs
youtube.com/puppetlabsinc
slideshare.net/puppetlabs
Collaborate. Automate. Ship.
Friday, August 23, 13