<?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>yo61.com &#187; scripting</title>
	<atom:link href="http://yo61.com/tag/scripting/feed" rel="self" type="application/rss+xml" />
	<link>http://yo61.com</link>
	<description>Web Operations &#38; System Administration in the wilds of North Yorkshire</description>
	<lastBuildDate>Mon, 30 Jan 2012 10:11:15 +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>Pre-generate sshd certificates</title>
		<link>http://yo61.com/pre-generate-sshd-certificates.html</link>
		<comments>http://yo61.com/pre-generate-sshd-certificates.html#comments</comments>
		<pubDate>Wed, 11 Nov 2009 10:27:31 +0000</pubDate>
		<dc:creator>Robin Bowes</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[puppet]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[sshd]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://yo61.com/?p=83</guid>
		<description><![CDATA[I use puppet to distribute my sshd configuration, including pre-generated ssh certificates. Here&#39;s how I bulk create certificates for a bunch of new nodes named b001-b034: for n in $&#40;seq -w 1 34&#41;; do ssh-keygen -q -t rsa -f b0$n -C '' -N '' done]]></description>
			<content:encoded><![CDATA[<p>I use puppet to distribute my sshd configuration, including pre-generated ssh certificates.</p>
<p>Here&#39;s how I bulk create certificates for a bunch of new nodes named b001-b034:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> n <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">seq</span> <span style="color: #660033;">-w</span> <span style="color: #000000;">1</span> <span style="color: #000000;">34</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #c20cb9; font-weight: bold;">ssh-keygen</span> <span style="color: #660033;">-q</span> <span style="color: #660033;">-t</span> rsa <span style="color: #660033;">-f</span> b0<span style="color: #007800;">$n</span> <span style="color: #660033;">-C</span> <span style="color: #ff0000;">''</span> <span style="color: #660033;">-N</span> <span style="color: #ff0000;">''</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://yo61.com/pre-generate-sshd-certificates.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuring lots of Dell DRACs at once</title>
		<link>http://yo61.com/configuring-lots-of-dell-dracs-at-once.html</link>
		<comments>http://yo61.com/configuring-lots-of-dell-dracs-at-once.html#comments</comments>
		<pubDate>Tue, 10 Nov 2009 12:18:44 +0000</pubDate>
		<dc:creator>Robin Bowes</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[dell]]></category>
		<category><![CDATA[drac]]></category>
		<category><![CDATA[racadm]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://yo61.com/?p=77</guid>
		<description><![CDATA[Having got racadm working on my workstation (see my previous post), the next step is to perform initial DRAC configuration, ie. change the root password, set the SSL cert values, etc. First I checked that all DRACs were pingable: for h in $&#40;seq -w 1 34&#41;; do hn=b0$h.drac.example.com if ping -q -c 1 $hn &#62;&#38; [...]]]></description>
			<content:encoded><![CDATA[<p>Having got racadm working on my workstation (see my <a href="/install-dell-racadm-on-fedora-11.html">previous post</a>), the next step is to perform initial DRAC configuration, ie. change the root password, set the SSL cert values, etc.</p>
<p>
	First I checked that all DRACs were pingable:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> h <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">seq</span> <span style="color: #660033;">-w</span> <span style="color: #000000;">1</span> <span style="color: #000000;">34</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #007800;">hn</span>=b0<span style="color: #007800;">$h</span>.drac.example.com
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #c20cb9; font-weight: bold;">ping</span> <span style="color: #660033;">-q</span> <span style="color: #660033;">-c</span> <span style="color: #000000;">1</span> <span style="color: #007800;">$hn</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null ; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> OK
    <span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> failed
    <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>Next, I created a drac config file (named drac.cfg) containing the settings that are common to all devices:</p>

<div class="wp_syntax"><div class="code"><pre class="" style="font-family:monospace;"><span class="br0">&#91;</span>cfgLanNetworking<span class="br0">&#93;</span>
cfgDNSDomainName=drac.example.com
&nbsp;
<span class="br0">&#91;</span>cfgUserAdmin<span class="br0">&#93;</span>
# cfgUserAdminIndex=<span style="">2</span>
cfgUserAdminUserName=root
cfgUserAdminPassword=secret
&nbsp;
<span class="br0">&#91;</span>cfgOobSnmp<span class="br0">&#93;</span>
cfgOobSnmpAgentEnable=<span style="">1</span>
cfgOobSnmpAgentCommunity=my_community_name
&nbsp;
<span class="br0">&#91;</span>cfgRacSecurity<span class="br0">&#93;</span>
cfgRacSecCsrKeySize=<span style="">1024</span>
# cfgRacSecCsrCommonName=
cfgRacSecCsrOrganizationName=example.com
cfgRacSecCsrOrganizationUnit=Web Services
cfgRacSecCsrLocalityName=My City
cfgRacSecCsrStateName=My State
cfgRacSecCsrCountryCode=IE
cfgRacSecCsrEmailAddr=contact@example.com</pre></div></div>

<p>I then ran a script to apply the common configuration to all devices. I also set the device-specific settings in the same script:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> n <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">seq</span> <span style="color: #660033;">-w</span> <span style="color: #000000;">1</span> <span style="color: #000000;">34</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #007800;">host</span>=b0<span style="color: #007800;">$hn</span>
    <span style="color: #007800;">domain</span>=drac.example.com
    <span style="color: #007800;">fullname</span>=<span style="color: #007800;">$host</span>.<span style="color: #007800;">$domain</span>
    racadm <span style="color: #660033;">-r</span> <span style="color: #007800;">$fullname</span> <span style="color: #660033;">-u</span> root <span style="color: #660033;">-p</span> calvin config <span style="color: #660033;">-g</span> cfgLanNetworking <span style="color: #660033;">-o</span> cfgDNSRacName <span style="color: #007800;">$host</span>
    racadm <span style="color: #660033;">-r</span> <span style="color: #007800;">$fullname</span> <span style="color: #660033;">-u</span> root <span style="color: #660033;">-p</span> calvin config <span style="color: #660033;">-g</span> cfgRacSecurity <span style="color: #660033;">-o</span> cfgRacSecCsrCommonName <span style="color: #007800;">$fullname</span>
    racadm <span style="color: #660033;">-r</span> <span style="color: #007800;">$fullname</span> <span style="color: #660033;">-u</span> root <span style="color: #660033;">-p</span> calvin config <span style="color: #660033;">-f</span> drac.cfg
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>Notice that I don&#39;t change the default password until last.</p>
<p>Now, I just need to work out how to generate the CSR, sign it, and upload the new cert&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://yo61.com/configuring-lots-of-dell-dracs-at-once.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Check file system integrity of multiple xen domU guests</title>
		<link>http://yo61.com/check-file-system-integrity-of-multiple-xen-domu-guests.html</link>
		<comments>http://yo61.com/check-file-system-integrity-of-multiple-xen-domu-guests.html#comments</comments>
		<pubDate>Mon, 09 Nov 2009 00:20:10 +0000</pubDate>
		<dc:creator>Robin Bowes</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[kpartx]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[lvm]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[xen]]></category>

		<guid isPermaLink="false">http://yo61.com/?p=49</guid>
		<description><![CDATA[I needed to check the integrity of the file systems on several xen domU guests while the guests were shutdown, ie. I needed to do it from the dom0. I use LVM logical volumes for the block devices for the guests disks named $host-disk0. These are stored in a volume group named vg_guests. I use [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to check the integrity of the file systems on several <a href="http://www.xen.org/">xen</a> domU guests while the guests were shutdown, ie. I needed to do it from the dom0.</p>
<p>I use <a href="http://sources.redhat.com/lvm2/">LVM</a> logical volumes for the block devices for the guests disks named <code>$host-disk0</code>. These are stored in a volume group named <code>vg_guests</code>. I use <a href="http://linux.die.net/man/8/kpartx">kpartx</a> to access the partitions on the block device.</p>
<p>Each guest disk has a small physical partition for<code> /boot</code>; the rest of the disk is allocated to a 2nd partition which is used as an LVM volume group named <code>vg_$host</code>.</p>
<p>Here&#39;s a script I knocked up to do the job:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> host <span style="color: #000000; font-weight: bold;">in</span> host1 host2 host3 ; <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #666666; font-style: italic;"># create devices from the LVs</span>
    kpartx <span style="color: #660033;">-av</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>mapper<span style="color: #000000; font-weight: bold;">/</span>vg_guests-<span style="color: #007800;">$host</span>--disk<span style="color: #000000; font-weight: bold;">*</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># Activate the VGs for the host</span>
    <span style="color: #000000; font-weight: bold;">for</span> vg <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span>vgs <span style="color: #660033;">--noheadings</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #007800;">$host</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #000000; font-weight: bold;">&amp;</span><span style="color: #666666; font-style: italic;">#39;{print $1}&amp;#39; ) ; do</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> Activating <span style="color: #007800;">$vg</span>
        vgchange <span style="color: #660033;">-ay</span> <span style="color: #007800;">$vg</span>
    <span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># check the file systems</span>
    <span style="color: #000000; font-weight: bold;">for</span> p <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>mapper<span style="color: #000000; font-weight: bold;">/</span>vg_<span style="color: #007800;">$host</span><span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> swap<span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">do</span>
        e2fsck <span style="color: #660033;">-p</span> <span style="color: #007800;">$p</span>
    <span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># Deactivate the VGs</span>
    <span style="color: #000000; font-weight: bold;">for</span> vg <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span>vgs <span style="color: #660033;">--noheadings</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #007800;">$host</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #000000; font-weight: bold;">&amp;</span><span style="color: #666666; font-style: italic;">#39;{print $1}&amp;#39; ) ; do</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> De-activating <span style="color: #007800;">$vg</span>
        vgchange <span style="color: #660033;">-an</span> <span style="color: #007800;">$vg</span>
    <span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># Remove the devices</span>
    kpartx <span style="color: #660033;">-dv</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>mapper<span style="color: #000000; font-weight: bold;">/</span>vg_guests-<span style="color: #007800;">$host</span>--disk0
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://yo61.com/check-file-system-integrity-of-multiple-xen-domu-guests.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

