<?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>cmdln.org (a sysadmin blog)</title>
	<atom:link href="http://www.cmdln.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cmdln.org</link>
	<description>a system administrators mutterings</description>
	<lastBuildDate>Thu, 29 Mar 2012 17:03:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Review: Learning CFEngine 3</title>
		<link>http://www.cmdln.org/2012/03/29/review-learning-cfengine-3/</link>
		<comments>http://www.cmdln.org/2012/03/29/review-learning-cfengine-3/#comments</comments>
		<pubDate>Thu, 29 Mar 2012 15:04:25 +0000</pubDate>
		<dc:creator>Nick Anderson</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[book review]]></category>
		<category><![CDATA[CFEngine]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://www.cmdln.org/?p=994</guid>
		<description><![CDATA[I just finished reading the final release of Diego Zambonis’ Learning CFEngine 3. I can’t recommend this book enough. If your just learning CFEngine 3, if you are versed but not an expert and you like CFEngine you will like this book. If you meet all those criteria and you don’t like the book, I’ll [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cmdln.org/wp-content/uploads/2012/03/learning_cfengine_3_cover.png"><img class="alignleft size-medium wp-image-1010" title="learning_cfengine_3_cover" src="http://www.cmdln.org/wp-content/uploads/2012/03/learning_cfengine_3_cover-228x300.png" alt="" width="228" height="300" /></a>I just finished reading the <a href="http://shop.oreilly.com/product/0636920022022.do">final release</a> of <a href="http://zzamboni.org">Diego Zamboni</a>s’ <a href="http://cf-learn.info/">Learning CFEngine 3</a>. I can’t recommend this book enough. If your just learning CFEngine 3, if you are versed but not an expert and you like CFEngine you will like this book. If you meet all those criteria and you don’t like the book, I’ll buy you a beer if we ever meet. It’s well worth the 20 dollars, or 14 if you want the ebook (<a href="http://oreilly.com/store/ebooks.html">DRM FREE! Thanks OReilly!</a>). Or you can use the discount code AUTHD to get 40% off the print version, and 50% off the e-book version.</p>
<p>The introduction gives an overview of automation, why you would choose CFEngine over or to complement another tool and a brief history of CFEngine. CFEngine has a strong computer science background. It’s nice to know what ideas lead to different design decisions. The introduction gives this background and Diego does a great job of making it a very easy read.</p>
<p>Chapter 2 covers installing CFEngine, bootstraping with an initial configuration , and the obligatory “hello world”. If you have the electronic version of the book (I highly recommend it, but you should probably buy the dead tree version too so you can read the book during air-plane take-off and landing)<img class="alignright" src="http://getfile7.posterous.com/getfile/files.posterous.com/cf-learn/wAmoTFvnEDkpGEFIB8XDse9dOs6dtiZSBVes4J9oUsEQ5aoX19sot4cf8v7r/final_web.pdf_page_126_of_182-.jpg" alt="" width="452" height="476" /> this is where you will see an outstanding feature.</p>
<p>Coloured syntax highlighting as well as fine little bullet dots that make the very detailed description of the policy easy to reference.  This is a great feature, it makes the policy infinitely easier to read and digest. But just like a late night info-mercial, “Wait, that’s not all folks!”.</p>
<p>Blow up that picture and see near point 3 “In the <a href="http://cf-learn.info/ref/files">files</a>:”. Yes that is a hyper-link and it gives you quick access to a cross-referenced index of all the section heading in the <a href="https://cfengine.com/manuals/cf3-reference">CFEngine Reference Manual</a>. All CFEngine keywords in the electronic versions of the book are linked to this index to provide easy access to the official reference documentation about that concept. That is awesome, let me see you do that with the dewy decimal system! (No, I never did learn it. I recall telling my teachers in grade school that I would always have a computer to be able to look that stuff up. Hah, I remember the librarian scoffed and my teacher chuckled) But WAIT! There’s MORE! Yes. Really there is, I’m not kidding.</p>
<p>You can use Diegos’ index as a search provider in your browser. You can use <a href="http://searchplugins.net ">searchplugins.net </a>to create a search for it. Just enter <a href="http://cf-learn.info/ref/TEST">http://cf-learn.info/ref/TEST</a> in the Search URL box. Set the title to “CFEngine Reference Manual”, hit create plug-in and click the link to install the search plug-in. Once that’s done you can create a keyword to use in the address bar as well by clicking your search provider drop-down <a href="http://www.cmdln.org/wp-content/uploads/2012/03/shamwow.jpg"><img class="alignleft size-thumbnail wp-image-1009" title="shamwow" src="http://www.cmdln.org/wp-content/uploads/2012/03/shamwow-150x150.jpg" alt="" width="150" height="150" /></a>icon, going to “Manage Search Engines”, selecting the provider and finally “Edit Keyword”. Now you can use the search box in your browser or you can use your keyword in you address bar to quickly and efficiently search the CFEngine Reference Manual. Ok lets get out of chapter two already, I don’t want to completely turn into the shamwow guy.</p>
<p>Chapter 3 covers some more basics including desired-state configuration, promise theory, and convergent configuration which again I think are important to understand why CFEngine works the way it does. The components CFEngine is made of are explained in enough detail to understand the purpose of each, but not so much as to get fatiguing. A high level language structure overview and a section covering other sources of information are also included. I particularly like that early in the book a multitude of resources are laid out. If you get tired of reading the book you already know where to go to take a break and read about the same subject.</p>
<p>Chapter 4 gets down into actually using CFEngine to get things done. There are some good practical examples that are directly useful like configuring sshd configuration parameters and restarting sshd if its config gets changed as well as an example of how to do local user management. More importantly the examples shown in this chapter show techniques that can be used for many different applications. This chapter also covers the use of classes to specify policy that applies to nodes with specific characteristics or conditions. I should mention here that the book mentions that classes will be renamed to contexts so as to not confuse people with the Object-Oriented Programming definition of class which is not the same as CFEngines use of the term. I was able to get this confirmed by <a href="http://cfengine.com/markburgess/">Mark Burgess</a> (original author, founder, and Chief Thinking Officer) of CFEngine. I personally am still warming up to this upcoming change, I understand the desire to change it to better communicate the meaning to people who may be more familiar with the OOP use of class and that does fall in line with a core principal of knowledge management but I am still a little sad inside. I always thought the OOP use of the word class was awkward. Anyway, moving on.</p>
<p>Chapter 5 really starts showing more patterns of how to use the declarative policy language to describe intentions and help you “think like CFEngine”. It’s a very good build on Chapter 4 expanding the ideas and getting a little more generic to help you apply the language in different situations. There is a good explanation of Hierarchical Copying much better than others I have read. Also there is pretty good coverage of using arrays for passing configuration to bundles and a very good explanation of how to set default values for bundle parameters. I think this is very important for writing re-usable policy so be sure to read that section twice.</p>
<p>There are two places I think this chapter is slightly lacking. The coverage of arrays doesn’t cover using multi-dimensional arrays and how there are different techniques for dealing with them. I find myself using multi-dimensional arrays frequently when I want to do a similar thing multiple times like define multiple nagios checks and make a single usebundle call. Also I found the section on controlling promise execution order to be a little short. It’s true if you think order matters, you should step back and think if the order really matters or not, and then if you still think order matters, think about it some more. But there are times when order does matter, I tend to find this with variable definitions. I commonly will need to get variables set on the second pass after a class has been defined, and then set another class once that variable has been defined so that I know I can finally run a command. A few practical examples in this section would have been appreciated.</p>
<p>Chapter 6 is about advanced topics. It covers running CFEngine in multiple environments, and unit testing bundles. These are both great and I think there is room for a book to expand on chapters 5 and 6 just about policy writing techniques. Who wants to write that one?</p>
<p>Finally there is an appendix that covers Emacs configuration for editing CFEngine policy files. Well, I don’t have much to say about this section, I am a vim user. I am trying out orgmode but my vim habits are deeply ingrained. If you haven’t used Emacs before and you want to take your brain for a spin go check out <a href="http://doc.norang.ca/org-mode.html">Organize Your Life In Plain Text!</a> by Bernt Hansen. He has a pretty amazing orgmode configuration, I barely understand how to use it, let alone much of the configuration. I would have appreciated an appendix B for vim. <a href="http://watson-wilson.ca/">Neil Watson</a> has a <a href="http://www.vim.org/scripts/script.php?script_id=2904">CFEngine 3 syntax highlighting plug-in for vim</a> that I use.</p>
<p>Well, that’s it. So basically I had 3 wants after reading this book, and all centred around more information. I say that’s pretty good. After all you cant please everyone, and I have been known to be highly critical. It really is one of the best technical books I have read in a while. I didn’t find it a dry read at all.</p>
<p>I hope you didn’t make it this far in my diatribe, hopefully you bailed out early on went and bought book and are reading it instead of this. If not, you should head on over to the <a href="http://shop.oreilly.com/product/0636920022022.do">O’Reilly store and buy a copy</a>. Don’t forget to use the discount code above to save a few bucks.</p>
<p>©2012 <a href="http://www.cmdln.org">cmdln.org (a sysadmin blog)</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.cmdln.org/2012/03/29/review-learning-cfengine-3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Bibble The Best Photo Editing Software For Linux Bought By Corel</title>
		<link>http://www.cmdln.org/2012/03/28/bibble-the-best-photo-editing-software-for-linux-bought-by-corel/</link>
		<comments>http://www.cmdln.org/2012/03/28/bibble-the-best-photo-editing-software-for-linux-bought-by-corel/#comments</comments>
		<pubDate>Thu, 29 Mar 2012 04:50:54 +0000</pubDate>
		<dc:creator>Nick Anderson</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[#photograpy]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.cmdln.org/?p=988</guid>
		<description><![CDATA[I have been using bibble for about a year now. Its the best photo editing software that ran on linux that I could find. It probably isn’t as polished as Photoshop but it has its own great features like threading so it can use all of your cores for rendering. Just over a week ago [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cmdln.org/wp-content/uploads/2012/03/aftershot_01.jpg"><img class="alignleft  wp-image-1017" title="aftershot_01" src="http://www.cmdln.org/wp-content/uploads/2012/03/aftershot_01.jpg" alt="" width="540" height="112" /></a>I have been using <a href="http://bibblelabs.com/">bibble</a> for about a year now. Its the best photo editing software that ran on linux that I could find. It probably isn’t as polished as Photoshop but it has its own great features like threading so it can use all of your cores for rendering.</p>
<p>Just over a week ago I noticed it had been bought by Corel and its been re-branded to <a href="http://www.corel.com/corel/product/index.jsp?pid=prod4670071&amp;cid=catalog20038&amp;segid=6000006">AfterShotPro</a>. I really hope they continue to develop it and provide Linux support.</p>
<p>©2012 <a href="http://www.cmdln.org">cmdln.org (a sysadmin blog)</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.cmdln.org/2012/03/28/bibble-the-best-photo-editing-software-for-linux-bought-by-corel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setup encfs on dropbox for boxcryptor with CFEngine</title>
		<link>http://www.cmdln.org/2012/02/27/setup-encfs-on-dropbox-for-boxcryptor-with-cfengine/</link>
		<comments>http://www.cmdln.org/2012/02/27/setup-encfs-on-dropbox-for-boxcryptor-with-cfengine/#comments</comments>
		<pubDate>Mon, 27 Feb 2012 20:19:39 +0000</pubDate>
		<dc:creator>Nick Anderson</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[boxcryptor]]></category>
		<category><![CDATA[CFEngine]]></category>
		<category><![CDATA[dropbox]]></category>
		<category><![CDATA[encfs]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.cmdln.org/?p=977</guid>
		<description><![CDATA[Here is an easy way to configure encfs with dropbox that is compatible with boxcryptor. Boxcryptor makes Windows, Mac Android, and IOS applications to assist you in accessing data that you have stored in encfs. They do require that you create your encfs with some specific options: Cipher algorithm: AES, Plaintext or Stream encrypted filenames, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cmdln.org/wp-content/uploads/2012/02/Selection_001.png"><img class="alignleft size-thumbnail wp-image-982" title="Selection_001" src="http://www.cmdln.org/wp-content/uploads/2012/02/Selection_001-150x150.png" alt="" width="150" height="150" /></a>Here is an easy way to configure <a href="http://www.arg0.net/encfs" target="_blank">encfs</a> with <a href="http://db.tt/REX1m3Zv" target="_blank">dropbox</a> that is compatible with boxcryptor. <a href="http://www.boxcryptor.com/" target="_blank">Boxcryptor</a> makes <a href="http://www.boxcryptor.com/download/#platform_win_dl">Windows</a>, <a href="http://blog.boxcryptor.com/encfs-174-installer-for-mac-os-x-available">Mac</a> <a href="https://market.android.com/details?id=com.boxcryptor.android">Android</a>, and <a href="http://itunes.apple.com/us/app/boxcryptor/id484546808">IOS</a> applications to assist you in accessing data that you have stored in encfs. They do require that you create your encfs with some <a href="https://boxcryptorsupport.uservoice.com/knowledgebase/articles/35105-can-boxcryptor-mount-encrypted-volumes-created-wit" target="_blank">specific options</a>: Cipher algorithm: AES, Plaintext or Stream encrypted filenames, No filename initialization vector chaining, No per-file initialization vectors, No external IV chaining, No block MAC headers, No per-block random bytes.</p>
<p>I thought it would be fun to write a <a href="http://cfengine.com/" target="_blank">CFEngine</a> policy to set it up so here it is. Just install CFEngine 3, configure your settings in the policy file and kick it off with cf-agent –KIf ~/.cfagent/inputs/boxcryptor_dropbox_encfs. (You will need the standard library, and the policy is classed for ubuntu, but it should be easy enough to add support for another distro).</p>
<div class="gistem"><div id="gist-1926615" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'>body common control {</div><div class='line' id='LC2'><br/></div><div class='line' id='LC3'>&nbsp;&nbsp;&nbsp;&nbsp;bundlesequence  =&gt; {</div><div class='line' id='LC4'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;main&quot;,</div><div class='line' id='LC5'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};</div><div class='line' id='LC6'><br/></div><div class='line' id='LC7'>&nbsp;&nbsp;&nbsp;&nbsp;inputs          =&gt; {</div><div class='line' id='LC8'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;cfengine_stdlib.cf&quot;,</div><div class='line' id='LC9'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};</div><div class='line' id='LC10'>}</div><div class='line' id='LC11'><br/></div><div class='line' id='LC12'>bundle agent main {</div><div class='line' id='LC13'># Setup encfs on one of your dropbox folders for use with boxcryptor</div><div class='line' id='LC14'>&nbsp;&nbsp;&nbsp;&nbsp;vars:</div><div class='line' id='LC15'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;settings[user]&quot;      string =&gt; &quot;user&quot;;</div><div class='line' id='LC16'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;settings[group]&quot;     string =&gt; &quot;group&quot;;</div><div class='line' id='LC17'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;settings[encfs]&quot;     string =&gt; &quot;/home/user/Dropbox/encfs&quot;;</div><div class='line' id='LC18'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;settings[mount]&quot;     string =&gt; &quot;/home/user/Documents/Safe&quot;;</div><div class='line' id='LC19'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;settings[password]&quot;  string =&gt; &quot;supersecret&quot;;</div><div class='line' id='LC20'><br/></div><div class='line' id='LC21'>&nbsp;&nbsp;&nbsp;&nbsp;methods:</div><div class='line' id='LC22'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;required_software&quot; </div><div class='line' id='LC23'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;usebundle   =&gt; install_boxcryptor,</div><div class='line' id='LC24'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;action      =&gt; if_elapsed(&quot;360&quot;),</div><div class='line' id='LC25'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comment     =&gt; &quot;Install software to work with boxcryptor, but only</div><div class='line' id='LC26'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;verify and try once every 6 hours&quot;;</div><div class='line' id='LC27'><br/></div><div class='line' id='LC28'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;encfs&quot; </div><div class='line' id='LC29'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;usebundle =&gt; encfs_init_boxcryptor(&quot;main.settings&quot;),</div><div class='line' id='LC30'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comment   =&gt; &quot;If no encfs is found, initalize one compatible with boxcryptor&quot;;</div><div class='line' id='LC31'><br/></div><div class='line' id='LC32'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;encfs&quot; </div><div class='line' id='LC33'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;usebundle =&gt; encfs_mounted(&quot;main.settings&quot;),</div><div class='line' id='LC34'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comment =&gt; &quot;Ensure the encfs is mounted somewhere we can write to it&quot;;</div><div class='line' id='LC35'>}</div><div class='line' id='LC36'><br/></div><div class='line' id='LC37'>bundle agent install_boxcryptor{</div><div class='line' id='LC38'># This is just a meta to make sure the deps for boxcryptor are all installed</div><div class='line' id='LC39'><br/></div><div class='line' id='LC40'>&nbsp;&nbsp;&nbsp;&nbsp;packages:</div><div class='line' id='LC41'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ubuntu::</div><div class='line' id='LC42'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;python-pexpect&quot;</div><div class='line' id='LC43'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;package_policy  =&gt; &quot;add&quot;,</div><div class='line' id='LC44'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;package_method  =&gt; apt,</div><div class='line' id='LC45'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comment         =&gt; &quot;python-expect is needed for the custom </div><div class='line' id='LC46'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scripts to initalize and mount encfs&quot;;</div><div class='line' id='LC47'><br/></div><div class='line' id='LC48'>&nbsp;&nbsp;&nbsp;&nbsp;methods:</div><div class='line' id='LC49'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# would be nice to find a dropbox fuse implimentation that works so we</div><div class='line' id='LC50'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# dont have to rely on the nautilus dropbox plugin and thus be able to </div><div class='line' id='LC51'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# this on a headless machine</div><div class='line' id='LC52'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&quot;dropbox&quot;    usebundle =&gt; install_dropfuse;</div><div class='line' id='LC53'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;dropbox&quot; </div><div class='line' id='LC54'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;usebundle =&gt; install_dropbox;</div><div class='line' id='LC55'><br/></div><div class='line' id='LC56'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;encryption&quot; </div><div class='line' id='LC57'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;usebundle =&gt; install_encfs;</div><div class='line' id='LC58'>}</div><div class='line' id='LC59'><br/></div><div class='line' id='LC60'>bundle agent encfs_init_boxcryptor(config){</div><div class='line' id='LC61'><br/></div><div class='line' id='LC62'>&nbsp;vars:</div><div class='line' id='LC63'>&nbsp;&nbsp;&nbsp;&nbsp;&quot;temp_script&quot;</div><div class='line' id='LC64'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;string =&gt; &quot;/tmp/init_boxcryptor_encfs.py&quot;;</div><div class='line' id='LC65'><br/></div><div class='line' id='LC66'>&nbsp;&nbsp;&nbsp;&nbsp;&quot;init_boxcryptor_encfs_template&quot; </div><div class='line' id='LC67'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comment =&gt; &quot;boxcryptor only supports a subset of encfs options, </div><div class='line' id='LC68'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this script initalizes an encfs filesystem with those </div><div class='line' id='LC69'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;options. Its an interactive process so we needed expect.&quot;,</div><div class='line' id='LC70'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;string =&gt; &quot;#!/usr/bin/env python</div><div class='line' id='LC71'># encoding: utf-8</div><div class='line' id='LC72'><br/></div><div class='line' id='LC73'>import pexpect</div><div class='line' id='LC74'>import sys</div><div class='line' id='LC75'><br/></div><div class='line' id='LC76'>child = pexpect.spawn(&#39;encfs $($(config)[encfs]) $($(config)[mount])&#39;)</div><div class='line' id='LC77'>child.logfile = sys.stdout</div><div class='line' id='LC78'>child.expect(&#39;&gt;&#39;)</div><div class='line' id='LC79'>child.sendline(&#39;x&#39;)</div><div class='line' id='LC80'>child.expect(&#39;The following cipher algorithms are available&#39;)</div><div class='line' id='LC81'>child.sendline(&#39;1&#39;)</div><div class='line' id='LC82'>child.expect(&#39;Selected key size&#39;)</div><div class='line' id='LC83'>child.sendline(&#39;256&#39;)</div><div class='line' id='LC84'>child.expect(&#39;filesystem block size&#39;)</div><div class='line' id='LC85'>child.sendline(&#39;1024&#39;)</div><div class='line' id='LC86'>child.expect(&#39;The following filename encoding algorithms are available&#39;)</div><div class='line' id='LC87'>child.sendline(&#39;3&#39;)</div><div class='line' id='LC88'>child.expect(&#39;Enable filename initialization vector chaining&#39;)</div><div class='line' id='LC89'>child.sendline(&#39;n&#39;)</div><div class='line' id='LC90'>child.expect(&#39;Enable per-file initialization vectors&#39;)</div><div class='line' id='LC91'>child.sendline(&#39;n&#39;)</div><div class='line' id='LC92'>child.expect(&#39;Enable block authentication code headers&#39;)</div><div class='line' id='LC93'>child.sendline(&#39;n&#39;)</div><div class='line' id='LC94'>child.expect(&#39;Add random bytes to each block header&#39;)</div><div class='line' id='LC95'>child.sendline(&#39;0&#39;)</div><div class='line' id='LC96'>child.expect(&#39;Enable file-hole pass-through&#39;)</div><div class='line' id='LC97'>child.sendline(&#39;y&#39;)</div><div class='line' id='LC98'>child.expect(&#39;New Encfs Password&#39;)</div><div class='line' id='LC99'>child.sendline(&#39;$($(config)[password])&#39;)</div><div class='line' id='LC100'>child.expect(&#39;Verify Encfs Password&#39;)</div><div class='line' id='LC101'>child.sendline(&#39;$($(config)[password])&#39;)</div><div class='line' id='LC102'>child.expect(pexpect.EOF, timeout=None)</div><div class='line' id='LC103'>child.close()</div><div class='line' id='LC104'>sys.exit(child.exitstatus)&quot;;</div><div class='line' id='LC105'><br/></div><div class='line' id='LC106'>&nbsp;&nbsp;&nbsp;&nbsp;classes:</div><div class='line' id='LC107'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;encfs_exists&quot; </div><div class='line' id='LC108'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;expression  =&gt; fileexists(&quot;$($(config)[encfs])/.encfs6.xml&quot;),</div><div class='line' id='LC109'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comment     =&gt; &quot;Determine if there is an existing encfs&quot;;</div><div class='line' id='LC110'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;mount_exists&quot;  </div><div class='line' id='LC111'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;expression  =&gt; isdir(&quot;$($(config)[mount])&quot;),</div><div class='line' id='LC112'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comment     =&gt; &quot;Make sure there is a place to mount the encfs&quot;;</div><div class='line' id='LC113'>&nbsp;</div><div class='line' id='LC114'>&nbsp;files:</div><div class='line' id='LC115'>&nbsp;&nbsp;&nbsp;!encfs_exists::</div><div class='line' id='LC116'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;$($(config)[mount])/.&quot;</div><div class='line' id='LC117'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;create =&gt; &quot;true&quot;,</div><div class='line' id='LC118'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;perms =&gt; mog(&quot;700&quot;, &quot;$($(config)[user])&quot;, &quot;$($(config)[group])&quot;),</div><div class='line' id='LC119'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comment =&gt; &quot;Make sure that there is a place to mount the encfs&quot;;</div><div class='line' id='LC120'><br/></div><div class='line' id='LC121'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;$(temp_script)&quot;</div><div class='line' id='LC122'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;create =&gt; &quot;true&quot;,</div><div class='line' id='LC123'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;perms =&gt; mog(&quot;700&quot;, &quot;$($(config)[user])&quot;, &quot;$($(config)[group])&quot;),</div><div class='line' id='LC124'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;edit_line =&gt; append_if_no_line(&quot;$(init_boxcryptor_encfs_template)&quot;),</div><div class='line' id='LC125'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;edit_defaults =&gt; empty,</div><div class='line' id='LC126'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;classes =&gt; if_repaired(&quot;script_installed&quot;),</div><div class='line' id='LC127'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comment =&gt; &quot;If no encfs filesystem is found place the initalization script</div><div class='line' id='LC128'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;so we can execute it.&quot;;</div><div class='line' id='LC129'><br/></div><div class='line' id='LC130'>&nbsp;&nbsp;&nbsp;&nbsp;encfs_exists::</div><div class='line' id='LC131'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;$(temp_script)&quot;</div><div class='line' id='LC132'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;delete =&gt; tidy,</div><div class='line' id='LC133'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;classes =&gt; if_repaired(&quot;performed_cleanup&quot;),</div><div class='line' id='LC134'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comment =&gt; &quot;Delete the temporary initalization script if an encfs already exists&quot;;</div><div class='line' id='LC135'><br/></div><div class='line' id='LC136'>&nbsp;&nbsp;&nbsp;&nbsp;commands:</div><div class='line' id='LC137'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;!(encfs_exists|initalized_boxcryptor_encfs)::</div><div class='line' id='LC138'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;$(temp_script)&quot;,</div><div class='line' id='LC139'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;contain =&gt; setuidgid_silent(&quot;$($(config)[user])&quot;, &quot;$($(config)[group])&quot;),</div><div class='line' id='LC140'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;classes =&gt; &quot;initalized_boxcryptor_encfs&quot;,</div><div class='line' id='LC141'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comment =&gt; &quot;If no encfs is detected and we havent yet successfully initalized</div><div class='line' id='LC142'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;one fire the expect script to do so.&quot;;</div><div class='line' id='LC143'><br/></div><div class='line' id='LC144'>&nbsp;&nbsp;&nbsp;&nbsp;reports:</div><div class='line' id='LC145'><br/></div><div class='line' id='LC146'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;script_installed::</div><div class='line' id='LC147'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;boxcryptor_initalize: I installed a script to do my work&quot;;</div><div class='line' id='LC148'><br/></div><div class='line' id='LC149'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;initalized_boxcryptor_encfs::</div><div class='line' id='LC150'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;boxcryptor_initalize: I couldn&#39;t find an existing encfs at $($(config)[encfs]) so I initalized one&quot;;</div><div class='line' id='LC151'><br/></div><div class='line' id='LC152'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;performed_cleanup::</div><div class='line' id='LC153'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;boxcryptor_initalize: I cleaned up after myself&quot;;</div><div class='line' id='LC154'><br/></div><div class='line' id='LC155'><br/></div><div class='line' id='LC156'>}</div><div class='line' id='LC157'><br/></div><div class='line' id='LC158'>bundle agent encfs_mounted(config){</div><div class='line' id='LC159'>&nbsp;&nbsp;&nbsp;&nbsp;vars:</div><div class='line' id='LC160'>&nbsp;&nbsp;&nbsp;&nbsp;&quot;temp_script&quot;</div><div class='line' id='LC161'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comment =&gt; &quot;Mounting an encfs filesystem requires a password, this script uses expect so we can supply one interactively&quot;,</div><div class='line' id='LC162'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;string =&gt; &quot;/tmp/mount_encfs.py&quot;;</div><div class='line' id='LC163'><br/></div><div class='line' id='LC164'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;mount_encfs_tpl&quot; string =&gt; &quot;#!/usr/bin/env python</div><div class='line' id='LC165'># encoding: utf-8</div><div class='line' id='LC166'><br/></div><div class='line' id='LC167'>import pexpect</div><div class='line' id='LC168'>import sys</div><div class='line' id='LC169'><br/></div><div class='line' id='LC170'>child = pexpect.spawn(&#39;/usr/bin/encfs $($(config)[encfs]) $($(config)[mount])&#39;)</div><div class='line' id='LC171'><br/></div><div class='line' id='LC172'>child.logfile = sys.stdout</div><div class='line' id='LC173'>child.expect(&#39;EncFS Password&#39;)</div><div class='line' id='LC174'>child.sendline(&#39;$($(config)[password])&#39;)</div><div class='line' id='LC175'>child.expect(pexpect.EOF, timeout=None)</div><div class='line' id='LC176'>child.close()</div><div class='line' id='LC177'>sys.exit(child.exitstatus)&quot;;</div><div class='line' id='LC178'><br/></div><div class='line' id='LC179'>&nbsp;&nbsp;&nbsp;&nbsp;classes:</div><div class='line' id='LC180'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;encfs_mounted&quot; </div><div class='line' id='LC181'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;expression  =&gt; returnszero(&quot;/bin/grep --silent -P ^encfs\s$($(config)[mount]) /etc/mtab&quot;, &quot;noshell&quot;),</div><div class='line' id='LC182'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comment     =&gt; &quot;Determine if the encfs filesystem is currently mounted or not&quot;; </div><div class='line' id='LC183'><br/></div><div class='line' id='LC184'>&nbsp;&nbsp;&nbsp;&nbsp;files:</div><div class='line' id='LC185'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;!encfs_mounted::</div><div class='line' id='LC186'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;$(temp_script)&quot;</div><div class='line' id='LC187'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;create          =&gt; &quot;true&quot;,</div><div class='line' id='LC188'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;perms           =&gt; mog(&quot;700&quot;, &quot;$($(config)[user])&quot;, &quot;$($(config)[group])&quot;),</div><div class='line' id='LC189'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;edit_line       =&gt; append_if_no_line(&quot;$(mount_encfs_tpl)&quot;),</div><div class='line' id='LC190'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;edit_defaults   =&gt; empty,</div><div class='line' id='LC191'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;classes         =&gt; if_repaired(&quot;placed_script&quot;),</div><div class='line' id='LC192'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comment         =&gt; &quot;If we dont detect that our desired encfs filesystem is mounted</div><div class='line' id='LC193'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;drop the expect script in place. We use the expect script</div><div class='line' id='LC194'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;because we need to provide a password&quot;;</div><div class='line' id='LC195'><br/></div><div class='line' id='LC196'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;encfs_mounted::</div><div class='line' id='LC197'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;$(temp_script)&quot;</div><div class='line' id='LC198'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;delete  =&gt; tidy,</div><div class='line' id='LC199'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;classes =&gt; if_repaired(&quot;performed_cleanup&quot;),</div><div class='line' id='LC200'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comment =&gt; &quot;If the encfs filesystem is mounted we have no need for the mount script to be in place, delete it&quot;;</div><div class='line' id='LC201'><br/></div><div class='line' id='LC202'>&nbsp;&nbsp;&nbsp;&nbsp;commands:</div><div class='line' id='LC203'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;!encfs_mounted::</div><div class='line' id='LC204'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;$(temp_script)&quot;,</div><div class='line' id='LC205'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;contain =&gt; setuidgid_silent(&quot;$($(config)[user])&quot;, &quot;$($(config)[group])&quot;),</div><div class='line' id='LC206'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;classes =&gt; if_else(&quot;repaired_mount&quot;, &quot;failed_repair_mount&quot;),</div><div class='line' id='LC207'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comment =&gt; &quot;If the enfcs filesystem is not mounted execute our mount script&quot;;</div><div class='line' id='LC208'><br/></div><div class='line' id='LC209'>&nbsp;&nbsp;&nbsp;&nbsp;reports:</div><div class='line' id='LC210'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;placed_script::</div><div class='line' id='LC211'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;boxcryptor_mounted: I installed a script&quot;;</div><div class='line' id='LC212'><br/></div><div class='line' id='LC213'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;repaired_mount::</div><div class='line' id='LC214'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;boxcryptor_mounted: $($(config)[encfs]) was not mounted on $($(config)[mount]), but we fixed it&quot;;</div><div class='line' id='LC215'><br/></div><div class='line' id='LC216'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;performed_cleanup::</div><div class='line' id='LC217'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;boxcryptor_mounted: I cleaned up aftermyself&quot;;</div><div class='line' id='LC218'><br/></div><div class='line' id='LC219'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;!encfs_mounted.failed_repair_mount::</div><div class='line' id='LC220'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;boxcryptor_mounted: I dunno what happened, but I couldnt mount the encfs volume check your settings!&quot;;</div><div class='line' id='LC221'><br/></div><div class='line' id='LC222'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;!repaired_mount.encfs_mounted::</div><div class='line' id='LC223'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;boxcryptor_mounted: Everything was as expected&quot;;</div><div class='line' id='LC224'>&nbsp;</div><div class='line' id='LC225'>}</div><div class='line' id='LC226'><br/></div><div class='line' id='LC227'><br/></div><div class='line' id='LC228'><br/></div><div class='line' id='LC229'><br/></div><div class='line' id='LC230'>bundle agent install_dropbox{</div><div class='line' id='LC231'>&nbsp;&nbsp;&nbsp;&nbsp;vars:</div><div class='line' id='LC232'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ubuntu::</div><div class='line' id='LC233'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;packages&quot;  slist =&gt; { &quot;nautilus-dropbox&quot; };</div><div class='line' id='LC234'><br/></div><div class='line' id='LC235'>&nbsp;&nbsp;&nbsp;&nbsp;packages:</div><div class='line' id='LC236'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ubuntu::</div><div class='line' id='LC237'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;$(packages)&quot;</div><div class='line' id='LC238'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;package_policy  =&gt; &quot;add&quot;,</div><div class='line' id='LC239'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;package_method  =&gt; apt,</div><div class='line' id='LC240'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comment         =&gt; &quot;Install dropbox packages with apt&quot;;</div><div class='line' id='LC241'><br/></div><div class='line' id='LC242'>}</div><div class='line' id='LC243'><br/></div><div class='line' id='LC244'>bundle agent install_encfs {</div><div class='line' id='LC245'># Install encfs</div><div class='line' id='LC246'>&nbsp;&nbsp;&nbsp;&nbsp;vars:</div><div class='line' id='LC247'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ubuntu::</div><div class='line' id='LC248'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;packages&quot; slist =&gt; { &quot;encfs&quot;, &quot;fuse-utils&quot; };</div><div class='line' id='LC249'>&nbsp;</div><div class='line' id='LC250'>&nbsp;&nbsp;&nbsp;&nbsp;packages:</div><div class='line' id='LC251'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ubuntu::</div><div class='line' id='LC252'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;$(packages)&quot;</div><div class='line' id='LC253'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;package_policy  =&gt; &quot;add&quot;,</div><div class='line' id='LC254'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;package_method  =&gt; apt,</div><div class='line' id='LC255'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comment         =&gt; &quot;Install encfs with apt&quot;;</div><div class='line' id='LC256'>&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC257'>}</div><div class='line' id='LC258'><br/></div><div class='line' id='LC259'>###########################################################################</div><div class='line' id='LC260'>#                               body parts                                #</div><div class='line' id='LC261'>###########################################################################</div><div class='line' id='LC262'><br/></div><div class='line' id='LC263'>body contain setuidgid_silent(x,y){</div><div class='line' id='LC264'>&nbsp;&nbsp;&nbsp;&nbsp;exec_owner =&gt; &quot;$(x)&quot;;</div><div class='line' id='LC265'>&nbsp;&nbsp;&nbsp;&nbsp;exec_group =&gt; &quot;$(y)&quot;;</div><div class='line' id='LC266'>&nbsp;&nbsp;&nbsp;&nbsp;no_output =&gt; &quot;true&quot;;</div><div class='line' id='LC267'>}</div><div class='line' id='LC268'><br/></div><div class='line' id='LC269'><br/></div><div class='line' id='LC270'><br/></div><div class='line' id='LC271'>###########################################################################</div><div class='line' id='LC272'>#                            Not really useful                            #</div><div class='line' id='LC273'>###########################################################################</div><div class='line' id='LC274'># I couldnt get dropfuse to work, nor did I try very hard</div><div class='line' id='LC275'>bundle agent install_dropfuse{</div><div class='line' id='LC276'>&nbsp;&nbsp;&nbsp;&nbsp;vars:</div><div class='line' id='LC277'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;dropfuse_src&quot; </div><div class='line' id='LC278'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;string =&gt; &quot;https://raw.github.com/arekzb/dropfuse/master/dropfuse.py&quot;,</div><div class='line' id='LC279'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comment =&gt; &quot;Location to get dropfuse binary from since its not packaged&quot;;</div><div class='line' id='LC280'><br/></div><div class='line' id='LC281'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;dropfuse_bin&quot;</div><div class='line' id='LC282'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;string  =&gt; &quot;/usr/local/bin/dropfuse.py&quot;,</div><div class='line' id='LC283'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comment =&gt; &quot;Location to install the dropfuse library&quot;;</div><div class='line' id='LC284'>&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC285'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ubuntu::</div><div class='line' id='LC286'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# TODO: find out if fuse-utils is really required for this</div><div class='line' id='LC287'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;packages&quot; </div><div class='line' id='LC288'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;slist   =&gt; { &quot;fuse-utils&quot;, &quot;python-fuse&quot; },</div><div class='line' id='LC289'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comment =&gt; &quot;Packages required&quot;;</div><div class='line' id='LC290'><br/></div><div class='line' id='LC291'>&nbsp;&nbsp;&nbsp;&nbsp;files:</div><div class='line' id='LC292'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;$(dropfuse_bin)&quot;</div><div class='line' id='LC293'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;perms       =&gt; mog(&quot;755&quot;, &quot;root&quot;, &quot;root&quot;),</div><div class='line' id='LC294'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ifvarclass  =&gt; &quot;dropfuse_installed&quot;,</div><div class='line' id='LC295'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comment     =&gt; &quot;If dropfuse is installed ensure that </div><div class='line' id='LC296'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;it is executable&quot;;</div><div class='line' id='LC297'>&nbsp;&nbsp;&nbsp;&nbsp;packages:</div><div class='line' id='LC298'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ubuntu::</div><div class='line' id='LC299'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;$(packages)&quot;</div><div class='line' id='LC300'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;package_policy =&gt; &quot;add&quot;,</div><div class='line' id='LC301'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;package_method =&gt; apt, </div><div class='line' id='LC302'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comment        =&gt; &quot;Install the selected package with apt if</div><div class='line' id='LC303'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;its not installed&quot;;</div><div class='line' id='LC304'>&nbsp;&nbsp;&nbsp;&nbsp;classes:</div><div class='line' id='LC305'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;dropfuse_installed&quot; </div><div class='line' id='LC306'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;expression  =&gt; fileexists(&quot;$(dropfuse_bin)&quot;),</div><div class='line' id='LC307'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comment     =&gt; &quot;Determine if the dropfuse binary is installed&quot;;</div><div class='line' id='LC308'><br/></div><div class='line' id='LC309'>&nbsp;&nbsp;&nbsp;&nbsp;commands:</div><div class='line' id='LC310'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;!dropfuse_installed::</div><div class='line' id='LC311'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;/usr/bin/wget $(dropfuse_src) -O $(dropfuse_bin)&quot;,</div><div class='line' id='LC312'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comment =&gt; &quot;Install the dropfuse binary, its not currently </div><div class='line' id='LC313'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;packaged so just get it from the authors github account&quot;;</div><div class='line' id='LC314'><br/></div><div class='line' id='LC315'>}</div><div class='line' id='LC316'><br/></div><div class='line' id='LC317'><br/></div><div class='line' id='LC318'><br/></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/1926615/944c7cce07e27a0ea69a5af92d04d92b9a038024/boxcryptor_dropbox_encfs.cf" style="float:right;">view raw</a>
            <a href="https://gist.github.com/1926615#file_boxcryptor_dropbox_encfs.cf" style="float:right;margin-right:10px;color:#666">boxcryptor_dropbox_encfs.cf</a>
            <a href="https://gist.github.com/1926615">This Gist</a> is brought to you using <a href="http://en.bainternet.info/2011/simple-gist-embed"><small>Simple Gist Embed</small></a>.
          </div>
        </div>
</div>
</div><style type="text/css">@import "http://gist.github.com/stylesheets/gist/embed.css"; .gistem .highlight {background: inherit; !important;}</style>
<p> </p>
<p>edit: February 27, 2012 at 2:52 pm</p>
<p>Thanks @highdraw for pointing out the mac installer.</p>
<p>©2012 <a href="http://www.cmdln.org">cmdln.org (a sysadmin blog)</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.cmdln.org/2012/02/27/setup-encfs-on-dropbox-for-boxcryptor-with-cfengine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New bundle to manage routes for RedHat/CentOS with CFEngine 3</title>
		<link>http://www.cmdln.org/2012/02/18/new-bundle-to-manage-routes-for-redhatcentos-with-cfengine-3/</link>
		<comments>http://www.cmdln.org/2012/02/18/new-bundle-to-manage-routes-for-redhatcentos-with-cfengine-3/#comments</comments>
		<pubDate>Sun, 19 Feb 2012 04:55:27 +0000</pubDate>
		<dc:creator>Nick Anderson</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[CFEngine]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[redhat]]></category>
		<category><![CDATA[routing]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://www.cmdln.org/?p=951</guid>
		<description><![CDATA[I re-factored rh_add_interface_routes into a new bundle rh_update_routes, you can find them in my CFEngine library. The biggest improvement is you no longer have to specify the interface you want the route on. Instead you specify a regular expression of the ip that would be on that interface and the specific interface is found. Second [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" src="http://farm4.staticflickr.com/3435/3388655598_42e5832466_m.jpg" alt="" width="240" height="160" />I re-factored rh_add_interface_routes into a new bundle rh_update_routes, you can find them in <a href="https://github.com/nickanderson/nickanderson-cfengine-library/blob/master/lib_rh.cf">my CFEngine library</a>.</p>
<p>The biggest improvement is you no longer have to specify the interface you want the route on. Instead you specify a regular expression of the ip that would be on that interface and the specific interface is found.</p>
<p>Second major improvement is the direct use of ip route del/add to update currently running system instead of restarting all networking.</p>
<p>Also a small change in the declaration of the routes that is less repetitive and requires less typing.</p>
<p>Take care in crafting your ip regular expression especially if you are not using a standard A, B or C class network.</p>
<p>Now lets see how it could be used.</p>
<p>Consider that you have multiple interfaces on a host, one interface connects to a “management” network, another connects to an application network, and another connects to a database network. Your default route is for the application network because you need to talk to the rest of the world.</p>
<p>Now consider what other networks that your host might need to connect to for “management”. Maybe you have a network that your backup servers sit on, and maybe you have another network that is for vpn clients, and you want vpn clients to be able to ssh to this host on the management interface.</p>
<p>We don’t need to add any routes for the db network or for the application network but for these other two networks we have to add the routes on the host.</p>
<p>172.16.208.0/25 is the network your backup servers sit on. 192.168.5.0/24 is your vpn client access network. Your management network on the host we are considering is 192.168.35.0/24.</p>
<p>You could define a common bundle to define these variables.</p>
<pre class="brush: plain; title: ; notranslate">

bundle common site {

vars:
ipv4_192_168_35::
&quot;mgmt_ip_regex&quot;
string  =&gt; &quot;192\.168\.35\..*&quot;,
comment =&gt; &quot;Regex to match the ip that is on the management network, we use this
to figure out which is the management interface&quot;;

&quot;mgmt_routes[172.16.208.0/25]&quot;
string  =&gt; &quot;192.168.35.254&quot;,
comment =&gt; &quot;Needed to talk to the backup servers over the management network&quot;;

&quot;mgmt_routes[192.168.5.0/24]&quot;
string  =&gt; &quot;192.168.35.254&quot;,
comment =&gt; &quot;Needed to talk to vpn clients on the vpn client network&quot;;

}
</pre>
<p>This is how you would call the rh_update_routes bundle.</p>
<pre class="brush: plain; title: ; notranslate">

bundle agent main{

methods:
&quot;routing&quot;       usebundle   =&gt; rh_update_routes(&quot;$(site.mgmt_ip_regex)&quot;, &quot;site.mgmt_routes&quot;),
comment =&gt; &quot;Setup Management routes defined in bundle common site&quot;;

}
</pre>
<p>Lets walk through the decision tree a little bit. In bundle common site mgmt_ip_regex and mgmt_routes is only defined if the client matches the class ipv4_192_168_35. We wouldn’t want to define the same routes for a host on the 192.168.5.0 network because the gateway would be wrong, so that’s why you need to be careful to restrict your variable definition based on classes.</p>
<p>The mgmt_ip_regex is needed to dynamically determine which interface these routes will apply to. And really we only need the interface for this so that we can update the proper file for persistent routes (in redhat|centos its /etc/sysconfig/network-scripts/route-interfacename).</p>
<p>Lets look at rh_update_routes to see what’s going on.</p>
<pre class="brush: plain; title: ; notranslate">
bundle agent rh_update_routes(ipregex, routes) {
# Expects string, array
# Note: This bundle depricates rh_add_interface_routes. I see no good reason to continue using it.
#
# ipregex is a regular expression that matches the ip on the interface you want these routes added
#   hint: ipregex should match an ip that can communicate with the specified gateway
#         for example if your routing a network via 192.168.0.1 and the network is a /24 network
#         (255.255.255.0 netmask) then you should have an ip in the range 192.168.0.1-254 on the
#         host your trying to add this route on. So a regex of 192\.168\.0\.[0-9]++ would work.
# routes is an array keyed on the network you want to route to with the string value being the gateway to use.
#
# NOTE: Unfortunately the only way I could think of to automatically determine the interface a route
#       needs added for is to use regcmp to compare the ipregex to the array of addresses. It would be
#       better if there was some way to use the iprange function to determine which nic an ipaddress
#       is on, but that does not currently work, or I am thus far to dense to figure out how.
#       So right now I am stuck with using ugly ipaddress regular expressions which can be error prone
#       in construction especially when you start networks that dont fall into octet boundaries
#
#       This causes there to be a limitation of usage on this bundle, you MUST NOT MIX
#       routes that go on seperate interfaces in the same route configuration array. I believe
#       this limitation could be surpassed if we could use the iprange or similar function.
#
# vars:
#    &quot;ipregex_mgmt&quot; string =&gt; &quot;192\.168\.0\.[0-9]++&quot;;
#    &quot;management[CIDRNETWORK]&quot;
#        string =&gt; &quot;GATEWAY&quot;,
#        comment =&gt; &quot;What do you need this for&quot;;
#
#    &quot;management[10.119.156.0/26]&quot;
#        string =&gt; &quot;192.168.0.1&quot;,
#        comment =&gt; &quot;Needed for talking to the special network used for backup servers&quot;;
#
# methods:
#    &quot;any&quot; usebundle =&gt; rh_add_routes(&quot;192\.168\.0\.[0-9]++&quot;, &quot;context.management&quot;);
#
    vars:
        &quot;nics&quot;          slist =&gt; getindices(&quot;sys.ipv4&quot;);
        #&quot;route_file&quot;    string =&gt; &quot;/etc/sysconfig/network-scripts/route-$(interface)&quot;;
        &quot;route_index&quot; slist =&gt; getindices(&quot;$(routes)&quot;);

    classes:
        &quot;supported_os&quot; or =&gt; { &quot;centos_5&quot;, &quot;redhat_5&quot; };

        &quot;$(nics)_matches_ipregex&quot; expression    =&gt; regcmp(&quot;$(ipregex)&quot;, &quot;$(sys.ipv4[$(nics)])&quot;),
            comment =&gt; &quot;Determine which network interface has an ip that we are adding routes for.
                        We need to know this so that we can insert the route in the proper
                        file for reboot persistence.&quot;;

    files:
        (centos_5|redhat_5)::
            &quot;/etc/sysconfig/network-scripts/route-$(nics)&quot;
                create      =&gt; &quot;true&quot;,
                perms       =&gt; mog(&quot;644&quot;, &quot;root&quot;, &quot;root&quot;),
                edit_line   =&gt; replace_or_add(&quot;$(route_index).*&quot;, &quot;$(route_index) via $($(this.routes)[$(route_index)])&quot;),
                classes     =&gt; if_repaired(&quot;persistent_route_updated_for_$(route_index)&quot;),
                ifvarclass  =&gt; &quot;$(nics)_matches_ipregex&quot;,
                comment     =&gt; &quot;Replace any conflicting routes and ensure persistent across reboots&quot;;

    commands:
        # We only attempt to delete a route if we have modified the persistent route file
        &quot;/sbin/ip route del $(route_index)&quot;
            ifvarclass  =&gt; canonify(&quot;persistent_route_updated_for_$(route_index)&quot;),
            classes     =&gt; &quot;attempted_route_removal_for_$(route_index)&quot;,
            comment     =&gt; &quot;Delete any possibly conflicting old route before adding the new one&quot;;

        # We only attempt to add a route if we have modified the persistent route file
        &quot;/sbin/ip route add $(route_index) via $($(routes)[$(route_index)])&quot;
            ifvarclass  =&gt; canonify(&quot;persistent_route_updated_for_$(route_index)&quot;),
            classes     =&gt; &quot;attempted_route_addition_for_$(route_index)&quot;,
            comment     =&gt; &quot;Add the new route&quot;;

    reports:
        cfengine::
            &quot;Persistent route updated for $(route_index) via $($(routes)[$(route_index)]) on dev $(nics)&quot;
                ifvarclass =&gt; canonify(&quot;persistent_route_updated_for_$(route_index)&quot;);

        !supported_os::
            &quot;Sorry I don't know how to work with this OS&quot;;

}
</pre>
<p>First we get a list of the interfaces on the system using getindices on sys.ipv4. Then we get a list of networks to route for from the configuration array that we passed into the bundle. Next we use the ipregex that we passed into the bundle and we iterate over the network interfaces looking for a match. When a match is found it defines the class $(nics)_matches_ipregex where nics expands to the current iterated nic from the list we built earlier. Thanks to Diego for this pattern.<a href="http://cf-learn.info/code/ch04/edit_inittab_tso.cf.html"> I found it</a> in <a href="http://cf-learn.info/">his upcoming book Learning CFEngine 3</a>, if you haven’t you should go get a copy. The pre-release is available now, and even in its early stage I recommend it.</p>
<p>Now we get to some actual action. In the files section we edit the interface file for the current iterated value of $(nics) but only if we have a match on the regex “$(nics)_matches_ipregex” and we replace any routes for the same network  with the desired route entry or add it if one does not exist using the replace_or_add edit_line bundle from the standard library. If we made any repairs to the file we define the class <code>persistent_route_updated_for_$(route_index)</code> which is used to control when the commands promises are made.</p>
<p>In the commands section we first delete  any route for a matching network. This command may fail if there is no matching route but that’s ok. It’s far easier to implement delete add than to account for the current routing table to avoid the possible unnecessary delete and use replace in stead. (that being said I welcome patches)</p>
<p>Finally we just report if we have made any updates.</p>
<p>I think we are lacking in explained useful examples so I hope someone finds this useful. Any suggestions for improvements or additions are welcome.</p>
<p>UPDATE: 2.19.2012</p>
<p>I had an omission in the bundle, I forgot to restrict the files edit on the $(nics)_matches_ipregex class, It caused every interface to have the specified routes added so please use the updated bundle.</p>
<p>©2012 <a href="http://www.cmdln.org">cmdln.org (a sysadmin blog)</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.cmdln.org/2012/02/18/new-bundle-to-manage-routes-for-redhatcentos-with-cfengine-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>pre-commit hook for git to check CFEngine syntax</title>
		<link>http://www.cmdln.org/2012/02/16/pre-commit-hook-for-git-to-check-cfengine-syntax/</link>
		<comments>http://www.cmdln.org/2012/02/16/pre-commit-hook-for-git-to-check-cfengine-syntax/#comments</comments>
		<pubDate>Thu, 16 Feb 2012 17:01:38 +0000</pubDate>
		<dc:creator>Nick Anderson</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[cf-promises]]></category>
		<category><![CDATA[CFEngine]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[pre-commit]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://www.cmdln.org/?p=945</guid>
		<description><![CDATA[Sometimes I am not so disciplined to run cf-promises on my policy before I commit it. I make a small change and I think I’m golden, but inevitably that breaks things. I wrote a simple commit hook to check policy syntax and stop you from shooting yourself in the foot. You can find  the pre-commit [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cmdln.org/wp-content/uploads/2012/02/git-logo.png"><img class="alignleft  wp-image-946" title="git-logo" src="http://www.cmdln.org/wp-content/uploads/2012/02/git-logo-97x150.png" alt="" width="58" height="90" /></a>Sometimes I am not so disciplined to run cf-promises on my policy before I commit it. I make a small change and I think I’m golden, but inevitably that breaks things. I wrote a simple commit hook to check policy syntax and stop you from shooting yourself in the foot. You can find  the <a id="a71b90d9d3bb7e4d1f4be225eb124c42527855a3" href="https://github.com/nickanderson/nickanderson-cfengine-library/blob/master/pre-commit">pre-commit</a> script over on <a href="https://github.com/nickanderson">my github account</a>. I hope you find it useful.</p>
<p>©2012 <a href="http://www.cmdln.org">cmdln.org (a sysadmin blog)</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.cmdln.org/2012/02/16/pre-commit-hook-for-git-to-check-cfengine-syntax/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Bundles of Bundles with CFEngine 3</title>
		<link>http://www.cmdln.org/2012/02/16/bundles-of-bundles-with-cfengine-3/</link>
		<comments>http://www.cmdln.org/2012/02/16/bundles-of-bundles-with-cfengine-3/#comments</comments>
		<pubDate>Thu, 16 Feb 2012 07:05:53 +0000</pubDate>
		<dc:creator>Nick Anderson</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[CFEngine]]></category>
		<category><![CDATA[createrepo]]></category>
		<category><![CDATA[password management]]></category>
		<category><![CDATA[redhat]]></category>
		<category><![CDATA[routes]]></category>
		<category><![CDATA[selinux]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[yum]]></category>

		<guid isPermaLink="false">http://www.cmdln.org/?p=935</guid>
		<description><![CDATA[I’ve been working more and more with CFEngine lately and I have been slowly building a tiny library. These are all pretty much redhat specific but I welcome patches and comments. Most of the bundles have comments that show usage, if there is interest I may post some example usage later.         [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cmdln.org/wp-content/uploads/2012/02/Extrusion-Bundles2.jpg"><img class="alignleft size-thumbnail wp-image-936" title="Bundles of Bundles" src="http://www.cmdln.org/wp-content/uploads/2012/02/Extrusion-Bundles2-150x150.jpg" alt="" width="150" height="150" /></a>I’ve been working more and more with CFEngine lately and I have been slowly building a <a href="http://www.laurand.net/images/Extrusion%20Bundles2.jpg">tiny library</a>. These are all pretty much redhat specific but I welcome patches and comments. Most of the bundles have comments that show usage, if there is interest I may post some example usage later.</p>
<p> </p>
<p> </p>
<p> </p>
<p><span id="more-935"></span></p>
<p> </p>
<p>I have recently added these bundles to my library</p>
<h2><a id="1547a55e9c7f237eb46ab06a01bb5d7a8ca13f88" href="https://github.com/nickanderson/nickanderson-cfengine-library/blob/master/lib_rh.cf">lib_rh.cf</a></h2>
<ul>
<li>
<pre>rh_add_interface_routes - manage routes on an interface</pre>
</li>
<li>
<pre>create_update_yum_repo - create a yum repo and update the metadata if files change</pre>
</li>
<li>
<pre>set_selinux_disabled - disable selinux, yes its sad but its common</pre>
</li>
<li>config_yum_client_repos — configure yum client configs in /etc/yum.repos.d/</li>
</ul>
<pre></pre>
<h2><a id="2588f5f1173110449ece0d6ec54c90c8c84351d7" href="https://github.com/nickanderson/nickanderson-cfengine-library/blob/master/lib_local_user_management.cf">lib_local_user_management.cf</a></h2>
<ul>
<li>local_users_enforce_password — enforce a local users password, supports updating last day changed for password expiration</li>
</ul>
<p> </p>
<p>©2012 <a href="http://www.cmdln.org">cmdln.org (a sysadmin blog)</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.cmdln.org/2012/02/16/bundles-of-bundles-with-cfengine-3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Great Internet Blackout of 2012</title>
		<link>http://www.cmdln.org/2012/01/18/the-great-internet-blackout-of-2012/</link>
		<comments>http://www.cmdln.org/2012/01/18/the-great-internet-blackout-of-2012/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 15:11:24 +0000</pubDate>
		<dc:creator>Nick Anderson</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[blackout]]></category>
		<category><![CDATA[freedom]]></category>
		<category><![CDATA[PIPA]]></category>
		<category><![CDATA[SOPA]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://www.cmdln.org/?p=932</guid>
		<description><![CDATA[I am happy to see how many sites are participating in the SOPA/PIPA protest today. I am a bit disapointed that facebook did not join (at least yet), and google only doing a doodle seems a little bit on the weak side. Still its nice when  so many people can show support for something so [...]]]></description>
			<content:encoded><![CDATA[<p>I am happy to see how many sites are participating in the SOPA/PIPA protest today. I am a bit disapointed that facebook did not join (at least yet), and google only doing a doodle seems a little bit on the weak side. Still its nice when  so many people can show support for something so threatening. There is quite a list of sites that are blacked out in one way or another today.</p>
<p><a href="http://sopastrike.com/">http://sopastrike.com/</a></p>
<p>I encourage you to voice your opposition to SOPA and PIPA as well.  Follow the link below for an easy way to get your representatives contact information, and send them an email.</p>
<p><a href="https://wfc2.wiredforchange.com/o/9042/p/dia/action/public/">https://wfc2.wiredforchange.com/o/9042/p/dia/action/public/</a></p>
<p> </p>
<p> </p>
<p>©2012 <a href="http://www.cmdln.org">cmdln.org (a sysadmin blog)</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.cmdln.org/2012/01/18/the-great-internet-blackout-of-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NetApp — Customer Service WIN!</title>
		<link>http://www.cmdln.org/2011/12/15/netapp-customer-service-win/</link>
		<comments>http://www.cmdln.org/2011/12/15/netapp-customer-service-win/#comments</comments>
		<pubDate>Thu, 15 Dec 2011 17:02:25 +0000</pubDate>
		<dc:creator>Nick Anderson</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[customer service]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[win]]></category>

		<guid isPermaLink="false">http://www.cmdln.org/?p=924</guid>
		<description><![CDATA[I just wanted to share my NetApp customer service experience since usually people only share negative experiences. I needed to download a mib for a NetApp today. I really don’t like that I have to register an account just to download a mib but whatever. I was really upset after registering the account and entering [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cmdln.org/wp-content/uploads/2011/12/thumbsup_000.jpg"><img class="alignleft size-thumbnail wp-image-925" title="thumbsup_000" src="http://www.cmdln.org/wp-content/uploads/2011/12/thumbsup_000-150x150.jpg" alt="" width="150" height="150" /></a>I just wanted to share my NetApp customer service experience since usually people only share negative experiences. I needed to download a mib for a NetApp today. I really don’t like that I have to register an account just to download a mib but whatever. I was really upset after registering the account and entering a system-id to find that I didn’t have access to download any mibs.</p>
<p>I saw that feedback button glaring at me so decided to give it a shot, left a “very dissatisfied” about download experience review. Within an hour I had an email that my access had been changed, and I now have access to download the mibs.</p>
<p>Good job NetApp, in my experience those feedback forms usually go unanswered.</p>
<p>©2012 <a href="http://www.cmdln.org">cmdln.org (a sysadmin blog)</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.cmdln.org/2011/12/15/netapp-customer-service-win/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remember to Register for Xen Day Boston 2011</title>
		<link>http://www.cmdln.org/2011/12/05/remember-to-register-for-xen-day-boston-2011/</link>
		<comments>http://www.cmdln.org/2011/12/05/remember-to-register-for-xen-day-boston-2011/#comments</comments>
		<pubDate>Mon, 05 Dec 2011 15:36:02 +0000</pubDate>
		<dc:creator>Nick Anderson</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[xen]]></category>

		<guid isPermaLink="false">http://www.cmdln.org/?p=920</guid>
		<description><![CDATA[Just a reminder that Xen Day Boston 2011 is coming up (December 9th). There’s still room to register, but spots are going fast! For more information see: http://blog.xen.org/index.php/2011/12/02/xen-day-presenters/ ©2012 cmdln.org (a sysadmin blog). All Rights Reserved..]]></description>
			<content:encoded><![CDATA[<p>Just a reminder that Xen Day Boston 2011 is coming up (December 9th).</p>
<p>There’s still room to register, but spots are going fast!</p>
<p>For more information see:</p>
<p>http://blog.xen.org/index.php/2011/12/02/xen-day-presenters/</p>
<p>©2012 <a href="http://www.cmdln.org">cmdln.org (a sysadmin blog)</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.cmdln.org/2011/12/05/remember-to-register-for-xen-day-boston-2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Xen Day @ LISA11</title>
		<link>http://www.cmdln.org/2011/11/18/xen-day-lisa11/</link>
		<comments>http://www.cmdln.org/2011/11/18/xen-day-lisa11/#comments</comments>
		<pubDate>Fri, 18 Nov 2011 18:41:12 +0000</pubDate>
		<dc:creator>Nick Anderson</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[LISA]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[xen]]></category>

		<guid isPermaLink="false">http://www.cmdln.org/?p=912</guid>
		<description><![CDATA[If you’re going to LISA in Boston this year consider registering for Xen Day on Friday Dec, 9. Registration is free and the schedule looks great. ©2012 cmdln.org (a sysadmin blog). All Rights Reserved..]]></description>
			<content:encoded><![CDATA[<p><a href="http://xen.org/community/xenday11.html"><br />
<img class="   " title="Xen Day 2011" src="http://xen.org/images/logos/Lisa11Xen.png" alt="Xen Day 2011" width="360" height="56" /></a></p>
<p>If you’re going to LISA in Boston this year consider registering for <a href="http://xen.org/community/xenday11.html">Xen Day</a> on Friday Dec, 9. <a href="http://www.regonline.com/Register/Checkin.aspx?EventID=1032884">Registration is free</a> and the schedule looks great.</p>
<p>©2012 <a href="http://www.cmdln.org">cmdln.org (a sysadmin blog)</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.cmdln.org/2011/11/18/xen-day-lisa11/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

