<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ascii for Breakfast &#187; valentin</title>
	<atom:link href="http://www.xenuser.org/author/admin/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.xenuser.org</link>
	<description>xenuser, also called ACSII FOR BREAKFAST, is a personal blog abut IT security, open source software, Cfengine 3 and other stuff.  And of course there is also Xen, my favourite virtualization solution.</description>
	<lastBuildDate>Sun, 02 Jun 2013 18:43:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Using environment variables in Puppet</title>
		<link>http://www.xenuser.org/open-source-development/using-environment-variables-in-puppet/</link>
		<comments>http://www.xenuser.org/open-source-development/using-environment-variables-in-puppet/#comments</comments>
		<pubDate>Sun, 02 Jun 2013 18:25:20 +0000</pubDate>
		<dc:creator>valentin</dc:creator>
				<category><![CDATA[Open Source & Development]]></category>
		<category><![CDATA[.pp]]></category>
		<category><![CDATA[.rb]]></category>
		<category><![CDATA[accessing]]></category>
		<category><![CDATA[code sample]]></category>
		<category><![CDATA[environment]]></category>
		<category><![CDATA[environment variables]]></category>
		<category><![CDATA[Facter]]></category>
		<category><![CDATA[manifest]]></category>
		<category><![CDATA[Puppet]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[sample]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[variable]]></category>

		<guid isPermaLink="false">http://www.xenuser.org/?p=2039</guid>
		<description><![CDATA[Welcome back to the next part of my little series &#8220;Cfengine 3 vs. Puppet&#8221;.  When sticking to the order of the Cfengine 3 blog post series, our next topic would be something like &#8220;using the reporting feature of Puppet&#8221;, but unfortunately I do not know how to make use of a reporting feature in Puppet [...]


Related posts:<ol><li><a href='http://www.xenuser.org/open-source-development/running-shell-commands-with-puppet/' rel='bookmark' title='Permanent Link: Running shell commands with Puppet'>Running shell commands with Puppet</a></li>
<li><a href='http://www.xenuser.org/open-source-development/mounting-nfs-shares-with-puppet/' rel='bookmark' title='Permanent Link: Mounting NFS-Shares with Puppet'>Mounting NFS-Shares with Puppet</a></li>
<li><a href='http://www.xenuser.org/open-source-development/taking-a-quick-look-at-the-configuration-management-system-puppet/' rel='bookmark' title='Permanent Link: Taking a quick look at the configuration management system Puppet'>Taking a quick look at the configuration management system Puppet</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Welcome back to the next part of my little series &#8220;Cfengine 3 vs. Puppet&#8221;.  When sticking to the order of the Cfengine 3 blog post series, our next topic would be something like &#8220;using the reporting feature of Puppet&#8221;, but unfortunately I do not know how to make use of a reporting feature in Puppet (or there is no such thing).</p>
<p>That is why we move on to the next topic: Accessing environment variables in Puppet! I searched the Internet for documentation about this specific feature; however, all I found was &#8220;this is not a built-in feature of Puppet&#8221; and a ruby script which enhances Facter.</p>
<p>That is why we have two &#8220;scripts&#8221; this time.</p>
<p><strong>Writing the Facter script and Puppet manifest</strong><br />
At first create the file /etc/puppet/modules/customfacts/lib/facter/env.rb:</p>
<pre class="brush: text">
ENV.each do |k,v|
	Facter.add(&quot;env_#{k.downcase}&quot;.to_sym) do
		setcode do
			v
		end
	end
end
</pre>
<p>Then create the Puppet manifest /etc/puppet/manifests/xenuser_org-009-using_environment_variables.pp:</p>
<pre class="brush: text">
file { &quot;demonstrate_env_var_usage&quot;:
	path =&gt; &quot;/etc/myenvfile&quot;,
	ensure =&gt; present,
	mode =&gt; 0640,
	content =&gt; &quot;Content of env var PWD: $env_pwd&quot;,
}
</pre>
<p>Now let&#8217;s see if Facter now collects all the environment variables on the target system:</p>
<pre class="brush: bash">
mintbox manifests # facter |grep env
env__ =&gt; /usr/bin/facter
env_colorterm =&gt; gnome-terminal
env_display =&gt; :0.0
env_home =&gt; /root
env_lang =&gt; C
env_logname =&gt; root
env_mail =&gt; /var/mail/root
env_oldpwd =&gt; /usr/lib/ruby/vendor_ruby/facter
env_path =&gt; /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
env_pwd =&gt; /etc/puppet/manifests
env_shell =&gt; /bin/bash
env_shlvl =&gt; 1
env_sudo_command =&gt; /bin/su
env_sudo_gid =&gt; 1000
env_sudo_uid =&gt; 1000
env_sudo_user =&gt; valentin
env_term =&gt; xterm
env_user =&gt; root
env_username =&gt; root
env_xauthority =&gt; /home/valentin/.Xauthority
env_xdg_session_cookie =&gt; af6d4563e613c62d87f9eb7400000008-1360505842.231246-1540805281
</pre>
<p>Yay! Facter now sees our environment variables. Now let&#8217;s move on:</p>
<pre class="brush: bash">
mintbox manifests # puppet apply xenuser_org-009-using_environment_variables.pp
Warning: Could not retrieve fact fqdn
Notice: /Stage[main]//File[demonstrate_env_var_usage]/ensure: created
Notice: Finished catalog run in 0.02 seconds
mintbox manifests # cat /etc/myenvfile
Content of env var PWD: /etc/puppet/manifests
</pre>
<p>Great, it works! We now can access environment variables within Puppet. Please do not forget that you have to place that ruby script (env.rb) on every Puppet agent system.</p>
<p><strong>Analyzing the Facter script and Puppet manifest</strong><br />
In the first step we created a custom ruby script and placed it on the right location where Facter can find it. Facter runs on every system there the Puppet agent is installed.</p>
<p>Facter now adds the environment variables to the catalogue; that is the reason why we can access our environment variables within Puppet manifests.</p>
<p>The puppet manifest itself is very simple and self-explaining.</p>
<p><strong>Summary</strong><br />
Learning that accessing environment variables is not possible within Puppet manifests was a big disappointment. At least we are able to enhance Facter and help ourselves.</p>
<p>The source of the env.rb script is the old Puppet wiki: <a href="http://projects.puppetlabs.com/projects/puppet/wiki/Environment_Variables_Patterns" title="Puppet wiki: Enhancing Facter for using env variables within Puppet" target="_blank">http://projects.puppetlabs.com/projects/puppet/wiki/Environment_Variables_Patterns</a></p>
<p>As usual, you can download all &#8220;scripts&#8221; from this blog post here: <a href="http://www.xenuser.org/downloads/puppet/env.rb" title="Ruby script for enhancing Facter in terms of environment variables" target="_blank">env.rb</a>, <a href="http://www.xenuser.org/downloads/puppet/xenuser_org-009-using_environment_variables.pp" title="Puppet manifest for accessing environment variables" target="_blank">xenuser_org-009-using_environment_variables.pp</a> <img src="http://www.xenuser.org/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=2039" width="1" height="1" style="display: none;" /></p>


<p>Related posts:<ol><li><a href='http://www.xenuser.org/open-source-development/running-shell-commands-with-puppet/' rel='bookmark' title='Permanent Link: Running shell commands with Puppet'>Running shell commands with Puppet</a></li>
<li><a href='http://www.xenuser.org/open-source-development/mounting-nfs-shares-with-puppet/' rel='bookmark' title='Permanent Link: Mounting NFS-Shares with Puppet'>Mounting NFS-Shares with Puppet</a></li>
<li><a href='http://www.xenuser.org/open-source-development/taking-a-quick-look-at-the-configuration-management-system-puppet/' rel='bookmark' title='Permanent Link: Taking a quick look at the configuration management system Puppet'>Taking a quick look at the configuration management system Puppet</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.xenuser.org/open-source-development/using-environment-variables-in-puppet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Two more cheat sheets added</title>
		<link>http://www.xenuser.org/linux/two-more-cheat-sheets-added/</link>
		<comments>http://www.xenuser.org/linux/two-more-cheat-sheets-added/#comments</comments>
		<pubDate>Sun, 10 Mar 2013 14:57:44 +0000</pubDate>
		<dc:creator>valentin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Tools for Linux sysadmins]]></category>
		<category><![CDATA[cheat sheet]]></category>
		<category><![CDATA[exam]]></category>
		<category><![CDATA[Guide]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[learning]]></category>
		<category><![CDATA[RHCE]]></category>
		<category><![CDATA[rhcva]]></category>
		<category><![CDATA[rhev]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[wiki]]></category>

		<guid isPermaLink="false">http://www.xenuser.org/?p=2033</guid>
		<description><![CDATA[Today I added two new cheat sheets: RHCE Cheat Sheet RHEV/RHCVA Especially the RHEV/RHCVA cheat sheet is not very comprehensive, but maybe it is still a little helpful when learning for the RHCVA exam. Enjoy! Related posts:New cheat sheets added Review: RHCSA/RHCE Red Hat Linux Certification Study Guide (Exams EX200 &#038; EX300) Cfengine3: Check for [...]


Related posts:<ol><li><a href='http://www.xenuser.org/linux/new-cheat-sheets-added/' rel='bookmark' title='Permanent Link: New cheat sheets added'>New cheat sheets added</a></li>
<li><a href='http://www.xenuser.org/misc/review-rhcsarhce-red-hat-linux-certification-study-guide-exams-ex200-ex300/' rel='bookmark' title='Permanent Link: Review: RHCSA/RHCE Red Hat Linux Certification Study Guide (Exams EX200 &#038; EX300)'>Review: RHCSA/RHCE Red Hat Linux Certification Study Guide (Exams EX200 &#038; EX300)</a></li>
<li><a href='http://www.xenuser.org/linux/cfengine3-check-for-running-services/' rel='bookmark' title='Permanent Link: Cfengine3: Check for running services'>Cfengine3: Check for running services</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Today I added two new cheat sheets:</p>
<ul>
<li><a title="RHCE Cheat Sheet" href="http://www.xenuser.org/rhce-cheat-sheet/" target="_blank">RHCE Cheat Sheet</a></li>
<li><a title="RHEV/RHCVA Cheat Sheet" href="http://www.xenuser.org/rhev-and-rhcva-cheat-sheet/" target="_blank">RHEV/RHCVA</a></li>
</ul>
<p>Especially the RHEV/RHCVA cheat sheet is not very comprehensive, but maybe it is still a little helpful when learning for the RHCVA exam. Enjoy! <img src="http://www.xenuser.org/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=2033" width="1" height="1" style="display: none;" /></p>


<p>Related posts:<ol><li><a href='http://www.xenuser.org/linux/new-cheat-sheets-added/' rel='bookmark' title='Permanent Link: New cheat sheets added'>New cheat sheets added</a></li>
<li><a href='http://www.xenuser.org/misc/review-rhcsarhce-red-hat-linux-certification-study-guide-exams-ex200-ex300/' rel='bookmark' title='Permanent Link: Review: RHCSA/RHCE Red Hat Linux Certification Study Guide (Exams EX200 &#038; EX300)'>Review: RHCSA/RHCE Red Hat Linux Certification Study Guide (Exams EX200 &#038; EX300)</a></li>
<li><a href='http://www.xenuser.org/linux/cfengine3-check-for-running-services/' rel='bookmark' title='Permanent Link: Cfengine3: Check for running services'>Cfengine3: Check for running services</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.xenuser.org/linux/two-more-cheat-sheets-added/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Performing simple Backups with Cfengine 3</title>
		<link>http://www.xenuser.org/open-source-development/performing-simple-backups-with-cfengine-3/</link>
		<comments>http://www.xenuser.org/open-source-development/performing-simple-backups-with-cfengine-3/#comments</comments>
		<pubDate>Sun, 17 Feb 2013 21:32:18 +0000</pubDate>
		<dc:creator>valentin</dc:creator>
				<category><![CDATA[Cfengine3]]></category>
		<category><![CDATA[Open Source & Development]]></category>
		<category><![CDATA[analyze]]></category>
		<category><![CDATA[archive]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[backup mechanism]]></category>
		<category><![CDATA[cfengine]]></category>
		<category><![CDATA[cfengine 3]]></category>
		<category><![CDATA[cfengine3]]></category>
		<category><![CDATA[code sample]]></category>
		<category><![CDATA[code snippet]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[mint]]></category>
		<category><![CDATA[NFS]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[scp]]></category>
		<category><![CDATA[simple]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[tar]]></category>
		<category><![CDATA[tar.gz]]></category>

		<guid isPermaLink="false">http://www.xenuser.org/?p=2007</guid>
		<description><![CDATA[Today I noticed that it might be useful to backup some folders on one of my VMs from time to time. At first I thought about creating a new cron job, but then I noticed that Cfengine 3 is running on that VM. So &#8211; why not letting Cfengine 3 do all the work? Writing [...]


Related posts:<ol><li><a href='http://www.xenuser.org/open-source-development/creating-new-symlinks-with-cfengine-3/' rel='bookmark' title='Permanent Link: Creating new symlinks with Cfengine 3'>Creating new symlinks with Cfengine 3</a></li>
<li><a href='http://www.xenuser.org/open-source-development/add-a-new-user-with-cfengine-3/' rel='bookmark' title='Permanent Link: Add a new user with Cfengine 3'>Add a new user with Cfengine 3</a></li>
<li><a href='http://www.xenuser.org/open-source-development/simple-reporting-with-cfengine-3/' rel='bookmark' title='Permanent Link: Simple reporting with Cfengine 3'>Simple reporting with Cfengine 3</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Today I noticed that it might be useful to backup some folders on one of my VMs from time to time. At first I thought about creating a new cron job, but then I noticed that Cfengine 3 is running on that VM. So &#8211; why not letting Cfengine 3 do all the work?</p>
<p><strong>Writing the Cfengine 3 code for performing simple backups</strong></p>
<pre class="brush: text">
body common control {
        version         =&gt; &quot;1.0&quot;;
        inputs          =&gt; { &quot;cfengine_stdlib.cf&quot; };
        bundlesequence  =&gt; { &quot;simple_backup&quot; };
}

body contain cd(dir)    {
        chdir           =&gt;      &quot;${dir}&quot;;
        useshell        =&gt;      &quot;true&quot;;
}

bundle agent simple_backup {
        vars:
          &quot;backup_dir&quot;          string  =&gt; &quot;/var/backups&quot;;
          &quot;folder_list&quot;         string  =&gt; &quot;/root /etc /usr/local/bin&quot;;
          &quot;date&quot;                string  =&gt; execresult (&quot;/bin/date +\&quot;%k-%M_%m-%d-%y\&quot;&quot;, &quot;noshell&quot;);

        files:
          &quot;$(backup_dir)/.&quot;
                create  =&gt; &quot;true&quot;;

        commands:
          &quot;/bin/tar czvf automated_cfengine_backup-$(date).tar.gz $(folder_list)&quot;
                contain =&gt; cd($(backup_dir));
}
</pre>
<p>That&#8217;s already it! Now save the snippet as &#8220;xenuser_org-019-performing_simple_backups.cf&#8221; and apply it:</p>
<pre class="brush: bash">
/var/cfengine/bin/cf-promises -f xenuser_org-019-performing_simple_backups.cf
/var/cfengine/bin/cf-agent -f xenuser_org-019-performing_simple_backups.cf
</pre>
<p>Great! Let&#8217;s have a look at our backup folder:</p>
<pre class="brush: bash">
mintbox backups # ls -lah --color /var/backups
total 219M
drwxr-xr-x  4 root root   4,0K 2013-02-17 22:16 .
drwxr-xr-x 14 root root   4,0K 2013-02-17 20:50 ..
-rw-r--r--  1 root root    36K 2012-10-09 23:08 apt.extended_states.0
-rw-r--r--  1 root root   3,1K 2012-10-01 23:08 apt.extended_states.1.gz
-rw-r--r--  1 root root   3,1K 2012-09-22 23:08 apt.extended_states.2.gz
-rw-r--r--  1 root root   3,1K 2012-08-07 19:20 apt.extended_states.3.gz
-rw-r--r--  1 root root   3,0K 2012-06-20 22:59 apt.extended_states.4.gz
-rw-r--r--  1 root root   3,0K 2012-06-10 19:59 apt.extended_states.5.gz
-rw-r--r--  1 root root     42 2012-06-03 15:06 apt.extended_states.6.gz
-rw-r--r--  1 root root   2,8M 2012-05-09 22:36 aptitude.pkgstates.0
-rw-r--r--  1 root root   288K 2011-11-24 20:12 aptitude.pkgstates.1.gz
-rw-------  1 root root    32M 2013-02-17 21:21 automated_cfengine_backup-21-20_02-17-13.tar.gz
</pre>
<p>Yay! Cfengine 3 just created a simple backup!</p>
<p><strong>Analyzing the Cfengine 3 code snippet</strong><br />
Well, the first part of the code snippet doesn&#8217;t contain any surprises. At first we define the &#8220;body common control&#8221; which contains a few information about the Cfengine 3 policy file. Afterwards we create another body, but this time a &#8220;contain(ment) body&#8221; which provides a sandbox for running commands as a non-privileged user inside an isolated directory tree. The &#8220;body contain cd(dir)&#8221; is needed to define and run a change dir command which can be used later:</p>
<pre class="brush: text">
body common control {
        version         =&gt; &quot;1.0&quot;;
        inputs          =&gt; { &quot;cfengine_stdlib.cf&quot; };
        bundlesequence  =&gt; { &quot;simple_backup&quot; };
}

body contain cd(dir)    {
        chdir           =&gt;      &quot;${dir}&quot;;
        useshell        =&gt;      &quot;true&quot;;
}
</pre>
<p>The next section is very simple as it contains only a promise of the type vars. We define a place for storing our backups, a list of folders to be archived and we let Cfengine 3 define a variable which contains the current date:</p>
<pre class="brush: text">
bundle agent simple_backup {
        vars:
          &quot;backup_dir&quot;          string  =&gt; &quot;/var/backups&quot;;
          &quot;folder_list&quot;         string  =&gt; &quot;/root /etc /usr/local/bin&quot;;
          &quot;date&quot;                string  =&gt; execresult (&quot;/bin/date +\&quot;%k-%M_%m-%d-%y\&quot;&quot;, &quot;noshell&quot;);
</pre>
<p>Now here comes the interesting part. The promise of the type &#8220;files&#8221; ensures that our directory containing the backups exists. The promise of the type &#8220;commands&#8221; then runs the command &#8220;/bin/tar czvf&#8221; which creates a .tar.gz file. &#8220;$(folder list) contains the directories to be backed up:</p>
<pre class="brush: text">
        files:
          &quot;$(backup_dir)/.&quot;
                create  =&gt; &quot;true&quot;;

        commands:
          &quot;/bin/tar czvf automated_cfengine_backup-$(date).tar.gz $(folder_list)&quot;
                contain =&gt; cd($(backup_dir));
}
</pre>
<p><strong>Summary</strong><br />
As you can see, it is very easy to create a backup mechanism within Cfengine 3. However, my sample above lacks a few details:</p>
<ul>
<li>The backups are created each time Cfengine 3 runs.</li>
<li>The backups are stored locally.</li>
</ul>
<p>It is up to you if you let Cfengine 3 e.g. store the .tar.gz files on a NFS share or let them be transported to another server directly (rsync, scp..).</p>
<p>As usual, you can <a href="http://www.xenuser.org/downloads/cfengine3/xenuser_org-019-performing_simple_backups.cf" title="Cfengine 3 snippet: Perform simple backups" target="_blank">download today&#8217;s Cfengine 3 code snippet here</a>.</p>
<p> <img src="http://www.xenuser.org/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=2007" width="1" height="1" style="display: none;" /></p>


<p>Related posts:<ol><li><a href='http://www.xenuser.org/open-source-development/creating-new-symlinks-with-cfengine-3/' rel='bookmark' title='Permanent Link: Creating new symlinks with Cfengine 3'>Creating new symlinks with Cfengine 3</a></li>
<li><a href='http://www.xenuser.org/open-source-development/add-a-new-user-with-cfengine-3/' rel='bookmark' title='Permanent Link: Add a new user with Cfengine 3'>Add a new user with Cfengine 3</a></li>
<li><a href='http://www.xenuser.org/open-source-development/simple-reporting-with-cfengine-3/' rel='bookmark' title='Permanent Link: Simple reporting with Cfengine 3'>Simple reporting with Cfengine 3</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.xenuser.org/open-source-development/performing-simple-backups-with-cfengine-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuring sshd with Puppet</title>
		<link>http://www.xenuser.org/open-source-development/configuring-sshd-with-puppet/</link>
		<comments>http://www.xenuser.org/open-source-development/configuring-sshd-with-puppet/#comments</comments>
		<pubDate>Tue, 12 Feb 2013 22:39:06 +0000</pubDate>
		<dc:creator>valentin</dc:creator>
				<category><![CDATA[Open Source & Development]]></category>
		<category><![CDATA[Puppet]]></category>
		<category><![CDATA[code sample]]></category>
		<category><![CDATA[code snippet]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[configuration file]]></category>
		<category><![CDATA[configure]]></category>
		<category><![CDATA[dependency]]></category>
		<category><![CDATA[editing configuration]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[linux mint]]></category>
		<category><![CDATA[notify]]></category>
		<category><![CDATA[package]]></category>
		<category><![CDATA[reload]]></category>
		<category><![CDATA[restart]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[services]]></category>
		<category><![CDATA[sshd]]></category>
		<category><![CDATA[sshd_config]]></category>
		<category><![CDATA[trigger]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://www.xenuser.org/?p=2004</guid>
		<description><![CDATA[During this blog post, I will show you how to edit the sshd_config file and restart sshd if necessary. For the sake of completeness and since this blog post is part of the comparison series &#8220;Cfengine 3 vs. Puppet&#8221;, I want to point you to the Cfengine 3 code snippet which does exactly the same. [...]


Related posts:<ol><li><a href='http://www.xenuser.org/open-source-development/configuring-sshd-or-any-other-service-with-cfengine-3/' rel='bookmark' title='Permanent Link: Configuring SSHd (or any other service) with Cfengine 3'>Configuring SSHd (or any other service) with Cfengine 3</a></li>
<li><a href='http://www.xenuser.org/misc/installing-packages-with-puppet/' rel='bookmark' title='Permanent Link: Installing packages with Puppet'>Installing packages with Puppet</a></li>
<li><a href='http://www.xenuser.org/open-source-development/puppet-ensure-pre-defined-services-are-running/' rel='bookmark' title='Permanent Link: Puppet: Ensure pre-defined services are running'>Puppet: Ensure pre-defined services are running</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>During this blog post, I will show you how to edit the sshd_config file and restart sshd if necessary. For the sake of completeness and since this blog post is part of the comparison series &#8220;Cfengine 3 vs. Puppet&#8221;, <a href="http://www.xenuser.org/open-source-development/configuring-sshd-or-any-other-service-with-cfengine-3/" title="Cfengine 3: Configuring sshd" target="_blank">I want to point you to the Cfengine 3 code snippet which does exactly the same</a>.</p>
<p><strong>Writing the Puppet manifest for configuring sshd</strong></p>
<pre class="brush: text">
package	{ &quot;openssh-server&quot;:	ensure =&gt; &quot;installed&quot; }

service	{ &quot;ssh&quot;:		ensure =&gt; &quot;running&quot;,
				enable =&gt; &quot;true&quot;,
				require =&gt; Package[&quot;openssh-server&quot;]
}

augeas { &quot;configure_sshd&quot;:
	context	=&gt; &quot;/files/etc/ssh/sshd_config&quot;,
	changes	=&gt;	[ 	&quot;set PasswordAuthentication yes&quot;,
				&quot;set UsePam yes&quot;
			],
	require	=&gt; Package[&quot;openssh-server&quot;],
	notify	=&gt; Service[&quot;ssh&quot;]
}
</pre>
<p>Save the code snippet above as <em>/etc/puppet/manifests/xenuser_org-007-configuring_ssh_or_any_other_service.pp</em> and apply it:</p>
<pre class="brush: bash">
cp -a /etc/ssh/sshd_config /etc/ssh/sshd_config.BAK

puppet apply xenuser_org-007-configuring_ssh_or_any_other_service.pp
Warning: Could not retrieve fact fqdn
Notice: /Stage[main]//Augeas[configure_sshd]/returns: executed successfully
Notice: /Stage[main]//Service[ssh]: Triggered &#039;refresh&#039; from 1 events
Notice: Finished catalog run in 1.19 seconds

diff /etc/ssh/sshd_config.BAK /etc/ssh/sshd_config
51c51
&lt; PasswordAuthentication no
---
&gt; PasswordAuthentication yes
87c87
&lt; UsePam no
---
&gt; UsePam yes
</pre>
<p>As you can see, Puppet just changed some config values in sshd_config and took care of /etc/init.d/ssh.</p>
<p><strong>Analyzing the Puppet manifest</strong><br />
At first we define that there is a package which should be installed. &#8220;openssh-server&#8221; will be used later as a dependency for editing sshd_config:</p>
<pre class="brush: text">
package	{ &quot;openssh-server&quot;:	ensure =&gt; &quot;installed&quot; }
</pre>
<p>Afterwards, we define that the ssh service should always be running. Please note that we use &#8220;ssh&#8221; and not &#8220;sshd&#8221; so Puppet is able to find the init.d script:</p>
<pre class="brush: text">
service	{ &quot;ssh&quot;:		ensure =&gt; &quot;running&quot;,
				enable =&gt; &quot;true&quot;,
				require =&gt; Package[&quot;openssh-server&quot;]
}
</pre>
<p>Now here comes to most interesting part. We use augeas, a tool which was added after Puppet was already used for a couple of years, for editing the sshd_config file. Please note that we use the &#8220;set&#8221; command in the &#8220;changes&#8221; method. Last but not least, we define a dependency (package &#8220;openssh-server&#8221;) and let augeas trigger a reload of sshd if any changes were applied to the config file: </p>
<pre class="brush: text">
augeas { &quot;configure_sshd&quot;:
	context	=&gt; &quot;/files/etc/ssh/sshd_config&quot;,
	changes	=&gt;	[ 	&quot;set PasswordAuthentication yes&quot;,
				&quot;set UsePam yes&quot;
			],
	require	=&gt; Package[&quot;openssh-server&quot;],
	notify	=&gt; Service[&quot;ssh&quot;]
}
</pre>
<p><strong>Summary</strong><br />
When I compary both the Cfengine 3 and the Puppet snippets with each other, I find the Puppet manifest to be shorter, better readable and somehow more accurate. Everything is linked in the manifest while in Cfengine 3, we simply defined a couple of promised which were processed from line to line.</p>
<p>A disadvantage of Puppet (at least in my eyes) is that there is no direct ability to edit files; in Cfengine 3, you simply do it and have not to use another tool like augeas here.</p>
<p>However, both code snippets do the job. As usual, you can <a href="http://www.xenuser.org/downloads/puppet/xenuser_org-007-configuring_ssh_or_any_other_service.pp" title="Download the Puppet manifest for configuring sshd" target="_blank">download today&#8217;s Puppet manifest here</a>. <img src="http://www.xenuser.org/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=2004" width="1" height="1" style="display: none;" /></p>


<p>Related posts:<ol><li><a href='http://www.xenuser.org/open-source-development/configuring-sshd-or-any-other-service-with-cfengine-3/' rel='bookmark' title='Permanent Link: Configuring SSHd (or any other service) with Cfengine 3'>Configuring SSHd (or any other service) with Cfengine 3</a></li>
<li><a href='http://www.xenuser.org/misc/installing-packages-with-puppet/' rel='bookmark' title='Permanent Link: Installing packages with Puppet'>Installing packages with Puppet</a></li>
<li><a href='http://www.xenuser.org/open-source-development/puppet-ensure-pre-defined-services-are-running/' rel='bookmark' title='Permanent Link: Puppet: Ensure pre-defined services are running'>Puppet: Ensure pre-defined services are running</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.xenuser.org/open-source-development/configuring-sshd-with-puppet/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Running shell commands with Puppet</title>
		<link>http://www.xenuser.org/open-source-development/running-shell-commands-with-puppet/</link>
		<comments>http://www.xenuser.org/open-source-development/running-shell-commands-with-puppet/#comments</comments>
		<pubDate>Sun, 10 Feb 2013 15:02:15 +0000</pubDate>
		<dc:creator>valentin</dc:creator>
				<category><![CDATA[Open Source & Development]]></category>
		<category><![CDATA[Puppet]]></category>
		<category><![CDATA[code snippet]]></category>
		<category><![CDATA[command]]></category>
		<category><![CDATA[exec]]></category>
		<category><![CDATA[linux mint]]></category>
		<category><![CDATA[manifest]]></category>
		<category><![CDATA[run command]]></category>
		<category><![CDATA[run shell command]]></category>
		<category><![CDATA[run simple commands]]></category>
		<category><![CDATA[sample]]></category>

		<guid isPermaLink="false">http://www.xenuser.org/?p=2000</guid>
		<description><![CDATA[As you might be aware of, I am directly comparing all my previously 18 written Cfengine 3 code snippets with Puppet 2.x/3.x. This time a Puppet manifest will run a very simple shell command, similar to the Cfengine 3 version. Writing the Puppet manifest for running a shell command exec { &#34;start_mysql&#34;: command =&#62; &#34;/etc/init.d/mysql [...]


Related posts:<ol><li><a href='http://www.xenuser.org/open-source-development/running-shell-commands-with-cfengine-3/' rel='bookmark' title='Permanent Link: Running shell commands with Cfengine 3'>Running shell commands with Cfengine 3</a></li>
<li><a href='http://www.xenuser.org/open-source-development/puppet-ensure-pre-defined-services-are-running/' rel='bookmark' title='Permanent Link: Puppet: Ensure pre-defined services are running'>Puppet: Ensure pre-defined services are running</a></li>
<li><a href='http://www.xenuser.org/open-source-development/configuring-sshd-with-puppet/' rel='bookmark' title='Permanent Link: Configuring sshd with Puppet'>Configuring sshd with Puppet</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>As you might be aware of, I am directly comparing all my previously 18 written Cfengine 3 code snippets with Puppet 2.x/3.x.<br />
This time a Puppet manifest will run a very simple shell command, <a href="http://www.xenuser.org/open-source-development/running-shell-commands-with-cfengine-3/" title="Cfengine 3: Running a simple shell command" target="_blank">similar to the Cfengine 3 version</a>.</p>
<p><strong>Writing the Puppet manifest for running a shell command</strong></p>
<pre class="brush: text">
exec { &quot;start_mysql&quot;:
	command	=&gt; &quot;/etc/init.d/mysql start&quot;

	# Here you could also use require
	# require	=&gt; Package[&quot;mysql-server&quot;]

	# Another important feature would be setting the path variable
	# path	=&gt; &quot;/usr/local/bin:/bin/&quot;
}
</pre>
<p>Now let&#8217;s apply the manifest and verify the result:</p>
<pre class="brush: bash">
/etc/init.d/mysql stop

ps aux |grep mysql
root     12366  0.0  0.0   4384   832 pts/0    S+   15:48   0:00 grep
--colour=auto mysql

puppet apply xenuser_org-006-running_shell_commands.pp
Warning: Could not retrieve fact fqdn
Notice: /Stage[main]//Exec[start_mysql]/returns: executed successfully
Notice: Finished catalog run in 2.25 seconds

ps aux |grep mysql
mysql    12611  2.7  0.9 318512 34604 ?        Ssl  15:48   0:00
/usr/sbin/mysqld
root     12833  0.0  0.0   4384   836 pts/0    S+   15:48   0:00 grep
--colour=auto mysql
</pre>
<p>There you go &#8211; MySQL is up and running.</p>
<p><strong>Summary</strong><br />
I think that executing shell commands directly via a Puppet manifest is not very &#8220;clean&#8221;, but sometimes you have no other option. I like that the function for doing so is called &#8220;exec&#8221; and that there are a lot of cool and useful parameters for it:<br />
<a href="http://docs.puppetlabs.com/references/stable/type.html#exec" title="Puppetlabs - documentation of exec" target="_blank">http://docs.puppetlabs.com/references/stable/type.html#exec</a></p>
<p>Compared to Cfengine 3, I am missing the &#8220;comment&#8221; which will appear in the syslog. However, the code in Puppet is much shorter.<br />
As usual, you can <a href="http://www.xenuser.org/downloads/puppet/xenuser_org-006-running_shell_commands.pp" title="Puppet manifest: Execute a single shell command" target="_blank">download today&#8217;s Puppet manifest for executing a shell command here</a>.<br />
 <img src="http://www.xenuser.org/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=2000" width="1" height="1" style="display: none;" /></p>


<p>Related posts:<ol><li><a href='http://www.xenuser.org/open-source-development/running-shell-commands-with-cfengine-3/' rel='bookmark' title='Permanent Link: Running shell commands with Cfengine 3'>Running shell commands with Cfengine 3</a></li>
<li><a href='http://www.xenuser.org/open-source-development/puppet-ensure-pre-defined-services-are-running/' rel='bookmark' title='Permanent Link: Puppet: Ensure pre-defined services are running'>Puppet: Ensure pre-defined services are running</a></li>
<li><a href='http://www.xenuser.org/open-source-development/configuring-sshd-with-puppet/' rel='bookmark' title='Permanent Link: Configuring sshd with Puppet'>Configuring sshd with Puppet</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.xenuser.org/open-source-development/running-shell-commands-with-puppet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Managing APT sources.lists with Puppet</title>
		<link>http://www.xenuser.org/open-source-development/managing-apt-sources-lists-with-puppet/</link>
		<comments>http://www.xenuser.org/open-source-development/managing-apt-sources-lists-with-puppet/#comments</comments>
		<pubDate>Sun, 03 Feb 2013 20:04:31 +0000</pubDate>
		<dc:creator>valentin</dc:creator>
				<category><![CDATA[Open Source & Development]]></category>
		<category><![CDATA[Puppet]]></category>
		<category><![CDATA[apt]]></category>
		<category><![CDATA[code snippet]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[linux mint]]></category>
		<category><![CDATA[management]]></category>
		<category><![CDATA[mint]]></category>
		<category><![CDATA[mirrors]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[release]]></category>
		<category><![CDATA[repos]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[sources.list]]></category>
		<category><![CDATA[sources.list management]]></category>
		<category><![CDATA[sources.list.d]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.xenuser.org/?p=1990</guid>
		<description><![CDATA[For this part of my comparison series &#8220;Cfengine 3 vs. Puppet&#8221; I upgraded my Linux Mint 12 to 13 and switched to Puppet 3.0.2. If you download and try my little code snippets I recommend to use at least Puppet 2.7.14 since this version is able to run the official apt module from Puppetlabs. While [...]


Related posts:<ol><li><a href='http://www.xenuser.org/linux/managing-apt-sources-lists-with-cfengine-3/' rel='bookmark' title='Permanent Link: Managing APT sources.lists with Cfengine 3'>Managing APT sources.lists with Cfengine 3</a></li>
<li><a href='http://www.xenuser.org/open-source-development/running-shell-commands-with-puppet/' rel='bookmark' title='Permanent Link: Running shell commands with Puppet'>Running shell commands with Puppet</a></li>
<li><a href='http://www.xenuser.org/open-source-development/using-environment-variables-in-puppet/' rel='bookmark' title='Permanent Link: Using environment variables in Puppet'>Using environment variables in Puppet</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>For this part of my comparison series &#8220;Cfengine 3 vs. Puppet&#8221; I upgraded my Linux Mint 12 to 13 and switched to Puppet 3.0.2. If you download and try my little code snippets I recommend to use at least Puppet 2.7.14 since this version is able to run <a href="https://forge.puppetlabs.com/puppetlabs/apt" title="apt module documentation from Puppetlabs" target="_blank">the official apt module from Puppetlabs</a>.</p>
<p><a href="http://www.xenuser.org/linux/managing-apt-sources-lists-with-cfengine-3/" title="Managing apt sources.list files with Cfengine 3" target="_blank">While the fifth part in my Cfengine 3 blog series was about managing apt sources lists with Cfengine 3</a>, this blog post will cover the same topic except that we use Puppet instead of the other configuration management tool from Oslo, Norway.</p>
<p><strong>Writing the Puppet manifest for managing apt sources.list files</strong></p>
<pre class="brush: text">
include apt

apt::source { &quot;puppetlabs_precise&quot;:
        location        =&gt; &quot;http://apt.puppetlabs.com/&quot;,
        release         =&gt; &quot;precise&quot;,
        repos           =&gt; &quot; main&quot;,
        include_src     =&gt; false
}

apt::source { &quot;ubuntu_archiv_precise&quot;:
        location        =&gt; &quot;http://archive.ubuntu.com/&quot;,
        release         =&gt; &quot;precise&quot;,
        repos           =&gt; &quot;main restricted universe multiverse&quot;,
        include_src     =&gt; false
}

apt::source { &quot;ubuntu_archiv_precise-updates&quot;:
        location        =&gt; &quot;http://archive.ubuntu.com/&quot;,
        release         =&gt; &quot;precise-updates&quot;,
        repos           =&gt; &quot;main restricted universe multiverse&quot;,
        include_src     =&gt; false
}

apt::source { &quot;ubuntu_archiv_precise-security&quot;:
        location        =&gt; &quot;http://archive.ubuntu.com/&quot;,
        release         =&gt; &quot;precise-security&quot;,
        repos           =&gt; &quot;main restricted universe multiverse&quot;,
        include_src     =&gt; false
}

apt::source { &quot;canonical_archiv_precise&quot;:
        location        =&gt; &quot;http://archive.canonical.com/ubuntu/&quot;,
        release         =&gt; &quot;precise&quot;,
        repos           =&gt; &quot;partner&quot;,
        include_src     =&gt; false
}

apt::source { &quot;linuxmint_maya&quot;:
        location        =&gt; &quot;http://packages.linuxmint.com/&quot;,
        release         =&gt; &quot;maya&quot;,
        repos           =&gt; &quot;main upstream import&quot;,
        include_src     =&gt; false
}
</pre>
<p>The sample above will only work with the official apt module from Puppetlabs, so make sure you install it before you run the Puppet manifest:</p>
<pre class="brush: bash">
puppet module install puppetlabs/apt
Notice: Preparing to install into /etc/puppet/modules ...
Notice: Downloading from https://forge.puppetlabs.com ...
Notice: Installing -- do not interrupt ...
/etc/puppet/modules
└─┬ puppetlabs-apt (v1.1.0)
  └── puppetlabs-stdlib (v3.2.0)

puppet apply /etc/puppet/manifests/xenuser_org-005-managing_apt_sources_lists.pp
</pre>
<p>What now happens is that Puppet creates a bunch of files in /etc/apt/sources.list.d/ and runs apt-get update.<br />
Lets verify that our Puppet manifest works:</p>
<pre class="brush: bash">
cd /etc/apt/sources.list.d
ls -la
total 40
drwxr-xr-x 2 root root 4096 Feb  3 20:48 .
drwxr-xr-x 7 root root 4096 Feb  3 20:48 ..
-rw-r--r-- 1 root root   84 Feb  3 20:42 canonical_archiv_precise.list
-rw-r--r-- 1 root root   78 Feb  3 20:42 linuxmint_maya.list
-rw-r--r-- 1 root root   50 Jun 20  2012 local-repository.list
-rw-r--r-- 1 root root   49 Jun 20  2012 local-repository.list.save
-rw-r--r-- 1 root root   66 Feb  3 20:42 puppetlabs_precise.list
-rw-r--r-- 1 root root   99 Feb  3 20:42 ubuntu_archiv_precise.list
-rw-r--r-- 1 root root  117 Feb  3 20:42 ubuntu_archiv_precise-security.list
-rw-r--r-- 1 root root  115 Feb  3 20:42 ubuntu_archiv_precise-updates.list
</pre>
<p>Go ahead and have a look at those files <img src='http://www.xenuser.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><strong>Analyzing the code snippet and summary</strong><br />
Instead of editing the file /etc/apt/sources.list directly (like I did in the Cfengine 3 version of this code snippet), we let Puppet create single sources.list files for every &#8220;apt source&#8221;. The downside of this approach is that we have to define a &#8220;release&#8221; for each &#8220;section&#8221; of the same release name (e.g. precise, precise-updates&#8230;).</p>
<p>While this is definitely a good and clean approach for managing apt sources.list files, we now have more complexity in comparison to the single file approach. However, I think that using the apt Puppet module is the right way to do it.</p>
<p>As usual, you can <a href="http://www.xenuser.org/downloads/cfengine3/xenuser_org-005-managing_apt_sources_lists.cf" title="Puppet manifest for managing apt sources.list files" target="_blank">download today&#8217;s Puppet manifest here</a>.</p>
<p><strong>Update from February 10th, 2013:</strong><br />
As Jean Rémond suggested in the comment below, you could also use &#8220;${::lsbdistcodename} instead of directly naming the distri version name, such as precise. However, in my example, using this variable brought &#8220;lisa&#8221; as the result (although my Linux Mint was updated from version 12 &#8220;Lisa&#8221; to version 13 &#8220;Maya&#8221;).<br />
Here is the code snippet I used:</p>
<pre class="brush: text">
apt::source { &quot;test&quot;:
        location        =&gt; &quot;http://test.test.com/&quot;,
        release         =&gt; &quot;${::lsbdistcodename}&quot;,
        repos           =&gt; &quot;main upstream import&quot;,
        include_src     =&gt; false
}
</pre>
<p>There might be a better way than writing &#8220;precise&#8221; or &#8220;maya&#8221; directly into the Puppet manifest; maybe I&#8217;ll cover that in another blog post. <img src="http://www.xenuser.org/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1990" width="1" height="1" style="display: none;" /></p>


<p>Related posts:<ol><li><a href='http://www.xenuser.org/linux/managing-apt-sources-lists-with-cfengine-3/' rel='bookmark' title='Permanent Link: Managing APT sources.lists with Cfengine 3'>Managing APT sources.lists with Cfengine 3</a></li>
<li><a href='http://www.xenuser.org/open-source-development/running-shell-commands-with-puppet/' rel='bookmark' title='Permanent Link: Running shell commands with Puppet'>Running shell commands with Puppet</a></li>
<li><a href='http://www.xenuser.org/open-source-development/using-environment-variables-in-puppet/' rel='bookmark' title='Permanent Link: Using environment variables in Puppet'>Using environment variables in Puppet</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.xenuser.org/open-source-development/managing-apt-sources-lists-with-puppet/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Mounting NFS-Shares with Puppet</title>
		<link>http://www.xenuser.org/open-source-development/mounting-nfs-shares-with-puppet/</link>
		<comments>http://www.xenuser.org/open-source-development/mounting-nfs-shares-with-puppet/#comments</comments>
		<pubDate>Sat, 19 Jan 2013 20:45:11 +0000</pubDate>
		<dc:creator>valentin</dc:creator>
				<category><![CDATA[Open Source & Development]]></category>
		<category><![CDATA[Puppet]]></category>
		<category><![CDATA[/etc/fstab]]></category>
		<category><![CDATA[code sample]]></category>
		<category><![CDATA[code snippet]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[fstab]]></category>
		<category><![CDATA[linux mint]]></category>
		<category><![CDATA[manifest]]></category>
		<category><![CDATA[mount]]></category>
		<category><![CDATA[mounting]]></category>
		<category><![CDATA[NFS]]></category>
		<category><![CDATA[sample]]></category>

		<guid isPermaLink="false">http://www.xenuser.org/?p=1985</guid>
		<description><![CDATA[Welcome to the next part of my little blog entry series about comparing Cfengine 3 with Puppet. In this issue, we will write a Puppet manifest for mounting a NFS share. You can compare it directly to the Cfengine 3 code snippet if you click here. Writing the Puppet code snippet for mounting a NFS [...]


Related posts:<ol><li><a href='http://www.xenuser.org/linux/mounting-nfs-shares-with-cfengine-3/' rel='bookmark' title='Permanent Link: Mounting NFS-Shares with Cfengine 3'>Mounting NFS-Shares with Cfengine 3</a></li>
<li><a href='http://www.xenuser.org/open-source-development/managing-apt-sources-lists-with-puppet/' rel='bookmark' title='Permanent Link: Managing APT sources.lists with Puppet'>Managing APT sources.lists with Puppet</a></li>
<li><a href='http://www.xenuser.org/open-source-development/performing-simple-backups-with-cfengine-3/' rel='bookmark' title='Permanent Link: Performing simple Backups with Cfengine 3'>Performing simple Backups with Cfengine 3</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Welcome to the next part of my little blog entry series about comparing Cfengine 3 with Puppet.<br />
In this issue, we will write a Puppet manifest for mounting a NFS share. You can compare it directly to the Cfengine 3 code snippet if you click <a href="http://www.xenuser.org/linux/mounting-nfs-shares-with-cfengine-3/" title="Cfengine 3 code snippet for mounting a NFS share" target="_blank">here</a>.</p>
<p>Writing the Puppet code snippet for mounting a NFS share</p>
<pre class="brush: text">
mount { &quot;/mnt&quot;:
        device  =&gt; &quot;localhost:/blubb&quot;,
        fstype  =&gt; &quot;nfs&quot;,
        ensure  =&gt; &quot;mounted&quot;,
        options =&gt; &quot;defaults&quot;,
        atboot  =&gt; &quot;true&quot;,
}
</pre>
<p>Save the file as /etc/puppet/manifests/xenuser_org-004-mounting_a_nfs_share.pp and let it run:</p>
<pre class="brush: bash">
ls -lah --color /mnt
total 8,0K
drwxr-xr-x  2 root root 4,0K 2012-05-10 22:36 .
drwxr-xr-x 23 root root 4,0K 2012-08-20 22:04 ..

puppet apply xenuser_org-004-mounting_a_nfs_share.pp
warning: Could not retrieve fact fqdn
notice: /Stage[main]//Mount[/mnt]/ensure: defined &#039;ensure&#039; as &#039;mounted&#039;
notice: /Stage[main]//Mount[/mnt]: Triggered &#039;refresh&#039; from 1 events
notice: Finished catalog run in 0.18 seconds
</pre>
<p>As you can see, Puppet claims that the provided NFS share was mounted. Let&#8217;s verify that:</p>
<pre class="brush: bash">
grep blubb /proc/mounts
localhost:/blubb/ /mnt nfs4 rw,relatime,vers=4,rsize=524288,wsize=524288,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=127.0.0.1,minorversion=0,local_lock=none,addr=127.0.0.1 0 0

ls -lah --color /mnt
total 8,0K
drwxr-xr-x  2 root root 4,0K 2012-05-10 22:36 .
drwxr-xr-x 23 root root 4,0K 2012-08-20 22:04 ..
-rw-r--r--  1 root root    0 2012-05-10 22:36 blobb
</pre>
<p>Great!</p>
<p><strong>Summary</strong><br />
Mounting the NFS share via Puppet was easy. In addition, Puppet added a new entry in /etc/fstab:</p>
<pre class="brush: bash">
cat /etc/fstab
# HEADER: This file was autogenerated at Sat Jan 19 21:27:19 +0100 2013
# HEADER: by puppet.  While it can still be managed manually, it
# HEADER: is definitely not recommended.
# /etc/fstab: static file system information.
#
# Use &#039;blkid&#039; to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# &lt;file system&gt; &lt;mount point&gt;   &lt;type&gt;  &lt;options&gt;       &lt;dump&gt;  &lt;pass&gt;
proc	/proc	proc	nodev,noexec,nosuid	0	0
# / was on /dev/sda1 during installation
UUID=f89cb605-8324-424f-9a0c-c555e7e0e779	/	ext4,acl	errors=remount-ro	0	1
# swap was on /dev/sda5 during installation
UUID=a66917ea-c89b-4067-80ec-7c13f0a4bd1c	none	swap	sw	0	0
localhost:/blubb	/mnt	nfs	defaults	0	0
</pre>
<p>There is also a way to add an entry to the fstab file with Cfengine 3 but unfortunately I did not cover it in my <a href="http://www.xenuser.org/linux/mounting-nfs-shares-with-cfengine-3/" title="Cfengine 3 code snippet for mounting NFS shares" target="_blank">blog entry about mounting NFS shares with Cfengine 3</a>.</p>
<p>When comparing both the Cfengine 3 and Puppet snippets with each other, I do not see which configuration management tool does it the more effective or easy way. Both do a good job when looking at the amount of lines you need to write for this purpose. However, one could argue that Puppet does the job a little bit better since you can directly provide the info if the NFS share should be mounted at  boots or not (fstab entry).</p>
<p>As usual, you can download today&#8217;s Puppet manifest <a href="http://www.xenuser.org/downloads/puppet/xenuser_org-004-mounting_a_nfs_share.pp" title="Puppet manifest for mounting a NFS share" target="_blank">here</a>. <img src="http://www.xenuser.org/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1985" width="1" height="1" style="display: none;" /></p>


<p>Related posts:<ol><li><a href='http://www.xenuser.org/linux/mounting-nfs-shares-with-cfengine-3/' rel='bookmark' title='Permanent Link: Mounting NFS-Shares with Cfengine 3'>Mounting NFS-Shares with Cfengine 3</a></li>
<li><a href='http://www.xenuser.org/open-source-development/managing-apt-sources-lists-with-puppet/' rel='bookmark' title='Permanent Link: Managing APT sources.lists with Puppet'>Managing APT sources.lists with Puppet</a></li>
<li><a href='http://www.xenuser.org/open-source-development/performing-simple-backups-with-cfengine-3/' rel='bookmark' title='Permanent Link: Performing simple Backups with Cfengine 3'>Performing simple Backups with Cfengine 3</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.xenuser.org/open-source-development/mounting-nfs-shares-with-puppet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing packages with Puppet</title>
		<link>http://www.xenuser.org/misc/installing-packages-with-puppet/</link>
		<comments>http://www.xenuser.org/misc/installing-packages-with-puppet/#comments</comments>
		<pubDate>Sat, 12 Jan 2013 20:18:39 +0000</pubDate>
		<dc:creator>valentin</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Open Source & Development]]></category>
		<category><![CDATA[Puppet]]></category>
		<category><![CDATA[code sample]]></category>
		<category><![CDATA[code snippet]]></category>
		<category><![CDATA[installing new packages]]></category>
		<category><![CDATA[linux mint]]></category>
		<category><![CDATA[manifest]]></category>
		<category><![CDATA[several ways]]></category>

		<guid isPermaLink="false">http://www.xenuser.org/?p=1977</guid>
		<description><![CDATA[Part three of my little blog series &#8220;Cfengine 3 vs Puppet&#8221; shows several ways of how new packages can be installed with Puppet. Writing the Puppet manifest for installing new packages # There are multiple possibilities here, 3 of them are shown here # Possibility #1 # package { &#34;slapd&#34;: ensure =&#62; &#34;installed&#34; } # [...]


Related posts:<ol><li><a href='http://www.xenuser.org/linux/installing-packages-with-cfengine-3/' rel='bookmark' title='Permanent Link: Installing packages with Cfengine 3'>Installing packages with Cfengine 3</a></li>
<li><a href='http://www.xenuser.org/open-source-development/configuring-sshd-with-puppet/' rel='bookmark' title='Permanent Link: Configuring sshd with Puppet'>Configuring sshd with Puppet</a></li>
<li><a href='http://www.xenuser.org/open-source-development/puppet-ensure-pre-defined-services-are-running/' rel='bookmark' title='Permanent Link: Puppet: Ensure pre-defined services are running'>Puppet: Ensure pre-defined services are running</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Part three of my little blog series &#8220;Cfengine 3 vs Puppet&#8221; shows several ways of how new packages can be installed with Puppet.</p>
<p><strong>Writing the Puppet manifest for installing new packages</strong></p>
<pre class="brush: text">
# There are multiple possibilities here, 3 of them are shown here
# Possibility #1
# package { &quot;slapd&quot;:            ensure  =&gt; &quot;installed&quot; }
# package { &quot;ldap-utils&quot;:       ensure  =&gt; &quot;installed&quot; }

# Possibility #2
# Package {                     ensure =&gt; &quot;installed&quot; }
# package { &quot;slapd&quot;: }
# package { &quot;ldap-utils&quot;: }

# Possiblity #3
 $packagesToBeInstalled = [ &quot;slapd&quot;, &quot;ldap-utils&quot; ]
 package { $packagesToBeInstalled:      ensure =&gt; &quot;installed&quot;
</pre>
<p>I saved the Puppet code snippet above as /etc/puppet/xenuser_org-003-ensure_packages_are_installed.pp and ran it with&#8230;</p>
<pre class="brush: bash">
puppet apply xenuser_org-003-ensure_packages_are_installed.pp
warning: Could not retrieve fact fqdn
notice: /Stage[main]//Package[slapd]/ensure: created
notice: /Stage[main]//Package[ldap-utils]/ensure: ensure changed &#039;purged&#039; to &#039;present&#039;
notice: Finished catalog run in 18.09 seconds
</pre>
<p>On my Linux Mint box I can verify that these packages got installed with&#8230;</p>
<pre class="brush: bash">
dpkg -l |grep slapd
ii  slapd                                  2.4.25-1.1ubuntu4.1                     OpenLDAP server (slapd)
dpkg -l |grep ldap-utils
ii  ldap-utils                             2.4.25-1.1ubuntu4.1                     OpenLDAP utilities
</pre>
<p><strong>Some words on the code</strong><br />
<a href="http://www.puppetcookbook.com/posts/install-multiple-packages.html" title="Puppet cookbook: How to install packages with Puppet" target="_blank">One link I found showed me</a> that there are several ways of installing packages with Puppet. The most simple and straight forward way is this one:</p>
<pre class="brush: text">
package { &quot;slapd&quot;:            ensure  =&gt; &quot;installed&quot; }
package { &quot;ldap-utils&quot;:       ensure  =&gt; &quot;installed&quot; }
</pre>
<p>The second possibility of installing new packages could be this one:</p>
<pre class="brush: text">
Package {                     ensure =&gt; &quot;installed&quot; }
package { &quot;slapd&quot;: }
package { &quot;ldap-utils&quot;: }
</pre>
<p>I think it is not 100% self-explaining, but still easy to adapt to your needs.<br />
Another way, <a href="http://www.xenuser.org/linux/installing-packages-with-cfengine-3/" title="Cfengine 3 code snippet: Install new packages" target="_blank">similar to the one I used in the Cfengine 3 snippet</a>:</p>
<pre class="brush: text">
$packagesToBeInstalled = [ &quot;slapd&quot;, &quot;ldap-utils&quot; ]
package { $packagesToBeInstalled:      ensure =&gt; &quot;installed&quot; }
</pre>
<p>I like this way the most. You first define an array containing the packages to be installed and then use the array in the &#8220;package&#8221; method. Awesome!</p>
<p><strong>Summary</strong><br />
Again I am surprised in a positive way; the Puppet code is even shorter than the Cfengine 3 code snippet, but still performing the same task.</p>
<p>As usual you can download today&#8217;s Puppet manifest <a href="http://www.xenuser.org/downloads/puppet/xenuser_org-003-ensure_packages_are_installed.pp" title="Download the Puppet manifest for installing new packages" target="_blank">here</a>.<br />
 <img src="http://www.xenuser.org/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1977" width="1" height="1" style="display: none;" /></p>


<p>Related posts:<ol><li><a href='http://www.xenuser.org/linux/installing-packages-with-cfengine-3/' rel='bookmark' title='Permanent Link: Installing packages with Cfengine 3'>Installing packages with Cfengine 3</a></li>
<li><a href='http://www.xenuser.org/open-source-development/configuring-sshd-with-puppet/' rel='bookmark' title='Permanent Link: Configuring sshd with Puppet'>Configuring sshd with Puppet</a></li>
<li><a href='http://www.xenuser.org/open-source-development/puppet-ensure-pre-defined-services-are-running/' rel='bookmark' title='Permanent Link: Puppet: Ensure pre-defined services are running'>Puppet: Ensure pre-defined services are running</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.xenuser.org/misc/installing-packages-with-puppet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Puppet: Ensure pre-defined services are running</title>
		<link>http://www.xenuser.org/open-source-development/puppet-ensure-pre-defined-services-are-running/</link>
		<comments>http://www.xenuser.org/open-source-development/puppet-ensure-pre-defined-services-are-running/#comments</comments>
		<pubDate>Sun, 06 Jan 2013 20:41:33 +0000</pubDate>
		<dc:creator>valentin</dc:creator>
				<category><![CDATA[Open Source & Development]]></category>
		<category><![CDATA[Puppet]]></category>
		<category><![CDATA[code sample]]></category>
		<category><![CDATA[code snippet]]></category>
		<category><![CDATA[ensure]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[manifest]]></category>
		<category><![CDATA[pre-defined]]></category>
		<category><![CDATA[restart]]></category>
		<category><![CDATA[running]]></category>
		<category><![CDATA[services]]></category>
		<category><![CDATA[start]]></category>

		<guid isPermaLink="false">http://www.xenuser.org/?p=1967</guid>
		<description><![CDATA[Welcome to part two of my series of blog entries about comparing Cfengine 3 to Puppet. The goal is to write little task-orientated snippets for both configuration management tools and compare the results each time. The goal is to find out which piece of software is easiest to learn and use. Today we are re-writing [...]


Related posts:<ol><li><a href='http://www.xenuser.org/open-source-development/configuring-sshd-with-puppet/' rel='bookmark' title='Permanent Link: Configuring sshd with Puppet'>Configuring sshd with Puppet</a></li>
<li><a href='http://www.xenuser.org/misc/installing-packages-with-puppet/' rel='bookmark' title='Permanent Link: Installing packages with Puppet'>Installing packages with Puppet</a></li>
<li><a href='http://www.xenuser.org/open-source-development/running-shell-commands-with-puppet/' rel='bookmark' title='Permanent Link: Running shell commands with Puppet'>Running shell commands with Puppet</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Welcome to part two of my series of blog entries about comparing Cfengine 3 to Puppet. The goal is to write little task-orientated snippets for both configuration management tools and compare the results each time. The goal is to find out which piece of software is easiest to learn and use.</p>
<p>Today we are re-writing the <a href="http://www.xenuser.org/linux/cfengine3-check-for-running-services/" title="Cfengine 3: Ensure pre-defined services are running" target="_blank">Cfengine 3 code snippet which ensured that a list of pre-defined services are running</a>.</p>
<p><strong>Writing the Puppet code snippet for ensuring that those services are running</strong></p>
<pre class="brush: text">
service { &quot;apache2&quot;:
        ensure  =&gt; &quot;running&quot;,
}

service { &quot;mysql&quot;:
        ensure  =&gt; &quot;running&quot;,
}
</pre>
<p>Save the code above as /etc/puppet/manifests/xenuser_org-002-ensure_processes_are_running.pp and execute it:</p>
<pre class="brush: bash">
puppet apply xenuser_org-002-ensure_processes_are_running.pp
warning: Could not retrieve fact fqdn
notice: /Stage[main]//Service[mysql]/ensure: ensure changed &#039;stopped&#039; to &#039;running&#039;
notice: /Stage[main]//Service[apache2]/ensure: ensure changed &#039;stopped&#039; to &#039;running&#039;
notice: Finished catalog run in 1.35 seconds
</pre>
<p>On my box (Linux Minth 12), Apache2 and MySQL were both installed and not running. Applying the Puppet manifest started those services again. You might have to adjust the code for your local Linux test box.</p>
<p><strong>Analyzing the Puppet manifest</strong><br />
There is not much to do in terms of analyzing the code snippet above. It is very short and simple. I like that.<br />
One could argue that it would be better to define a list of services and apply the &#8220;ensure -> running&#8221; part on the list while iterating through it. However, the approach above is sufficient.</p>
<p>By the way, Puppet supports a notifying method which listens on changes of a specified config file of a specific service. If the config file is changed, the correct service will be restarted.</p>
<p><strong>Summary</strong><br />
In comparison to the Cfengine 3 snippet we had to write less &#8220;code&#8221; and achieved the same result. What I liked most was that I did not have to provide the path to the init scripts.</p>
<p>As usual, you can <a href="http://xenuser.org/downloads/puppet/xenuser_org-002-ensure_processes_are_running.pp" title="Puppet manifest: Restart pre-defined services" target="_blank">download today&#8217;s Puppet manifest here</a>. <img src="http://www.xenuser.org/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1967" width="1" height="1" style="display: none;" /></p>


<p>Related posts:<ol><li><a href='http://www.xenuser.org/open-source-development/configuring-sshd-with-puppet/' rel='bookmark' title='Permanent Link: Configuring sshd with Puppet'>Configuring sshd with Puppet</a></li>
<li><a href='http://www.xenuser.org/misc/installing-packages-with-puppet/' rel='bookmark' title='Permanent Link: Installing packages with Puppet'>Installing packages with Puppet</a></li>
<li><a href='http://www.xenuser.org/open-source-development/running-shell-commands-with-puppet/' rel='bookmark' title='Permanent Link: Running shell commands with Puppet'>Running shell commands with Puppet</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.xenuser.org/open-source-development/puppet-ensure-pre-defined-services-are-running/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTC Desire Z: Aktualisiertes Review nach über 2 Jahren</title>
		<link>http://www.xenuser.org/android/htc-desire-z-aktualisiertes-review-nach-uber-2-jahren/</link>
		<comments>http://www.xenuser.org/android/htc-desire-z-aktualisiertes-review-nach-uber-2-jahren/#comments</comments>
		<pubDate>Sat, 05 Jan 2013 23:00:34 +0000</pubDate>
		<dc:creator>valentin</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[HTC Desire Z]]></category>
		<category><![CDATA[desire z]]></category>
		<category><![CDATA[Erfahrungsbericht]]></category>
		<category><![CDATA[hardware-tastatur]]></category>
		<category><![CDATA[htc]]></category>
		<category><![CDATA[kauf]]></category>
		<category><![CDATA[nachfolger]]></category>
		<category><![CDATA[review]]></category>
		<category><![CDATA[slider]]></category>

		<guid isPermaLink="false">http://www.xenuser.org/?p=1962</guid>
		<description><![CDATA[For English speaking readers: This is one of the few German blog posts. Rest ensured that most of the upcoming content will be written in English. Anfang November 2010 schaffte ich mir das damals brandneue HTC Desire Z bei O2 an (ich &#8220;bloggte&#8221;). Damals sprach vor allem die Hardware-Tastatur für das Gerät, obwohl es mit [...]


Related posts:<ol><li><a href='http://www.xenuser.org/android/htc-desire-z-mit-android-2-2-froyo-erster-eindruck/' rel='bookmark' title='Permanent Link: HTC Desire Z mit Android 2.2 (Froyo): Erster Eindruck'>HTC Desire Z mit Android 2.2 (Froyo): Erster Eindruck</a></li>
<li><a href='http://www.xenuser.org/gaming/the-best-games-for-android-2-2-froyo-running-on-a-htc-desire-z/' rel='bookmark' title='Permanent Link: The best games for Android 2.2 (Froyo) running on a HTC Desire Z'>The best games for Android 2.2 (Froyo) running on a HTC Desire Z</a></li>
<li><a href='http://www.xenuser.org/xen/xen-ported-to-arm-architecture/' rel='bookmark' title='Permanent Link: Xen ported to ARM architecture'>Xen ported to ARM architecture</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>For English speaking readers: This is one of the few German blog posts. Rest ensured that most of the upcoming content will be written in English.</p>
<p>Anfang November 2010 schaffte ich mir das damals brandneue HTC Desire Z bei O2 an (<a href="http://www.xenuser.org/android/htc-desire-z-mit-android-2-2-froyo-erster-eindruck/" title="HTC Desire Z: Erster Eindruck" target="_blank">ich &#8220;bloggte&#8221;</a>). Damals sprach vor allem die Hardware-Tastatur für das Gerät, obwohl es mit 560 Euro recht teuer war.</p>
<p><strong>Immernoch zufrieden!</strong><br />
Nach 2 Jahren und knapp 3 Monaten fällt mein Fazit immer noch sehr positiv aus: Das Gerät weist zwar deutliche Gebrauchsspuren an der Hülle auf, ist aber immernoch in Takt. Der Akku hält gefühlt noch genauso lange wie zu Beginn und der Slide-Mechanismus des Keyboards ist kein bisschen abgenutzt.</p>
<p>Leider ging mir im April 2011 das Display kaputt, was jedoch gegen 140 Euro Gebühr von einem Münchner Unternehmen ausgetauscht wurde.</p>
<p><strong>Einziges Manko: Android <img src='http://www.xenuser.org/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </strong><br />
HTC hat als letzte Android-Version 2.3.3 für das Desire Z veröffentlicht. Während ich auch ohne Android 3/4 auskomme, stört mich doch, dass das Handy schon beim Starten von wenigen Apps anfängt zu ruckeln. Ab und an erscheint zusätzlich ein weißer Bildschirm mit dem HTC-Schriftzug, was einem &#8220;Reload&#8221; gleich kommt. Während dieser Zeit kann ich das Gerät fast nicht bedienen &#8211; ungünstig! Selbst die Deinstallation von nicht mehr benötigten Apps und das Löschen von Daten bringt keine Besserung (vermutlich hilft nur ein vollständiger Reset, aka &#8220;Neuinstallation&#8221;).</p>
<p><strong>2 Jahre &#8211; und nun?</strong><br />
Da das Gerät langsam in die Jahre kommt, sehe ich mich gerade nach einem möglichen Nachfolger um. Leider haben jedoch HTC und andere Hersteller kein Interesse mehr an der Veröffentlichung von Smartphones mit HW-Tastaturen &#8211; ohne eine solche Erweiterung möchte ich jedoch kein Handy bedienen. Derzeit gibt es Gerüchte, wonach Samsung eine Variante vom Galaxy S3 mit HW-Tastatur veröffentlichen möchte, allerdings wird da vermutlich der Bildschirm kleiner als beim &#8220;Original&#8221; ausfallen.</p>
<p>Mal sehen, was 2013 auf den Markt kommt!<br />
 <img src="http://www.xenuser.org/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1962" width="1" height="1" style="display: none;" /></p>


<p>Related posts:<ol><li><a href='http://www.xenuser.org/android/htc-desire-z-mit-android-2-2-froyo-erster-eindruck/' rel='bookmark' title='Permanent Link: HTC Desire Z mit Android 2.2 (Froyo): Erster Eindruck'>HTC Desire Z mit Android 2.2 (Froyo): Erster Eindruck</a></li>
<li><a href='http://www.xenuser.org/gaming/the-best-games-for-android-2-2-froyo-running-on-a-htc-desire-z/' rel='bookmark' title='Permanent Link: The best games for Android 2.2 (Froyo) running on a HTC Desire Z'>The best games for Android 2.2 (Froyo) running on a HTC Desire Z</a></li>
<li><a href='http://www.xenuser.org/xen/xen-ported-to-arm-architecture/' rel='bookmark' title='Permanent Link: Xen ported to ARM architecture'>Xen ported to ARM architecture</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.xenuser.org/android/htc-desire-z-aktualisiertes-review-nach-uber-2-jahren/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
