Download - Infrastructure as Data - PuppetConf 2013

Transcript
Page 1: Infrastructure as Data - PuppetConf 2013

Infrastructure as DataNick LewisDeveloper | Puppet Labs @nick_lewis

Friday, August 23, 13

Page 2: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

Infrastructure as Data

• Specified data• Manifests

• Hiera

• Node classification

• Observed data• Facts

• Generated/derived data• Catalogs

• Reports

Friday, August 23, 13

Page 3: Infrastructure as Data - PuppetConf 2013

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

Page 4: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

Infrastructure as Code

• tangible artifact

• easy to change

• documented

• repeatable

• idempotent

Friday, August 23, 13

Page 5: Infrastructure as Data - PuppetConf 2013

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

Page 6: Infrastructure as Data - PuppetConf 2013

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

Page 7: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

Infrastructure as Bash

• platform-specific

• imperative

• ad-hoc relationships

• brittle in the face of failure

Friday, August 23, 13

Page 8: Infrastructure as Data - PuppetConf 2013

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

Page 9: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

Infrastructure as Bash

• platform-specific

• slightly less imperative

• ad-hoc relationships

• brittle in the face of failure

Friday, August 23, 13

Page 10: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

Infrastructure as Bash

• platform-specific

• slightly less imperative

• ad-hoc relationships

• brittle in the face of failure

Friday, August 23, 13

Page 11: Infrastructure as Data - PuppetConf 2013

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

Page 12: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

Infrastructure as Puppet

• platform-independent

• mostly declarative

• relationships are explicit

• understands failure

Friday, August 23, 13

Page 13: Infrastructure as Data - PuppetConf 2013

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

Page 14: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

include ntp

Friday, August 23, 13

Page 15: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

tell me what you wantwhat you really really want

Friday, August 23, 13

Page 16: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

include magical_time_synchronization

Friday, August 23, 13

Page 17: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

configuration managementthe art of making your monitoring checks pass

Friday, August 23, 13

Page 18: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

abstractiongiving a name to something and then cutting it out of your life

Friday, August 23, 13

Page 19: Infrastructure as Data - PuppetConf 2013

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

Page 20: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

package { 'ntp': }

file_line { 'ntp server': }

service { 'ntp': }

Friday, August 23, 13

Page 21: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

Friday, August 23, 13

Page 22: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

Friday, August 23, 13

Page 23: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

time sync

Friday, August 23, 13

Page 24: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

time sync

ntpd service

Friday, August 23, 13

Page 25: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

time sync

ntpd service

ntp package

Friday, August 23, 13

Page 26: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

time sync

ntpd service

ntp package ntp.conf

Friday, August 23, 13

Page 27: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

time sync

ntpd service

ntp package ntp.conf

yum

Friday, August 23, 13

Page 28: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

time sync

ntpd service

ntp package ntp.conf

yum

python

Friday, August 23, 13

Page 29: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

time sync

ntpd service

ntp package ntp.conf

yum

rpmpython

Friday, August 23, 13

Page 30: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

time sync

ntpd service

ntp package ntp.conf

yum

rpmpython

...

Friday, August 23, 13

Page 31: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

time sync

ntpd service

ntp package ntp.conf

yum

rpmpythonntp server...

Friday, August 23, 13

Page 32: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

time sync

ntpd service

ntp package ntp.conf

yum

rpmpython networkntp server...

Friday, August 23, 13

Page 33: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

time sync

ntpd service

ntp package ntp.conf

yum

rpmpython networkntp server...

...

Friday, August 23, 13

Page 34: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

time sync

ntpd service

ntp package ntp.conf

filesystem

yum

rpmpython networkntp server...

...

Friday, August 23, 13

Page 35: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

time sync

ntpd service

ntp package ntp.conf

filesystem

yum

rpmpython networkntp server...

......

Friday, August 23, 13

Page 36: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

time sync

ntpd service

ntp package ntp.conf

filesystem

yum

rpmpythonelectricity

networkntp server...

......

Friday, August 23, 13

Page 37: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

time sync

ntpd service

ntp package ntp.conf

filesystem

yum

rpmpythonelectricity

networkntp server...

...... ...

Friday, August 23, 13

Page 38: Infrastructure as Data - PuppetConf 2013

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

Page 39: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

if you wanna be my loveryou gotta apt-get with my

friends

Friday, August 23, 13

Page 40: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

requiresubscribe

Friday, August 23, 13

Page 41: Infrastructure as Data - PuppetConf 2013

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

Page 42: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

File / FileFile / UserFile / GroupUser / GroupCron / UserExec / FileExec / User

?

Friday, August 23, 13

Page 43: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

file { "/home/sweet/home": ensure => present, owner => sweet, require => User[sweet],}

user { "sweet": ensure => present,}

Friday, August 23, 13

Page 44: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

file { "/home/sweet/home": ensure => absent, owner => sweet, require => User[sweet],}

user { "sweet": ensure => absent,}

Friday, August 23, 13

Page 45: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

file { "/home/sweet/home": ensure => present, owner => sweet, require => User[sweet],}

user { "sweet": ensure => absent,}

Friday, August 23, 13

Page 46: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

file { "/home/sweet/home": ensure => present, owner => User[sweet],}

user { "sweet": ensure => absent,}

Friday, August 23, 13

Page 47: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

user { "sweet": ensure => absent,}

file { "/home/sweet/home": ensure => present,}

Friday, August 23, 13

Page 48: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

user { "sweet": ensure => absent,}

file { "/home/sweet/home": ensure => present,}

--ordering manifest

Friday, August 23, 13

Page 49: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

user { "sweet": ensure => absent,}

file { "/home/sweet/home": ensure => present,}

--ordering random

Friday, August 23, 13

Page 50: Infrastructure as Data - PuppetConf 2013

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

Page 51: Infrastructure as Data - PuppetConf 2013

puppetconf.com #puppetconf

file { "/etc/motd": ensure => present, content => "Hello PuppetConf!\nGoodbye PuppetConf :(",}

Friday, August 23, 13

Page 52: Infrastructure as Data - PuppetConf 2013

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

Page 53: Infrastructure as Data - PuppetConf 2013

Thank YouNick LewisDeveloper | Puppet Labs @nick_lewis

Collaborate. Automate. Ship.

Friday, August 23, 13

Page 54: Infrastructure as Data - PuppetConf 2013

Follow us on Twitter @puppetlabs

youtube.com/puppetlabsinc

slideshare.net/puppetlabs

Collaborate. Automate. Ship.

Friday, August 23, 13