Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How people actually write Puppet code

How people actually write Puppet code

An analysis of more than 7.5 million lines of Puppet code. Looking at what features people use (or don't use) and how we might use this to design Puppet and help the Puppet community. Warning: contains lots of SQL queries .

Gareth Rushgrove

October 12, 2017
Tweet

More Decks by Gareth Rushgrove

Other Decks in Technology

Transcript

  1. What if we were to analyze all of the code

    written in the Puppet language?
  2. - But why? - GitHub and BigQuery - Libraries.io and

    the Forge - Caveats and limitations
  3. BigQuery provides a SQL interface to all of the code

    on GitHub, along with the associated metadata
  4. So we have lots of code from lots of people.

    What questions might we ask?
  5. How do people license their Puppet code? mit(7345) apache-2.0 (6368)

    gpl-3.0 (1537) gpl-2.0 (1512) bsd-3-clause (805) bsd-2-clause (373) mpl-2.0 (287) agpl-3.0 (160) isc (121) unlicense (105)
  6. What do people name their classes? apache(153) mysql (131) php

    (129) base (118) main (118) nginx (110) git (84) python (82) mysql::params (69) ssh (64) mysql::server (59) apt (59) puppet::params (56) mysql::config (55) nodejs (53) apt_get_update (52)
  7. What do people name defined types? add_dotdeb (75) mysql_db (68)

    mysql_nginx_default_conf (57) mongodb_db(52) nginx_vhost (49) postgresql_db (40) mariadb_db (39) mariabdb_nginx_default_conf (38) safepackage(31) iptables_port (26)
  8. What packages do people manage with Puppet? git (552) curl

    (386) wget (239) nginx(246) apache2 (244) vim (243) unzip (238) build-essential (197) python-pip (185) mysql (184) ntp (176) openssh-server (156) nodejs (152) httpd (138)
  9. What services do people manage with Puppet? apache2 (314) nginx

    (280) mysql (239) httpd (165) puppet (125) iptables (119) ssh (105) postgresql (93) php5-fpm (88) neutron-server (81) ntp (76) postfix (74) ntpd (71) sshd (70) mysqld (69)
  10. Which resource types are most used? file (30298) package (22162)

    exec (16825) service (11112) user (3951) host (2361) group (2181) notify (2151) yumrepo (1229) cron (1122) stage (429) resources (380) mount (373) ssh_authorized_key (271)
  11. Which resource types are least used? interface (260) zone (207)

    selboolean (108) router (103) tidy (76) sshkey (66) schedule (42) filebucket (42) mailalias (40) vlan (31) selmodule (25) zfs (11) mcx (6) scheduled_task (5) zpool (3) k5login (3) computer (2) maillist (1)
  12. How popular are the nagios types? service (160) command (56)

    host (49) servicedependency (35) contact (18) servicegroup (10) hostextinfo (8) timeperiod (5) hostdependency (3) serviceescalation (2) hostescalation (1)
  13. Which data type are being used? String (603) Boolean (411)

    Integer (174) Hash (132) Array (82) Default (14) Float (5) Numeric (3) Undef (1)
  14. Which abstract data types are in use? Optional(611) Enum (277)

    Data (162) Type (145) Variant (134) All (127) Patter (73) Tuple (13) Collection (11) Struct (11) Scaler (2)
  15. What gems are popular in Puppet projects? puppet (1285) puppetlabs_spec_helper

    (1268) rake (1215) puppet-lint (837) metadata-json-lint (726) beaker-rspec (694) rspec-puppet (676) puppet-blacksmith (518) beaker (509) serverspec (444)
  16. Which puppet-lint plugins are most used? unquoted_string (366) leading_zero (344)

    absolute_classname (318) trailing_comma (310) version_comparison (248) variable_contains_uppercase (222) beginning_with_digits (191) emtyp_string (156) undef_in_function (147) spaceship_operatorwithout_tag (135)
  17. forgeapi.puppetlabs.com/v3/modules { "uri": "/v3/modules/arioch-keepalived", "slug": "arioch-keepalived", "name": "keepalived", "downloads": 5551609,

    "created_at": "2013-07-02 09:13:33 -0700", "updated_at": "2016-12-28 20:00:02 -0800", "deprecated_at": null, "deprecated_for": null, "superseded_by": null, "supported": false, "endorsement": "approved", "module_group": "base", "owner": { "uri": "/v3/users/arioch", "slug": "arioch", "username": "arioch",
  18. Interesting to note that while most Puppet repositories are MIT,

    most published modules are Apache licensed
  19. For example, we could use this approach to see how

    people adopt the new Puppet Tasks
  20. - Analyzing hieradata - Parsing all of the Puppet code

    - Seeing changes over time So many more questions:
  21. - Make it easy to run against your own code

    - Some way of submitting aggregates - Publish public bigquery tables Lots of ideas too: