{"id":848,"date":"2018-10-18T16:09:29","date_gmt":"2018-10-18T16:09:29","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw92\/?p=848"},"modified":"2018-10-21T00:34:36","modified_gmt":"2018-10-21T00:34:36","slug":"katello-separate-lifecycle-for-puppet-modules-lisenet-com-linux-security","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/18\/katello-separate-lifecycle-for-puppet-modules-lisenet-com-linux-security\/","title":{"rendered":"Katello: Separate Lifecycle for Puppet Modules | Lisenet.com :: Linux | Security"},"content":{"rendered":"<p>Working with Katell. We\u2019re going to configure a separate lifecycle for Puppet modules. This article is part of the <a href=\"https:\/\/www.lisenet.com\/2018\/homelab-project-with-kvm-katello-and-puppet\/\" target=\"_blank\" rel=\"noopener\">Homelab Project with KVM, Katello and Puppet<\/a> series.<\/p>\n<p>Homelab<\/p>\n<p>We have Katello installed on a CentOS 7 server:<\/p>\n<p>katello.hl.local (10.11.1.4) \u2013 see <a href=\"https:\/\/www.lisenet.com\/2016\/install-katello-on-centos-7\/\" target=\"_blank\" rel=\"noopener\">here<\/a> for installation instructions<\/p>\n<p>See the image below to identify the homelab part this article applies to.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.lisenet.com\/wp-content\/uploads\/2018\/04\/lisenet-homelab-diagram_katello.png\" alt=\"\" width=\"1200\" height=\"793\" \/><\/p>\n<h2>Separate Lifecycle for Puppet Modules<\/h2>\n<p>The idea for using a separate lifecycle for Puppet modules was taken from a Red Hat <a href=\"https:\/\/access.redhat.com\/blogs\/1169563\/posts\/2848811\" target=\"_blank\" rel=\"noopener\">blog post<\/a> that was published by Maxim Burgerhout.<\/p>\n<p>We already know that we can create a repository that contains RPM files. We can then create a content view by snapshotting the repository.<\/p>\n<p>We can create a content view with Puppet modules, just like we would do with RPMs. Based on that content view, Katello creates a special directory on the filesystem and it\u2019s where the Puppet master looks for Puppet modules.<\/p>\n<p>Katello creates a Puppet environment from the Puppet module content view the moment we publish it. As a result, using a Puppet module content view as a Puppet environment directly makes it easy to iterate quickly during development of our homelab Puppet modules.<\/p>\n<h2>The Plan<\/h2>\n<p>Below is a step-by-step plan that we\u2019ll be following in this article.<\/p>\n<ol>\n<li>Step 1: create a Puppet product.<\/li>\n<li>Step 2: build Puppet modules.<\/li>\n<li>Step 3: create a Puppet repository.<\/li>\n<li>Step 4: sync Puppet repository.<\/li>\n<li>Step 5: create a content view.<\/li>\n<li>Step 6: add Puppet modules to the content view.<\/li>\n<li>Step 7: publish Puppet content view.<\/li>\n<li>Step 8: backup Katello configuration.<\/li>\n<\/ol>\n<h2>Configure Katello<\/h2>\n<h3>Step 1: Create a Puppet Product<\/h3>\n<p># hammer product create &#8211;name &#8220;puppet&#8221;<\/p>\n<h3>Step 2: Build Puppet Modules<\/h3>\n<p>See here for more info: <a href=\"https:\/\/www.lisenet.com\/2016\/build-and-import-puppet-modules-into-katello\" target=\"_blank\" rel=\"noopener\">Build and Import Puppet Modules into Katello<\/a><\/p>\n<p>The idea here is to have a single Katello repository containing all our Puppet modules.<\/p>\n<p>A Katello repository may be a plain directory containing a Pulp manifest and packaged Puppet modules. According to the Pulp project documentation, the Pulp manifest is a file listing each Puppet module contained in the directory. Each module is listed on a separate line which has the following format: &lt;name&gt;,&lt;checksum&gt;,&lt;size&gt;. The name is the file name, the checksum is SHA256 digest of the file, and the size is the size of the file in bytes. The Pulp manifest must be named PULP_MANIFEST. Having all this information, we can build Puppet modules manually, generate a Pulp manifest and import everything into Katello.<\/p>\n<p>Get the source from GitHub:<\/p>\n<p># cd \/opt<br \/>\n# git clone https:\/\/github.com\/crylium\/build-puppet-modules-for-katello.git<\/p>\n<p>Build the modules, providing the path to the modules\u2019 directory:<\/p>\n<p># bash .\/build-puppet-modules-for-katello\/puppet-module-build.sh<br \/>\n\/etc\/puppetlabs\/code\/environments\/homelab\/modules\/<\/p>\n<p>This will also create the file PULP_MANIFEST.<\/p>\n<h3>Step 3: Create a Puppet Repository<\/h3>\n<p># hammer repository create<br \/>\n&#8211;product &#8220;puppet&#8221;<br \/>\n&#8211;name &#8220;homelab_modules&#8221;<br \/>\n&#8211;content-type &#8220;puppet&#8221;<br \/>\n&#8211;url &#8220;file:\/\/\/etc\/puppetlabs\/code\/environments\/homelab\/modules\/&#8221;<\/p>\n<h3>Step 4: Synchronise Puppet Repository<\/h3>\n<p># hammer repository synchronize<br \/>\n&#8211;product &#8220;puppet&#8221;<br \/>\n&#8211;name &#8220;homelab_modules&#8221;<\/p>\n<h3>Step 5: Create a Content View<\/h3>\n<p># hammer content-view create<br \/>\n&#8211;name &#8220;puppet_content&#8221;<br \/>\n&#8211;description &#8220;Puppet modules&#8221;<\/p>\n<h3>Step 6: Add Puppet Modules to the Content View<\/h3>\n<p>View the module list:<\/p>\n<p># hammer puppet-module list<br \/>\n&#8212;|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;|&#8212;&#8212;&#8212;&#8212;&#8211;|&#8212;&#8212;&#8212;|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\nID | NAME | AUTHOR | VERSION | UUID<br \/>\n&#8212;|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;|&#8212;&#8212;&#8212;&#8212;&#8211;|&#8212;&#8212;&#8212;|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\n38 | graylog | graylog | 0.6.0 | f27d9a89-9e0a-44fe-b72d-f101d94629a4<br \/>\n37 | sudo | saz | 5.0.0 | f088fa68-bfa3-4429-a8f2-f9c893d52bfc<br \/>\n36 | ruby | puppetlabs | 1.0.0 | eaaef4ba-bf52-4275-8eff-0340d98aa3f7<br \/>\n35 | archive | puppet | 2.3.0 | e09d2bc5-ec62-488c-a1a8-df6364448378<br \/>\n34 | elasticsearch | elastic | 6.2.1 | d965e7b4-ec88-4813-b575-745f9e78c2f1<br \/>\n33 | augeasproviders_shellvar | herculesteam | 2.2.2 | cbbe2521-890b-476d-b3b5-beef1b72fd73<br \/>\n32 | haproxy | puppetlabs | 2.1.0 | c9113401-719a-4d19-8ee8-8faca9a30317<br \/>\n31 | mongodb | puppet | 2.1.0 | c8e47d0c-e54c-4cef-9b16-c1bad02e7fba<br \/>\n30 | sysctl | thias | 1.0.6 | c23fabcc-0d62-4ecb-8ac3-ebe06e9772e6<br \/>\n29 | nfs | derdanne | 2.0.7 | c09f3853-43a8-4d30-b81d-7ce160d8b3b8<br \/>\n28 | stdlib | puppetlabs | 4.24.0 | 9ec2939a-3b08-4fbe-a7ff-1c34984350d7<br \/>\n27 | ssh | saz | 3.0.1 | 99b1c530-fbe7-487a-8842-cfeacc688b74<br \/>\n26 | apache | puppetlabs | 2.3.1 | 93f56575-da3d-41b6-964c-a70af87bcb0c<br \/>\n25 | concat | puppetlabs | 2.2.1 | 9379ce64-6135-4b17-a1c3-5731b0ac89c3<br \/>\n24 | mysql | puppetlabs | 5.3.0 | 92695de8-45c0-4271-832c-5721bdb5ffd9<br \/>\n23 | openldap | camptocamp | 1.16.1 | 924b998d-b361-4f75-9e41-55f825d209da<br \/>\n22 | accounts | puppetlabs | 1.3.0 | 8bf8366e-81f1-4dd1-8de6-9e330e7de759<br \/>\n21 | sssd | sgnl05 | 2.7.0 | 8afc1e88-9d4a-46ad-8107-5d457f4cd740<br \/>\n20 | snmp | razorsedge | 3.9.0 | 8aed966e-e973-4d87-af1d-6f4b63051c32<br \/>\n19 | lisenet_firewall | lisenet | 1.0.0 | 8513e8ec-7cdd-4606-8d8c-92a660dc5da5<br \/>\n18 | corosync | puppet | 6.0.0 | 7b4dba49-c793-47f7-b872-a683a4b8d131<br \/>\n17 | augeasproviders_core | herculesteam | 2.1.4 | 77afedf9-65b8-4168-a8a1-5e534e84462d<br \/>\n16 | pe_gem | puppetlabs | 0.2.0 | 5e639097-072a-4486-bc19-0b3ab6a8bbae<br \/>\n15 | keepalived | arioch | 1.2.5 | 4ff5c45b-0a93-4cbd-8574-1b246363378c<br \/>\n14 | firewall | puppetlabs | 1.12.0 | 3a86241a-3c52-4339-a05d-6f6de0a033ac<br \/>\n13 | rsyslog | saz | 5.0.0 | 330447a4-010a-4cfb-8b99-5cbcf327adaa<br \/>\n12 | systemd | camptocamp | 1.1.1 | 2fea15c7-99d4-49cd-9eea-578c5e249657<br \/>\n11 | ntp | puppetlabs | 7.1.1 | 2fd3c5d5-4943-4f54-bd60-3bd1d73af0d3<br \/>\n10 | translate | puppetlabs | 1.1.0 | 2e46f4e3-34f6-41a0-9466-4b163b87f5d9<br \/>\n9 | selinux | puppet | 1.5.2 | 2e12d841-2801-45d2-a70c-e287d134b1e8<br \/>\n8 | postgresql | puppetlabs | 5.3.0 | 28f11fd1-223b-46fe-a92c-cfc485aa28ef<br \/>\n7 | datacat | richardc | 0.6.2 | 24f45f62-7012-4ac1-809e-3efd9d5d9daa<br \/>\n6 | zabbix | puppet | 6.2.0 | 2426fdbc-9dc2-4cf2-8810-a7702fdd7faa<br \/>\n5 | limits | saz | 3.0.2 | 1b893348-11e9-45e7-9d64-5fb2819c1e96<br \/>\n4 | apt | puppetlabs | 4.5.1 | 13c33cf0-acbe-4369-b44e-def9933e6d87<br \/>\n3 | wordpress | hunner | 1.0.0 | 0f928270-7b36-407b-b603-1efe6e261812<br \/>\n2 | staging | puppet | 3.1.0 | 0a6ffb28-5049-4556-923d-7af3850ece63<br \/>\n1 | java | puppetlabs | 2.4.0 | 081cb24f-cec7-4c12-a203-5685edc1936d<br \/>\n&#8212;|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;|&#8212;&#8212;&#8212;&#8212;&#8211;|&#8212;&#8212;&#8212;|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/p>\n<p>We can loop the module IDs to add them to the content view:<\/p>\n<p># for i in $(seq 1 38);do<br \/>\nhammer content-view puppet-module add<br \/>\n&#8211;content-view &#8220;puppet_content&#8221;<br \/>\n&#8211;id &#8220;$i&#8221;; done<\/p>\n<h3>Step 7: Publish Puppet Content View<\/h3>\n<p>Let us check the environments that we have available before we publish the content view:<\/p>\n<p># hammer environment list<br \/>\n&#8212;|&#8212;&#8212;&#8212;&#8211;<br \/>\nID | NAME<br \/>\n&#8212;|&#8212;&#8212;&#8212;&#8211;<br \/>\n2 | homelab<br \/>\n1 | production<br \/>\n&#8212;|&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>The production environment is the default one, and the homelab environment is the one we created manually. Publish Puppet content view:<\/p>\n<p># hammer content-view publish<br \/>\n&#8211;name &#8220;puppet_content&#8221;<br \/>\n&#8211;description &#8220;Publishing Puppet modules&#8221;<\/p>\n<p>As mentioned earlier, Katello creates a Puppet environment from the Puppet module content view the moment we publish it. Verify:<\/p>\n<p># hammer environment list<br \/>\n&#8212;|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\nID | NAME<br \/>\n&#8212;|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n3 | KT_lisenet_Library_puppet_content_4<br \/>\n2 | homelab<br \/>\n1 | production<br \/>\n&#8212;|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p>We can now associate a host or hostgroup with whatever Puppet environment we want, including the one created for the Puppet module content view.<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.lisenet.com\/wp-content\/uploads\/2018\/04\/lisenet-puppet-environment.png\" alt=\"\" width=\"549\" height=\"362\" \/><\/p>\n<h3>Step 8: Backup Katello Configuration<\/h3>\n<p>Let us create a backup of our Katello configuration so that we don\u2019t lose any changes that we\u2019ve made so far:<\/p>\n<p># katello-backup \/mnt\/backup\/ &#8211;features=all -y<\/p>\n<p><a href=\"https:\/\/www.lisenet.com\/2018\/katello-separate-lifecycle-for-puppet-modules\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Working with Katell. We\u2019re going to configure a separate lifecycle for Puppet modules. This article is part of the Homelab Project with KVM, Katello and Puppet series. Homelab We have Katello installed on a CentOS 7 server: katello.hl.local (10.11.1.4) \u2013 see here for installation instructions See the image below to identify the homelab part this &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/18\/katello-separate-lifecycle-for-puppet-modules-lisenet-com-linux-security\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Katello: Separate Lifecycle for Puppet Modules | Lisenet.com :: Linux | Security&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-848","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/848","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=848"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/848\/revisions"}],"predecessor-version":[{"id":1028,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/848\/revisions\/1028"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=848"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=848"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=848"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}