Infrastructure as Data - PuppetConf 2013

1,079 views

Published on

"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.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,079
On SlideShare
0
From Embeds
0
Number of Embeds
449
Actions
Shares
0
Downloads
33
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Infrastructure as Data - PuppetConf 2013

  1. 1. Infrastructure as Data Nick Lewis Developer | Puppet Labs @nick_lewis Friday, August 23, 13
  2. 2. puppetconf.com #puppetconf Infrastructure as Data • Specified data • Manifests • Hiera • Node classification • Observed data • Facts • Generated/derived data • Catalogs • Reports Friday, August 23, 13
  3. 3. puppetconf.com #puppetconf as a minecraft addict I would like time to be correct on my computer so that I can stop playing minecraft and go to sleep Friday, August 23, 13
  4. 4. puppetconf.com #puppetconf Infrastructure as Code • tangible artifact • easy to change • documented • repeatable • idempotent Friday, August 23, 13
  5. 5. puppetconf.com #puppetconf yum install -y ntp if ! grep 'server 0.pool.ntp.org' /etc/ntp.conf; then echo 'server 0.pool.ntp.org' >> /etc/ntp.conf fi /etc/init.d/ntpd status || /etc/init.d/ntpd start Friday, August 23, 13
  6. 6. puppetconf.com #puppetconf yum check-update ntp if [ $? -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 restart elif ! /etc/init.d/ntpd status; then /etc/init.d/ntpd start fi Friday, August 23, 13
  7. 7. puppetconf.com #puppetconf Infrastructure as Bash • platform-specific • imperative • ad-hoc relationships • brittle in the face of failure Friday, August 23, 13
  8. 8. 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 ntp else start_service ntp fi Friday, August 23, 13
  9. 9. puppetconf.com #puppetconf Infrastructure as Bash • platform-specific • slightly less imperative • ad-hoc relationships • brittle in the face of failure Friday, August 23, 13
  10. 10. puppetconf.com #puppetconf Infrastructure as Bash • platform-specific • slightly less imperative • ad-hoc relationships • brittle in the face of failure Friday, August 23, 13
  11. 11. 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
  12. 12. puppetconf.com #puppetconf Infrastructure as Puppet • platform-independent • mostly declarative • relationships are explicit • understands failure Friday, August 23, 13
  13. 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
  14. 14. puppetconf.com #puppetconf include ntp Friday, August 23, 13
  15. 15. puppetconf.com #puppetconf tell me what you want what you really really want Friday, August 23, 13
  16. 16. puppetconf.com #puppetconf include magical_time_synchronization Friday, August 23, 13
  17. 17. puppetconf.com #puppetconf configuration management the art of making your monitoring checks pass Friday, August 23, 13
  18. 18. puppetconf.com #puppetconf abstraction giving a name to something and then cutting it out of your life Friday, August 23, 13
  19. 19. 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
  20. 20. puppetconf.com #puppetconf package { 'ntp': } file_line { 'ntp server': } service { 'ntp': } Friday, August 23, 13
  21. 21. puppetconf.com #puppetconf Friday, August 23, 13
  22. 22. puppetconf.com #puppetconf Friday, August 23, 13
  23. 23. puppetconf.com #puppetconf time sync Friday, August 23, 13
  24. 24. puppetconf.com #puppetconf time sync ntpd service Friday, August 23, 13
  25. 25. puppetconf.com #puppetconf time sync ntpd service ntp package Friday, August 23, 13
  26. 26. puppetconf.com #puppetconf time sync ntpd service ntp package ntp.conf Friday, August 23, 13
  27. 27. puppetconf.com #puppetconf time sync ntpd service ntp package ntp.conf yum Friday, August 23, 13
  28. 28. puppetconf.com #puppetconf time sync ntpd service ntp package ntp.conf yum python Friday, August 23, 13
  29. 29. puppetconf.com #puppetconf time sync ntpd service ntp package ntp.conf yum rpmpython Friday, August 23, 13
  30. 30. puppetconf.com #puppetconf time sync ntpd service ntp package ntp.conf yum rpmpython ... Friday, August 23, 13
  31. 31. puppetconf.com #puppetconf time sync ntpd service ntp package ntp.conf yum rpmpython ntp server... Friday, August 23, 13
  32. 32. puppetconf.com #puppetconf time sync ntpd service ntp package ntp.conf yum rpmpython network ntp server... Friday, August 23, 13
  33. 33. puppetconf.com #puppetconf time sync ntpd service ntp package ntp.conf yum rpmpython network ntp server... ... Friday, August 23, 13
  34. 34. puppetconf.com #puppetconf time sync ntpd service ntp package ntp.conf filesystem yum rpmpython network ntp server... ... Friday, August 23, 13
  35. 35. puppetconf.com #puppetconf time sync ntpd service ntp package ntp.conf filesystem yum rpmpython network ntp server... ... ... Friday, August 23, 13
  36. 36. puppetconf.com #puppetconf time sync ntpd service ntp package ntp.conf filesystem yum rpmpython electricity network ntp server... ... ... Friday, August 23, 13
  37. 37. puppetconf.com #puppetconf time sync ntpd service ntp package ntp.conf filesystem yum rpmpython electricity network ntp server... ... ... ... Friday, August 23, 13
  38. 38. puppetconf.com #puppetconf time sync ntpd service ntp package ntp.conf filesystem yum rpmpython electricity network ntp server... ... ... ... the very concept of time itself Friday, August 23, 13
  39. 39. puppetconf.com #puppetconf if you wanna be my lover you gotta apt-get with my friends Friday, August 23, 13
  40. 40. puppetconf.com #puppetconf require subscribe Friday, August 23, 13
  41. 41. puppetconf.com #puppetconf Package installs Service File is the source of Package User owns File File configures Service User is a member of Group File is the directory of File File is executed by Exec Friday, August 23, 13
  42. 42. puppetconf.com #puppetconf File / File File / User File / Group User / Group Cron / User Exec / File Exec / User ? Friday, August 23, 13
  43. 43. puppetconf.com #puppetconf file { "/home/sweet/home": ensure => present, owner => sweet, require => User[sweet], } user { "sweet": ensure => present, } Friday, August 23, 13
  44. 44. puppetconf.com #puppetconf file { "/home/sweet/home": ensure => absent, owner => sweet, require => User[sweet], } user { "sweet": ensure => absent, } Friday, August 23, 13
  45. 45. puppetconf.com #puppetconf file { "/home/sweet/home": ensure => present, owner => sweet, require => User[sweet], } user { "sweet": ensure => absent, } Friday, August 23, 13
  46. 46. puppetconf.com #puppetconf file { "/home/sweet/home": ensure => present, owner => User[sweet], } user { "sweet": ensure => absent, } Friday, August 23, 13
  47. 47. puppetconf.com #puppetconf user { "sweet": ensure => absent, } file { "/home/sweet/home": ensure => present, } Friday, August 23, 13
  48. 48. puppetconf.com #puppetconf user { "sweet": ensure => absent, } file { "/home/sweet/home": ensure => present, } --ordering manifest Friday, August 23, 13
  49. 49. puppetconf.com #puppetconf user { "sweet": ensure => absent, } file { "/home/sweet/home": ensure => present, } --ordering random Friday, August 23, 13
  50. 50. 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
  51. 51. puppetconf.com #puppetconf file { "/etc/motd": ensure => present, content => "Hello PuppetConf!nGoodbye PuppetConf :(", } Friday, August 23, 13
  52. 52. 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
  53. 53. Thank You Nick Lewis Developer | Puppet Labs @nick_lewis Collaborate. Automate. Ship. Friday, August 23, 13
  54. 54. Follow us on Twitter @puppetlabs youtube.com/puppetlabsinc slideshare.net/puppetlabs Collaborate. Automate. Ship. Friday, August 23, 13

×