<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Erb on Puppeteers Oy</title>
		<link>https://www.puppeteers.net/tags/erb/</link>
		<description>Recent content in Erb on Puppeteers Oy</description>
		<generator>Hugo</generator>
		<language>en-US</language>
		
		
		
		
			<lastBuildDate>Thu, 22 Dec 2022 00:00:00 +0000</lastBuildDate>
		
			<atom:link href="https://www.puppeteers.net/tags/erb/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>Convert a hash into JSON in Puppet</title>
				<link>https://www.puppeteers.net/blog/convert-a-hash-into-json-in-puppet/</link>
				<pubDate>Thu, 22 Dec 2022 00:00:00 +0000</pubDate>
				<guid>https://www.puppeteers.net/blog/convert-a-hash-into-json-in-puppet/</guid>
				<description>&lt;p&gt;&lt;img src=&#34;https://puppeteers-public.hel1.your-objectstorage.com/pexels-jess-loiterton-9259842.jpg&#34; alt=&#34;&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt;This article shows you how to convert a hash into JSON in Puppet using a simple &lt;a href=&#34;https://www.puppet.com/docs/puppet/7/lang_template_erb.html&#34;&gt;ERB template&lt;/a&gt; that gets its data from &lt;a href=&#34;https://www.puppet.com/docs/puppet/7/hiera_intro.html&#34;&gt;Hiera&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Suppose you have this data in Hiera:&lt;/p&gt;&#xA;&lt;div class=&#34;code-block&#34;&gt;&#xA;    &lt;button class=&#34;code-copy&#34; type=&#34;button&#34; hidden aria-label=&#34;Copy code to clipboard&#34;&gt;&#xA;      &lt;span class=&#34;code-copy-label&#34; aria-hidden=&#34;true&#34;&gt;Copy&lt;/span&gt;&#xA;    &lt;/button&gt;&#xA;    &lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;myhash:&#xA;  mykey:&#xA;    foo: one&#xA;    bar: two&lt;/code&gt;&lt;/pre&gt;&#xA;  &lt;/div&gt;&lt;p&gt;Converting a hash into a JSON file on the target node is surprisingly easy. First look up the data:&lt;/p&gt;&#xA;&lt;div class=&#34;code-block&#34;&gt;&#xA;    &lt;button class=&#34;code-copy&#34; type=&#34;button&#34; hidden aria-label=&#34;Copy code to clipboard&#34;&gt;&#xA;      &lt;span class=&#34;code-copy-label&#34; aria-hidden=&#34;true&#34;&gt;Copy&lt;/span&gt;&#xA;    &lt;/button&gt;&#xA;    &lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;$myhash = lookup(&amp;#39;myhash&amp;#39;, Hash)&lt;/code&gt;&lt;/pre&gt;&#xA;  &lt;/div&gt;&lt;p&gt;Then create a simple ERB template (here: &lt;em&gt;mymodule/templates/myhash.erb&lt;/em&gt;)&lt;/p&gt;</description>
			</item>
			<item>
				<title>Dynamic partitioning in Foreman kickstart templates</title>
				<link>https://www.puppeteers.net/blog/dynamic-partitioning-in-foreman-kickstart-templates/</link>
				<pubDate>Wed, 12 May 2021 00:00:00 +0000</pubDate>
				<guid>https://www.puppeteers.net/blog/dynamic-partitioning-in-foreman-kickstart-templates/</guid>
				<description>&lt;p&gt;Foreman&amp;rsquo;s &lt;a href=&#34;https://docs.theforeman.org/nightly/Provisioning_Guide/index-foreman-deb.html&#34;&gt;provisioning system&lt;/a&gt; allows creating provisioning templates with highly dynamic content. This article describes how to create dynamic content in your Foreman provisioning templates. While the example is related to dynamic partitioning in kickstart, the basic mechanisms for setting this up applies to any kind of template.&lt;/p&gt;&#xA;&lt;p&gt;Foreman &lt;a href=&#34;https://docs.theforeman.org/nightly/Provisioning_Guide/index-foreman-deb.html#provisioning-templates_provisioning&#34;&gt;provisioning templates&lt;/a&gt; are written in &lt;a href=&#34;https://www.stuartellis.name/articles/erb/&#34;&gt;ERB format&lt;/a&gt;. This allows having logic in the template itself based on user-defined host parameters. For example the &lt;a href=&#34;https://github.com/theforeman/foreman/blob/develop/app/views/unattended/provisioning_templates/provision/kickstart_default.erb&#34;&gt;Kickstart default template&lt;/a&gt; consumes a bunch of &lt;a href=&#34;https://docs.theforeman.org/nightly/Managing_Hosts/index-foreman-el.html&#34;&gt;host parameters&lt;/a&gt; that allow you to define what kind of kickstart file you want Foreman to spit out for each host or host group. To give a simple example there&amp;rsquo;s the &amp;ldquo;lang&amp;rdquo; parameter which sets the value for &amp;ldquo;lang&amp;rdquo; kickstart option:&lt;/p&gt;</description>
			</item>
	</channel>
</rss>
