{"id":3927,"date":"2023-11-02T09:54:18","date_gmt":"2023-11-02T14:54:18","guid":{"rendered":"https:\/\/fgiasson.com\/blog\/?p=3927"},"modified":"2023-11-02T09:54:18","modified_gmt":"2023-11-02T14:54:18","slug":"literate-programming-for-devops-mlops-and-infrastructure-as-code-in-general","status":"publish","type":"post","link":"https:\/\/fgiasson.com\/blog\/index.php\/2023\/11\/02\/literate-programming-for-devops-mlops-and-infrastructure-as-code-in-general\/","title":{"rendered":"Literate Programming: for DevOps, MLOps and Infrastructure as Code in General"},"content":{"rendered":"\n<p>Software developers generally tells me that they don&#8217;t have to document most of anything since the code is the documentation: just read it. This is when I reply: the code tells me the <em>how<\/em> you did it (if lucky) the words around the code should tell me the <em>why<\/em>.<\/p>\n<p>With the recent (last 15 years) emergence of <a href=\"https:\/\/en.wikipedia.org\/wiki\/Infrastructure_as_code\">Infrastructure as Code<\/a> (IaC), new important specialized developer roles such as DevOps and now MLOps, I will argue that literate programming concepts are becoming more and more important to the software industry.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Infrastructure as Code<\/h2>\n\n\n\n<p>In the last fifteen years, we saw the emergence of several Domain Specific Languages (DSL) to help system administrators to manage and provision their infrastructure. Those DSL revolutionized the way infrastructures were created and cared for.<\/p>\n<p>Infrastructures were now entirely defined in plain text files. Those files could be versioned, they would get special treatments in IDEs, complete infrastructure could be rollbacked, etc.<\/p>\n<p>But, there is one special characteristics that IaC has: the side effects of the &#8220;infrastructure code&#8221; are huge because a single line can lead to provision, or destroy, huge number of hardware resources which can have dramatic physical or monetary impacts.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Importance of Documentation<\/h2>\n\n\n\n<p>In this context, I argue about the importance of literate programming principles to code and maintain IaC. Some of the DSL are very opaque, a very small change can have dramatic side effects. IaC also has deal with versions of several tens, if not hundred, pieces of software that have to work together. IaC creates very complex networks of computers in different regions of the World.<\/p>\n<p>None of that is self evident in code written in those DSL. The\u00a0<em>why<\/em> needs to be documented very carefully, and documentation needs to be as close as possible to the DSLs code because every time something changes in the infrastructure, the change needs to be reflected in the text that describes the rational of that piece of infrastructure. And finally, both the <em>how<\/em> and the <em>why<\/em> will be carefully peer reviewed in a pull request.\u00a0<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Org-mode: Agnostic Literate Programming Framework<\/h2>\n\n\n\n<p>Considering that there exists a specific DSL per framework (Terraform, Ansible, Docker, Puppet, Chef, etc.) it is important to have a literate programming framework that is language agnostic (unlike <a href=\"https:\/\/www-cs-faculty.stanford.edu\/~knuth\/cweb.html\">CWeb<\/a>, <a href=\"http:\/\/nbdev.fast.ai\">nbdev<\/a>, etc.). This is why I strongly support Org-mode. If the DevOps\/MLOps developers works within Emacs, they have all the power of all the major modes already existing in Emacs to manipulate the code of those DSL within the code blocks. If they don&#8217;t, they can always use their favorite IDE with a <a href=\"https:\/\/fgiasson.com\/blog\/index.php\/2023\/10\/31\/orgweb-cli-org-mode-environment-for-web-like-development-without-emacs\/\">Org-mode command line utility<\/a> like <a href=\"https:\/\/github.com\/fgiasson\/orgweb\/tree\/main\">OrgWeb<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Few Examples<\/h2>\n\n\n\n<p>Let&#8217;s take a look at what it looks like in the wild. Here are two examples, one that describes a Dockerfile and a series of Ansible playbooks, properly rendered in GitHub.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Literate Dockerfile<\/h3>\n\n\n\n<p>The first example is <a href=\"https:\/\/github.com\/fgiasson\/orgweb\/blob\/main\/org\/Docker.org\">orgweb&#8217;s Docker.org file where the Dockerfile if generated<\/a>. As you can see, everything of importance about the generated Docker image is stated. The version of Alpine Linux used, which version of Emacs is shipped with, the reason why we choose Alpine in the first place, etc.<\/p>\n<p>Then it explains why the Dockerfile needs to install the <code>tf-dejavu<\/code> package, and what happens if it is not installed. And then it explains why the <code>install.el<\/code> and <code>site-start.el<\/code> files are being copied over and what they are used for. And finally, why <code>install.el<\/code> is being run while building the image.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Literate Ansible<\/h3>\n\n\n\n<p><a href=\"https:\/\/github.com\/thartman83\/literate-playbooks#archiso\">Here is another example from a project I stumbled upon recently<\/a>. This repository is a set of Ansible playbook to provision a series of infrastructure resources such as a <a href=\"https:\/\/github.com\/thartman83\/literate-playbooks\/tree\/main\/provision-docker-registry\">docker registry<\/a>, <a href=\"https:\/\/github.com\/thartman83\/literate-playbooks\/tree\/main\/provision-longhorn\">longhorn<\/a>, etc.<\/p>\n\n\n","protected":false},"excerpt":{"rendered":"<p>In this blog post, I am arguing that literate programming concepts are becoming more and more important to the software industry considering the recent (last 15 years) emergence of Infrastructure as Code (IaC) and new important specialized developer roles such as DevOps and now MLOps.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[277,309],"tags":[],"class_list":["post-3927","post","type-post","status-publish","format-standard","hentry","category-literate-programming","category-mlops"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/3927","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=3927"}],"version-history":[{"count":9,"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/3927\/revisions"}],"predecessor-version":[{"id":3936,"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/3927\/revisions\/3936"}],"wp:attachment":[{"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=3927"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=3927"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=3927"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}