<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>Joni Junni</title>
    <subtitle>My notes on various, mostly computing related stuff.</subtitle>
    <link rel="self" type="application/atom+xml" href="/atom.xml"/>
    <link rel="alternate" type="text/html" href="/"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2023-04-07T13:50:00+00:00</updated>
    <id>/atom.xml</id>
    <entry xml:lang="en">
        <title>Disabling Type 2 Protection in SAS HDDs</title>
        <published>2023-04-07T13:50:00+00:00</published>
        <updated>2023-04-07T13:50:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/posts/disabling-type-2-protection-in-sas-hdds/"/>
        <id>/posts/disabling-type-2-protection-in-sas-hdds/</id>
        
        <content type="html" xml:base="/posts/disabling-type-2-protection-in-sas-hdds/">&lt;h2 id=&quot;what-is-type-2-protection&quot;&gt;What is Type 2 Protection?&lt;&#x2F;h2&gt;
&lt;p&gt;Sometimes old enterprise SAS disks come with Type 1 or 2 Protection enabled.  This is based on &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Data_Integrity_Field&quot;&gt;T10 Data Protection Information&lt;&#x2F;a&gt; specification, which aims to ensure end-to-end-data integrity for data storage by using different (520 byte) block size where the disk controller can use the extra bytes for parity checking etc. In some cases this configuration can result problems with software RAID setups, like ZFS.&lt;&#x2F;p&gt;
&lt;p&gt;To disable Type 2 Protection in modern SAS hard disks, you can use &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;linux.die.net&#x2F;man&#x2F;8&#x2F;sg3_utils&quot;&gt;sg3_utils&lt;&#x2F;a&gt;-package found in most Linux distributions.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;Disclaimer: This procedure will DESTROY all data on the disk. Using these commands can make your disk unusable. Use on your own risk! You have been warned.&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;p&gt;You can use &lt;code&gt;sg_readcap&lt;&#x2F;code&gt; command to check if you have the protection feature on:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;root@parzival&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; ~]#&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; sg_readcap&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &#x2F;dev&#x2F;sdYOURDISK&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;READ&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; CAPACITY&lt;&#x2F;span&gt;&lt;span&gt; (10&lt;&#x2F;span&gt;&lt;span&gt;) indicates device capacity too large&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;  now&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; trying&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; 16&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; byte&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; cdb&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; variant&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;Read&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; Capacity&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; results:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;   Protection:&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; prot_en=1,&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; p_type=1,&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; p_i_exponent=&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;0&lt;&#x2F;span&gt;&lt;span&gt; [type&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; 2&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; protection]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;   Logical&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; block&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; provisioning:&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; lbpme=0,&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; lbprz=&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;   Last&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; LBA=&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;22961717247&lt;&#x2F;span&gt;&lt;span&gt; (0x5589fffff&lt;&#x2F;span&gt;&lt;span&gt;), Number of logical&lt;&#x2F;span&gt;&lt;span&gt; blocks&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;2&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;2&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;9&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;6&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;7&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;7&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;2&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;4&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;8&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;   Logical&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; block&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; length=&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;512&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; bytes&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;   Logical&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; blocks&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; per&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; physical&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; block&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; exponent=&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;3&lt;&#x2F;span&gt;&lt;span&gt; [so&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; physical&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; block&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; length=&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;4096&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; bytes]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;   Lowest&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; aligned&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; LBA=&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;Hence:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;   Device&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; size:&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; 11756399230976&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; bytes,&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; 11211776.0&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; MiB,&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; 11756.40&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; GB,&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; 11.76&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; TB&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;So here we can see that &lt;code&gt;[type 2 protection]&lt;&#x2F;code&gt; is mentioned in the command output, which indicates that the Type 2 protection is currently enabled.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;disabling-type-2-protection&quot;&gt;Disabling Type 2 protection&lt;&#x2F;h2&gt;
&lt;p&gt;So how we can disable it? With &lt;code&gt;sg_format&lt;&#x2F;code&gt; command. This will send a &lt;strong&gt;FORMAT UNIT&lt;&#x2F;strong&gt; command the controller on the hard disk itself, which will start a low-level formatting process to change the layout on the disk. &lt;strong&gt;Note: This will take a loong time to complete depending on hard disk size and it will delete all data on the disk. You have been warned.&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;p&gt;The command:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;sg_format -F -f 0 -v &#x2F;dev&#x2F;sdYOURDISK&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Where the arguments I’m using are:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;-F&lt;&#x2F;strong&gt; is &lt;strong&gt;—format&lt;&#x2F;strong&gt;, do &lt;strong&gt;FORMAT UNIT&lt;&#x2F;strong&gt; command&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;-f 0&lt;&#x2F;strong&gt; is &lt;strong&gt;—fmtpinfo=0&lt;&#x2F;strong&gt;, means what protection level to select&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;-v&lt;&#x2F;strong&gt; which means verbose.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;You can find more in-depth command definitions in the &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;linux.die.net&#x2F;man&#x2F;8&#x2F;sg_format&quot;&gt;sg_format man page&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[&lt;&#x2F;span&gt;&lt;span&gt;root@parzival &lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;~&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span&gt;# sg_format -F -f 0 -v &#x2F;dev&#x2F;sdYOURDISK&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;    SEAGATE&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;   ST12000NM0158&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;     RSL5&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;   peripheral_type:&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; disk&lt;&#x2F;span&gt;&lt;span&gt; [0x0&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      PROTECT&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;      &amp;lt;&amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; supports&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt; protection&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; informatio&lt;&#x2F;span&gt;&lt;span&gt;n&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;&amp;gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;      Unit serial number: MAG1CA7&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;      LU name: 5000c&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;    mode sense(10) cdb: [5a 00 01 00 00 00 00 00 fc 00]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;Mode Sense (block descriptor) data, prior to changes:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;block count maxed out, set &amp;lt;&amp;lt;longlba&amp;gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;    mode sense(10) cdb: [5a 10 01 00 00 00 00 00 fc 00]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;  &amp;lt;&amp;lt;&amp;lt; longlba flag set (64 bit lba) &amp;gt;&amp;gt;&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;  Number of blocks=23081319440 [0x55fc0fc10]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;  Block size=512 [0x200]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;A FORMAT UNIT will commence in 15 seconds&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;    ALL data on &#x2F;dev&#x2F;sdYOURDISK will be DESTROYED&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;        Press control-C to abort&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;A FORMAT UNIT will commence in 10 seconds&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;    ALL data on &#x2F;dev&#x2F;sdYOURDISK will be DESTROYED&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;        Press control-C to abort&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;A FORMAT UNIT will commence in 5 seconds&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;    ALL data on &#x2F;dev&#x2F;sdYOURDISK will be DESTROYED&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;        Press control-C to abort&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;    Format unit cdb: [04 18 00 00 00 00]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;Format unit command launched without error&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;After the command was run successfully, it will print out the status info every few seconds. You can Ctrl-C out of the command if you like, it will continue the format in the background. You can check the status of the formatting with &lt;code&gt;sg_requests&lt;&#x2F;code&gt;:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[&lt;&#x2F;span&gt;&lt;span&gt;root@parzival &lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;~&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span&gt;# sg_requests &#x2F;dev&#x2F;sdYOURDISK&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;data-in&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; decoded&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; as&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; sense:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;Fixed&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; format,&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; current&lt;&#x2F;span&gt;&lt;span&gt;;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt; Sense&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; key:&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; Not&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; Ready&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;Additional&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; sense:&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; Logical&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; unit&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; not&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; ready,&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; format&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; in&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; progress&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;  Progress&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; indication:&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; 0.37%&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;Number&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; of&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; data-in&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; errors&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; detected:&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; 1,&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; most&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; recent&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; sense_key=&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;2&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;sources&quot;&gt;Sources&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;linux.die.net&#x2F;man&#x2F;8&#x2F;sg3_utils&quot;&gt;sg_utils man page&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Creating a MariaDB database and user from CLI</title>
        <published>2017-08-05T00:00:00+00:00</published>
        <updated>2017-08-05T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/posts/create-mysql-database-from-cli/"/>
        <id>/posts/create-mysql-database-from-cli/</id>
        
        <summary type="html">&lt;p&gt;&lt;em&gt;2026-08-09: Updated to MariaDB-compatible commands&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;p&gt;For some reason I always have to search the internet for the steps required for creating a database and grant privileges to it in the MariaDB command line. Usually the how-tos found on the net are a bit complicated or they are missing some commands that I like to do when I create databases and users.&amp;hellip;
&lt;&#x2F;p&gt;
</summary>
        
    </entry>
    <entry xml:lang="en">
        <title>Replacing default Samsung Emoji emoticons with Google Emojis on rooted Samsung Note 3</title>
        <published>2014-07-17T00:00:00+00:00</published>
        <updated>2014-07-17T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/posts/replacing-default-samsung-emoji-emoticons-with-google-emojis-on-samsung-note-3-rooted/"/>
        <id>/posts/replacing-default-samsung-emoji-emoticons-with-google-emojis-on-samsung-note-3-rooted/</id>
        
        <content type="html" xml:base="/posts/replacing-default-samsung-emoji-emoticons-with-google-emojis-on-samsung-note-3-rooted/">&lt;p&gt;&lt;strong&gt;Your device needs to be rooted for this to work!&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;p&gt;First, connect the mobile on your computer with USB-cable. Download, extract &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;www.jonijunni.fi&#x2F;wp-content&#x2F;uploads&#x2F;2014&#x2F;07&#x2F;Emoji_Google.zip&quot;&gt;Emoji_Google&lt;&#x2F;a&gt; and copy NotoColorEmoji.ttf file to the device SD-card.&lt;&#x2F;p&gt;
&lt;p&gt;Open an adb-shell on the mobile as root:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;adb shell&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;su&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Remount &#x2F;system, so we can copy the file:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mount -o rw,remount &#x2F;system&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Rename the old file for backup purposes:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mv &#x2F;system&#x2F;fonts&#x2F;NotoColorEmoji.ttf &#x2F;system&#x2F;fonts&#x2F;NotoColorEmoji.ttf.old&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Copy the new file in &#x2F;system&#x2F;fonts (your path may vary depending on where you saved it) and set the correct permissions:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;cp &#x2F;sdcard&#x2F;NotoColorEmoji.ttf &#x2F;system&#x2F;fonts&#x2F;NotoColorEmoji.ttf&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;chmod 644 &#x2F;system&#x2F;fonts&#x2F;NotoColorEmoji.ttf&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Remount &#x2F;system as read-only again:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mount -o ro,remount &#x2F;system&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Finally, reboot the device.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;posts&#x2F;replacing-default-samsung-emoji-emoticons-with-google-emojis-on-samsung-note-3-rooted&#x2F;google-emojis.png&quot; alt=&quot;google-emojs&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Yay, Google Emojis appear!&lt;&#x2F;p&gt;
&lt;p&gt; &lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Linux centralized management: Creating a puppet test environment based on production server - Part 1</title>
        <published>2013-12-11T00:00:00+00:00</published>
        <updated>2013-12-11T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/school/linux-centralized-management/creating-a-puppet-test-environment-based-on-production-server-part-1/"/>
        <id>/school/linux-centralized-management/creating-a-puppet-test-environment-based-on-production-server-part-1/</id>
        
        <content type="html" xml:base="/school/linux-centralized-management/creating-a-puppet-test-environment-based-on-production-server-part-1/">&lt;h1 id=&quot;creating-a-puppet-test-environment-based-on-production-server-part-1&quot;&gt;Creating a puppet test environment based on production server - Part 1&lt;&#x2F;h1&gt;
&lt;p&gt;I decided to do few modules that will build an identical server configuration based on a production server of mine.&lt;&#x2F;p&gt;
&lt;p&gt;First I created a project folder where all the project files are created.&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;mkdir&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; vhost&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;cd&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; vhost&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; init&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I used Vagrant to create a virtual machine where my puppet modules will be deployed.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;creating-the-vagrantfile-for-the-environment&quot;&gt;Creating the Vagrantfile for the environment&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;code&gt;nano Vagrantfile&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;p&gt;I wrote a Vagrantfile that creates one virtual machine where all the modules will be run:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;ruby&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;Vagrant&lt;&#x2F;span&gt;&lt;span&gt;::&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;Config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;run&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; do&lt;&#x2F;span&gt;&lt;span&gt; |&lt;&#x2F;span&gt;&lt;span&gt;config&lt;&#x2F;span&gt;&lt;span&gt;|&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;vm&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;provision&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; :&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;puppet&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; do&lt;&#x2F;span&gt;&lt;span&gt; |&lt;&#x2F;span&gt;&lt;span&gt;puppet&lt;&#x2F;span&gt;&lt;span&gt;|&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		puppet&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;module_path&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;modules&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		puppet&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;manifest_file&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;site.pp&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;	end&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;vm&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;define&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; :&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;web1&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; do&lt;&#x2F;span&gt;&lt;span&gt; |&lt;&#x2F;span&gt;&lt;span&gt;apache_config&lt;&#x2F;span&gt;&lt;span&gt;|&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		apache_config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;vm&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;box&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;precise64&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		apache_config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;vm&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;box_url&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;http:&#x2F;&#x2F;files.vagrantup.com&#x2F;precise64.box&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		apache_config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;vm&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;network&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; :&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;hostonly&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;10.0.0.2&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		apache_config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;vm&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;host_name&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;web1.labra.local&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;	end&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;end&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;creating-apache-module-with-virtual-hosts&quot;&gt;Creating Apache module with virtual hosts&lt;&#x2F;h2&gt;
&lt;p&gt;I created a new module called apache which will install Apache and with a defined type vhost allow creating of virtualhosts for Apache.&lt;&#x2F;p&gt;
&lt;p&gt;First I created the default module directory structure:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;mkdir&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; -&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;p&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; modules&#x2F;apache&#x2F;manifests&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;mkdir&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; -&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;p&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; modules&#x2F;apache&#x2F;templates&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Then I created the main init.pp file:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nano modules&#x2F;apache&#x2F;manifests&#x2F;init.pp&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;And wrote the following in it:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;puppet&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;class&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt; apache&lt;&#x2F;span&gt;&lt;span&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;        package&lt;&#x2F;span&gt;&lt;span&gt; {&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;apache2&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;                ensure &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span&gt; installed,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;                require &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; Exec&lt;&#x2F;span&gt;&lt;span&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;apt-update&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;        service&lt;&#x2F;span&gt;&lt;span&gt; {&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;apache2&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;                ensure &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; running&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;                require &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; Package&lt;&#x2F;span&gt;&lt;span&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;apache2&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;        exec&lt;&#x2F;span&gt;&lt;span&gt; { &lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;apt-update&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;                command &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&#x2F;usr&#x2F;bin&#x2F;apt-get update&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The main manifest installs Apache and starts it if it is not running already. The exec-command is only needed for Vagrant because it does not update package lists automatically, more about the problem in &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;10845864&#x2F;puppet-trick-run-apt-get-update-before-installing-other-packages&quot;&gt;here&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;apache-virtualhosts-with-defined-types&quot;&gt;Apache Virtualhosts with defined types&lt;&#x2F;h2&gt;
&lt;p&gt;For the Apache Virtualhosts I used my modified version of the &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;puppetlabs&#x2F;puppetlabs-apache&#x2F;blob&#x2F;master&#x2F;manifests&#x2F;vhost.pp&quot;&gt;Puppetlabs-apache&lt;&#x2F;a&gt; defined type vhost code.&lt;&#x2F;p&gt;
&lt;p&gt;I created the vhost.pp file for the virtualhost type:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nano modules&#x2F;apache&#x2F;manifests&#x2F;vhost.pp&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I modified the Puppetlabs code to be a bit simplified version for my configuration:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;puppet&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;define&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt; apache::vhost&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        $&lt;&#x2F;span&gt;&lt;span&gt;port&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        $&lt;&#x2F;span&gt;&lt;span&gt;docroot&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;        =&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&#x2F;var&#x2F;www-${name}&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        $&lt;&#x2F;span&gt;&lt;span&gt;template&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;      =&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;apache&#x2F;vhost-default.conf.erb&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        $&lt;&#x2F;span&gt;&lt;span&gt;priority&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;      =&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;25&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        $&lt;&#x2F;span&gt;&lt;span&gt;servername&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;    =&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        $&lt;&#x2F;span&gt;&lt;span&gt;serveraliases&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        $&lt;&#x2F;span&gt;&lt;span&gt;options&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;       =&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;Indexes FollowSymLinks MultiViews&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        $&lt;&#x2F;span&gt;&lt;span&gt;vhost_name&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;    =&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;*&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      ) &lt;&#x2F;span&gt;&lt;span&gt;{&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;      include&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#E36209, #FFAB70);&quot;&gt; apache&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6A737D, #6A737D);&quot;&gt;      #&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6A737D, #6A737D);&quot;&gt; Below is a pre-2.6.5 idiom for having a parameter default to the title,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6A737D, #6A737D);&quot;&gt;      #&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6A737D, #6A737D);&quot;&gt; but you could also just declare $servername = &amp;quot;$title&amp;quot; in the parameters&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6A737D, #6A737D);&quot;&gt;      #&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6A737D, #6A737D);&quot;&gt; list and change srvname to servername in the template.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;      if&lt;&#x2F;span&gt;&lt;span&gt; $&lt;&#x2F;span&gt;&lt;span&gt;servername&lt;&#x2F;span&gt;&lt;span&gt; == &lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        $&lt;&#x2F;span&gt;&lt;span&gt;srvname&lt;&#x2F;span&gt;&lt;span&gt; = &lt;&#x2F;span&gt;&lt;span&gt;$&lt;&#x2F;span&gt;&lt;span&gt;title&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      } &lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;else&lt;&#x2F;span&gt;&lt;span&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        $&lt;&#x2F;span&gt;&lt;span&gt;srvname&lt;&#x2F;span&gt;&lt;span&gt; = &lt;&#x2F;span&gt;&lt;span&gt;$&lt;&#x2F;span&gt;&lt;span&gt;servername&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;      case&lt;&#x2F;span&gt;&lt;span&gt; $&lt;&#x2F;span&gt;&lt;span&gt;operatingsystem&lt;&#x2F;span&gt;&lt;span&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;        &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;centos&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;redhat&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;fedora&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;: { &lt;&#x2F;span&gt;&lt;span&gt;$&lt;&#x2F;span&gt;&lt;span&gt;vdir&lt;&#x2F;span&gt;&lt;span&gt;   = &lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&#x2F;etc&#x2F;httpd&#x2F;conf.d&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                                        $&lt;&#x2F;span&gt;&lt;span&gt;logdir&lt;&#x2F;span&gt;&lt;span&gt; = &lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&#x2F;var&#x2F;log&#x2F;httpd&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;        &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;ubuntu&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;debian&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;:           { &lt;&#x2F;span&gt;&lt;span&gt;$&lt;&#x2F;span&gt;&lt;span&gt;vdir&lt;&#x2F;span&gt;&lt;span&gt;   = &lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&#x2F;etc&#x2F;apache2&#x2F;sites-enabled&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                                        $&lt;&#x2F;span&gt;&lt;span&gt;logdir&lt;&#x2F;span&gt;&lt;span&gt; = &lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&#x2F;var&#x2F;log&#x2F;apache2&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;        default:&lt;&#x2F;span&gt;&lt;span&gt;                      { &lt;&#x2F;span&gt;&lt;span&gt;$&lt;&#x2F;span&gt;&lt;span&gt;vdir&lt;&#x2F;span&gt;&lt;span&gt;   = &lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&#x2F;etc&#x2F;apache2&#x2F;sites-enabled&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                                        $&lt;&#x2F;span&gt;&lt;span&gt;logdir&lt;&#x2F;span&gt;&lt;span&gt; = &lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&#x2F;var&#x2F;log&#x2F;apache2&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;      file&lt;&#x2F;span&gt;&lt;span&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;        &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;${&lt;&#x2F;span&gt;&lt;span&gt;vdir&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;}&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;${&lt;&#x2F;span&gt;&lt;span&gt;priority&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;}&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;-&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;${&lt;&#x2F;span&gt;&lt;span&gt;name&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;}&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;.conf&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;          content &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; template&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span&gt;$&lt;&#x2F;span&gt;&lt;span&gt;template&lt;&#x2F;span&gt;&lt;span&gt;),&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;          owner   &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;root&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;          group   &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;root&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;          mode    &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;755&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;          require &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; Package&lt;&#x2F;span&gt;&lt;span&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;apache2&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;          notify  &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; Service&lt;&#x2F;span&gt;&lt;span&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;apache2&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Creating the master site definition for Vagrant Puppet provision&lt;&#x2F;p&gt;
&lt;p&gt;First I created a manifests-directory to my project directory root where I created a site.pp file for Vagrant to run:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mkdir manifests&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nano manifests&#x2F;site.pp&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I defined my one node in the file to install Apache and MySQL Server, create two users for the sites and finally create two virtualhosts with the names jonijunni.labra.local and synkkasiiseli.labra.local:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;puppet&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;	node&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;web1.labra.local&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;            apache::vhost&lt;&#x2F;span&gt;&lt;span&gt; { &lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;jonijunni.labra.local&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;                    priority &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;20&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;                    port &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;80&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;                    docroot &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&#x2F;home&#x2F;jonijunni&#x2F;public_html&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;                    require &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; User&lt;&#x2F;span&gt;&lt;span&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;jonijunni&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;            apache::vhost&lt;&#x2F;span&gt;&lt;span&gt; { &lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;synkkasiiseli.labra.local&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;                    priority &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;20&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;                    port &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;80&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;                    docroot &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&#x2F;home&#x2F;synkkasiiseli&#x2F;public_html&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;                    require &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; User&lt;&#x2F;span&gt;&lt;span&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;synkkasiiseli&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;            user::user&lt;&#x2F;span&gt;&lt;span&gt; { &lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;jonijunni&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;                    username &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;jonijunni&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;            user::user&lt;&#x2F;span&gt;&lt;span&gt; { &lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;synkkasiiseli&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;                    username &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;synkkasiiseli&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;            include&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#E36209, #FFAB70);&quot;&gt; mysql&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;After that I deployed the virtual machine:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;vagrant up&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;creating-a-puppet-test-environment-based-on-production-server-part-1&#x2F;vagrant-deploy-success.png&quot; alt=&quot;vagrant-deploy-success&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Finally I tested with my browser that the virtual hosts work:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;creating-a-puppet-test-environment-based-on-production-server-part-1&#x2F;virtualhosts-work-vagrant.png&quot; alt=&quot;virtualhosts-work-vagrant&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;For the domain name to work you need to have the name configured on the DNS-server on your network or in your hosts-file.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;commiting-to-git-repository&quot;&gt;Commiting to Git repository&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; add&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; .&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; commit&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; pull&lt;&#x2F;span&gt;&lt;span&gt; &amp;amp;&amp;amp;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt; git&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; push&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;git-log&quot;&gt;Git Log&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;lt;pre class=&amp;quot;wp-code-highlight prettyprint&amp;quot;&amp;gt;commit 2746c1444cd568594829fa59c3ed958e6994d5a2&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Author: Joni Junni &amp;lt;joni@xenon.(none)&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Date:   Mon Dec 9 10:01:34 2013 +0200&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Fixed apt-get update problem&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;commit 5c51013b74d0a8505b1d4befbb464ff3cc2105ad&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Author: Joni Junni &amp;lt;joni@xenon.(none)&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Date:   Mon Dec 9 09:16:15 2013 +0200&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Fixed thingies&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;commit e948a7c53e69acec097e0396a59259dff0c5d34f&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Author: Joni Junni &amp;lt;joni@xenon.(none)&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Date:   Sat Dec 7 12:57:35 2013 +0200&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Working web1 server with name resolving&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;commit a5eed82397955ecf7bccda1eeca1c8be7e468a5e&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Author: Joni Junni &amp;lt;joni@xenon.(none)&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Date:   Sat Dec 7 12:23:03 2013 +0200&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Committing a new Vagrant project&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;moving-the-repo-to-master-server&quot;&gt;Moving the repo to master server&lt;&#x2F;h2&gt;
&lt;p&gt;I moved my project to a remote server for easier deployment.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;Things to run on the remote server&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;mkdir&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; vhost.git&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;cd&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; vhost.git&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; init&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; -&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;-bare&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; -&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;-shared&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;strong&gt;Things to do on the local repository&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; remote&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; add&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; origin&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; ssh:&#x2F;&#x2F;joni@xenon.local&#x2F;home&#x2F;joni&#x2F;vhost.git&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; push&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; origin&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; master&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; branch&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; -&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;-set-upstream&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; master&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; origin&#x2F;master&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; pull&lt;&#x2F;span&gt;&lt;span&gt; &amp;amp;&amp;amp;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt; git&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; push&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;creating-a-puppet-test-environment-based-on-production-server-part-1&#x2F;moving-repo-to-server.png&quot; alt=&quot;moving-repo-to-server&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;Cloning the repo to other machines&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;p&gt;I cloned the repo to my development machine:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git clone ssh:&#x2F;&#x2F;joni@192.168.2.7&#x2F;home&#x2F;joni&#x2F;gitrepo&#x2F;vhost.git&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Muistilista&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Ympäristön rakennus vagrant&lt;&#x2F;li&gt;
&lt;li&gt;Apachen asennus&lt;&#x2F;li&gt;
&lt;li&gt;Vhostin luominen&lt;&#x2F;li&gt;
&lt;li&gt;Nameresolving?&lt;&#x2F;li&gt;
&lt;li&gt;sivustokohtaiset käyttäjät&lt;&#x2F;li&gt;
&lt;li&gt;Tietokantapalvelimen asennus&lt;&#x2F;li&gt;
&lt;li&gt;Mysql kantojen lisääminen&lt;&#x2F;li&gt;
&lt;li&gt;Varnishin asennus ja konffaus&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h1 id=&quot;sources&quot;&gt;Sources&lt;&#x2F;h1&gt;
&lt;ul&gt;
&lt;li&gt;Tero Karvinen: Linux Centralized Management course – Using Git lecture (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2013&#x2F;aikataulu-%E2%80%93-linuxin-keskitetty-hallinta-%E2%80%93-ict4tn011-4-syksylla-2013&quot;&gt;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2013&#x2F;aikataulu-%E2%80%93-linuxin-keskitetty-hallinta-%E2%80%93-ict4tn011-4-syksylla-2013&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Git from Offline to Network – Tero Karvinen (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2012&#x2F;git-from-offline-to-network&quot;&gt;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2012&#x2F;git-from-offline-to-network&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Setting up BIND9 (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;jack-brennan.com&#x2F;dns-with-bind9-on-debian-part-22&#x2F;&quot;&gt;http:&#x2F;&#x2F;jack-brennan.com&#x2F;dns-with-bind9-on-debian-part-22&#x2F;&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Learning Puppet – Defined types (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;docs.puppetlabs.com&#x2F;learning&#x2F;definedtypes.html&quot;&gt;http:&#x2F;&#x2F;docs.puppetlabs.com&#x2F;learning&#x2F;definedtypes.html&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Apache: Name-based Virtual Host support (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;httpd.apache.org&#x2F;docs&#x2F;2.2&#x2F;vhosts&#x2F;name-based.html&quot;&gt;https:&#x2F;&#x2F;httpd.apache.org&#x2F;docs&#x2F;2.2&#x2F;vhosts&#x2F;name-based.html&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Linux project: Setting up Vagrant development environment, project wrap-up</title>
        <published>2013-12-03T00:00:00+00:00</published>
        <updated>2013-12-03T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/school/linux-project/setting-up-vagrant-development-environment-project-wrap-up/"/>
        <id>/school/linux-project/setting-up-vagrant-development-environment-project-wrap-up/</id>
        
        <content type="html" xml:base="/school/linux-project/setting-up-vagrant-development-environment-project-wrap-up/">&lt;p&gt;First I installed Vagrant on the testing server:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; apt-get&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; update&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; apt-get&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; install&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; vagrant&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Then I created a project directory to test the environment and initiated a Vagrantfile to it:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;mkdir&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; -&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;p&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; ~&#x2F;projects&#x2F;linuxtest&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;vagrant&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; init&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I added the following text to the Vagrantfile:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;ruby&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;Vagrant&lt;&#x2F;span&gt;&lt;span&gt;::&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;Config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;run&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; do&lt;&#x2F;span&gt;&lt;span&gt; |&lt;&#x2F;span&gt;&lt;span&gt;config&lt;&#x2F;span&gt;&lt;span&gt;|&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;vm&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;define&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; :&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;web1&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; do&lt;&#x2F;span&gt;&lt;span&gt; |&lt;&#x2F;span&gt;&lt;span&gt;apache_config&lt;&#x2F;span&gt;&lt;span&gt;|&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                apache_config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;vm&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;box&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;precise64&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                apache_config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;vm&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;box_url&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;http:&#x2F;&#x2F;files.vagrantup.com&#x2F;precise64.box&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                apache_config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;vm&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;host_name&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;web1&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                apache_config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;vm&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;network&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; :&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;bridged&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; :&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;bridge&lt;&#x2F;span&gt;&lt;span&gt; =&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;eth1&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;        end&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;vm&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;define&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; :&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;db1&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; do&lt;&#x2F;span&gt;&lt;span&gt; |&lt;&#x2F;span&gt;&lt;span&gt;mysql_config&lt;&#x2F;span&gt;&lt;span&gt;|&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                mysql_config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;vm&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;box&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;precise64&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                mysql_config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;vm&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;box_url&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;http:&#x2F;&#x2F;files.vagrantup.com&#x2F;precise64.box&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                mysql_config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;vm&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;host_name&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;db1&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                mysql_config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;vm&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;network&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; :&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;bridged&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; :&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;bridge&lt;&#x2F;span&gt;&lt;span&gt; =&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;eth1&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;        end&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;end&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;strong&gt;WARNING!&lt;&#x2F;strong&gt; If you configure your virtual machines in bridged mode, please make sure that you define a good password for the vagrant user!&lt;&#x2F;p&gt;
&lt;p&gt;The Vagrantfile defines the creation of two VMs. One machine for Apache and another for databases. I defined the network to be in bridged mode on the eth1 interface. The host_name line defines a hostname automatically for both machines.&lt;&#x2F;p&gt;
&lt;p&gt;Then I created the VMs:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;vagrant up&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-project&#x2F;setting-up-vagrant-development-environment-project-wrap-up&#x2F;linuxtest-up.png&quot; alt=&quot;linuxtest-up&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;After Vagrant created the machines, I installed avahi-utils and apache2 on the web1 VM:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo apt-get install avahi-utils apache2&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I installed Avahi for easy name resolving, as I don’t have a working DNS server on my network. I tested that both of them installed correctly and is working:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-project&#x2F;setting-up-vagrant-development-environment-project-wrap-up&#x2F;working-web1.png&quot; alt=&quot;working-web1&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;project-wrap-up&quot;&gt;Project wrap-up&lt;&#x2F;h3&gt;
&lt;p&gt;We started our project by listing a few of the virtualization platforms and we selected three of them for testing the most suitable system to replace the ESXi server platform. After we tested the three systems we selected two of them, Vagrant and VirtualBox, for the final solution. Vagrant will be used on projects involving Linux-based VMs and GUI-version of VirtualBox is used to deploy and test Windows VMs.&lt;&#x2F;p&gt;
&lt;p&gt;In the future we will be using Puppet for automating the installation of needed programs for Vagrant VMs, as this was not a task in this project.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;sources&quot;&gt;Sources&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;Vagrant Docs for version 1.0.1 (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;docs-v1.vagrantup.com&#x2F;v1&#x2F;docs&#x2F;index.html&quot;&gt;http:&#x2F;&#x2F;docs-v1.vagrantup.com&#x2F;v1&#x2F;docs&#x2F;index.html&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Linux project: Testing Virtualbox on Xubuntu 12.04</title>
        <published>2013-12-02T00:00:00+00:00</published>
        <updated>2013-12-02T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/school/linux-project/testing-virtualbox-on-xubuntu-12-04/"/>
        <id>/school/linux-project/testing-virtualbox-on-xubuntu-12-04/</id>
        
        <content type="html" xml:base="/school/linux-project/testing-virtualbox-on-xubuntu-12-04/">&lt;p&gt;The third candidate for replacing my current ESXi testing environment is plain Virtualbox.&lt;&#x2F;p&gt;
&lt;p&gt;For this test, I installed Xubuntu 12.04 on my development machine for testing purposes.&lt;&#x2F;p&gt;
&lt;p&gt;First I installed Virtualbox from repos:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; apt-get&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; update&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; apt-get&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; install&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; virtualbox&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;After the installation I needed to restart the machine to get the kernel driver functioning.&lt;&#x2F;p&gt;
&lt;p&gt;After the reboot I started Virtualbox by opening it from the main menu:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-project&#x2F;testing-virtualbox-on-xubuntu-12-04&#x2F;main-screen.png&quot; alt=&quot;main-screen&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;testing-debian-on-virtualbox&quot;&gt;Testing Debian on Virtualbox&lt;&#x2F;h3&gt;
&lt;p&gt;I created a new virtual machine by selecting “New”. I created a Debian test machine with the following settings:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Name: deb-test1&lt;&#x2F;li&gt;
&lt;li&gt;OS Type: Debian 7.2&lt;&#x2F;li&gt;
&lt;li&gt;RAM: 2Gb&lt;&#x2F;li&gt;
&lt;li&gt;HDD: 8Gd&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;I downloaded Debian 7.2 netinstaller-ISO for testing. I attached the ISO image to the VM:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-project&#x2F;testing-virtualbox-on-xubuntu-12-04&#x2F;diskimg.png&quot; alt=&quot;diskimg&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;And finally started the VM to see if it works:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-project&#x2F;testing-virtualbox-on-xubuntu-12-04&#x2F;working-debian-vm.png&quot; alt=&quot;working-debian-vm&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;So, Debian runs nicely on Virtualbox, but is quite unwieldy without Vagrant automatizing the deployment.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;testing-windows-guest-on-virtualbox&quot;&gt;Testing Windows guest on VirtualBox&lt;&#x2F;h3&gt;
&lt;p&gt;I also tested Virtualbox with a Windows 2008R2 guest with the following specs on the VM:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Name: win-test&lt;&#x2F;li&gt;
&lt;li&gt;OS Type: Windows 2008 (64 bit)&lt;&#x2F;li&gt;
&lt;li&gt;RAM: 10Gb&lt;&#x2F;li&gt;
&lt;li&gt;HDD: 25Gb&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;After I attached the ISO image to the VM and started it, I got a working Windows VM:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-project&#x2F;testing-virtualbox-on-xubuntu-12-04&#x2F;working-win-server.png&quot; alt=&quot;working-win-server&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;conclusion&quot;&gt;Conclusion&lt;&#x2F;h3&gt;
&lt;p&gt;Virtualbox is a simple way to run virtual machines graphically. For our purposes we will be using Vagrant and Virtualbox together as the final development environment. We will run Linux boxes in Vagrant and Windows machines on Virtualbox.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;sources&quot;&gt;Sources&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;Oracle Virtualbox Official site (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;www.virtualbox.org&#x2F;&quot;&gt;https:&#x2F;&#x2F;www.virtualbox.org&#x2F;&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt; &lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Linux project: Setting up Vagrant on Ubuntu 12.04</title>
        <published>2013-12-01T00:00:00+00:00</published>
        <updated>2013-12-01T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/school/linux-project/setting-up-vagrant-on-ubuntu-12-04/"/>
        <id>/school/linux-project/setting-up-vagrant-on-ubuntu-12-04/</id>
        
        <content type="html" xml:base="/school/linux-project/setting-up-vagrant-on-ubuntu-12-04/">&lt;p&gt;Text author: Aleksi Kulmala&lt;&#x2F;p&gt;
&lt;h3 id=&quot;installing-vagrant-and-virtualbox&quot;&gt;Installing Vagrant and Virtualbox&lt;&#x2F;h3&gt;
&lt;p&gt;First up when starting this project you have to install Virtualbox first.&lt;&#x2F;p&gt;
&lt;p&gt;You can do it easily from terminal using command:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo apt-get install virtualbox&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;After that you can download the right package for your platform from the Vagrant homepage. You can also install it from command prompt using command:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo apt-get install vagrant&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;When you have installed the package you can go straight to the command prompt. To get Vagrant up and running run these commands:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;vagrant init precise http:&#x2F;&#x2F;files.vagrantup.com&#x2F;precise32.boxvagrant up&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Now you have a running virtual machine in Virtualbox. You can connect to it using:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;vagrant ssh&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h3 id=&quot;creating-a-vagrant-project&quot;&gt;Creating a Vagrant project&lt;&#x2F;h3&gt;
&lt;p&gt;When you are setting your project up Vagrant has built-in command to get all working first you have to create directory for it:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mkdir vagrant_test&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;cd vagrant_test&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;vagrant init&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Vagrant uses “boxes” this means you don’t have to build a virtual machine from scratch, instead you use a base images to clone virtual machines. Now we have to add the boxes by using simple command:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;vagrant box add precise32 http:&#x2F;&#x2F;files.vagrantup.com&#x2F;precise32.box&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Now that we have done all the setup for the virtual machine we can run a command to start using it&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;vagrant up&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This command will create us a virtual machine running Ubuntu. Now we can log in to it using SSH:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;vagrant ssh&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Now we have a real virtual machine in our hands and we can do whatever we want with it. If you want to destroy the virtual machine you can run the command:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;vagrant destroy&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Vagrant has this great feature “synced folders” Vagrant will automatically sync your files to and from the virtual machine.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;sources&quot;&gt;Sources&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;Vagrant Getting Started Guide (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;docs.vagrantup.com&#x2F;v2&#x2F;getting-started&#x2F;index.html&quot;&gt;http:&#x2F;&#x2F;docs.vagrantup.com&#x2F;v2&#x2F;getting-started&#x2F;index.html&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Linux project: Installing, configuring and testing OpenStack on Ubuntu Server 12.04.3</title>
        <published>2013-11-25T00:00:00+00:00</published>
        <updated>2013-11-25T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/school/linux-project/installing-configuring-and-testing-openstack-on-ubuntu-server-12-04-3/"/>
        <id>/school/linux-project/installing-configuring-and-testing-openstack-on-ubuntu-server-12-04-3/</id>
        
        <content type="html" xml:base="/school/linux-project/installing-configuring-and-testing-openstack-on-ubuntu-server-12-04-3/">&lt;p&gt;The OpenStack platform consists of 9 components, that provide different services to the platform:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Dashboard Service (Horizon) – Service provides a front-end to OpenStack, that allows users to configure the OpenStack platform.&lt;&#x2F;li&gt;
&lt;li&gt;Compute Service (Nova) – Provides the platform that hosts the virtual machines&lt;&#x2F;li&gt;
&lt;li&gt;Networking Service (Neutron) – Provides networking capabilities to the platform&lt;&#x2F;li&gt;
&lt;li&gt;Object Storage Service (Swift) –&lt;&#x2F;li&gt;
&lt;li&gt;Block Storage Service (Cinder) – Provides block storage (Virtual HDDs) to virtual machines.&lt;&#x2F;li&gt;
&lt;li&gt;Identity Service (Keystone) – Does the authentication and authorization for the platform services.&lt;&#x2F;li&gt;
&lt;li&gt;Image Service (Glance) – Provides images to the platform.&lt;&#x2F;li&gt;
&lt;li&gt;Metering&#x2F;Monitoring Service (Ceilometer) – Monitors the platform services.&lt;&#x2F;li&gt;
&lt;li&gt;Orchestration Service (Heat) – Provides orchestration capabilities to the platform.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;I will install only Nova, Horizon, Keystone and Glance services for my test environment.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;installation&quot;&gt;Installation&lt;&#x2F;h3&gt;
&lt;p&gt;Installation is quite time consuming, It took me a day to get the system running properly. I used this guide to get the system installed and running: &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;docs.openstack.org&#x2F;havana&#x2F;install-guide&#x2F;install&#x2F;apt&#x2F;content&#x2F;&quot;&gt;http:&#x2F;&#x2F;docs.openstack.org&#x2F;havana&#x2F;install-guide&#x2F;install&#x2F;apt&#x2F;content&#x2F;&lt;&#x2F;a&gt; I will not be go through the installation steps because they are documented on this guide well enough to get the system running.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;testing&quot;&gt;Testing&lt;&#x2F;h3&gt;
&lt;p&gt;After I got the system installed, opened the dashboard with my browser:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-project&#x2F;installing-configuring-and-testing-openstack-on-ubuntu-server-12-04-3&#x2F;openstack-login-screen.png&quot; alt=&quot;openstack-login-screen&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;First I uploaded a Debian 7.2.0 Netinstaller ISO image from my local machine:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-project&#x2F;installing-configuring-and-testing-openstack-on-ubuntu-server-12-04-3&#x2F;openstack-upload-image.png&quot; alt=&quot;openstack-upload-image&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;I created a Debian test VM from the GUI with the following settings:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-project&#x2F;installing-configuring-and-testing-openstack-on-ubuntu-server-12-04-3&#x2F;openstack-create-instance.png&quot; alt=&quot;openstack-create-instance&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;After launching the VM, I opened the console to the VM:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-project&#x2F;installing-configuring-and-testing-openstack-on-ubuntu-server-12-04-3&#x2F;openstack-instance-console.png&quot; alt=&quot;openstack-instance-console&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;I now have a running OpenStack with functional Debian VM!&lt;&#x2F;p&gt;
&lt;h3 id=&quot;conclusion&quot;&gt;Conclusion&lt;&#x2F;h3&gt;
&lt;p&gt;OpenStack is quite massive piece of software, which is aimed for using in cloud hosting services with fair amount of hardware to virtualize the instances. It can be run on single server node for development and testing purposes, but it is not recommended for production use. For my use case it might be too large configuration.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;windows-guest-compatibility&quot;&gt;Windows guest compatibility&lt;&#x2F;h3&gt;
&lt;p&gt;OpenStack can host Windows guest VM’s, but based on my research they are quite complicated to get them up and running on the platform. If you want to get Windows instances running on OpenStack, I recommend watching this presentation:&lt;&#x2F;p&gt;
&lt;h3 id=&quot;sources&quot;&gt;Sources&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;OpenStack Installation Guide for Ubuntu Server 12.04 (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;docs.openstack.org&#x2F;havana&#x2F;install-guide&#x2F;install&#x2F;apt&#x2F;content&#x2F;&quot;&gt;http:&#x2F;&#x2F;docs.openstack.org&#x2F;havana&#x2F;install-guide&#x2F;install&#x2F;apt&#x2F;content&#x2F;&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Windows drivers (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;docs.openstack.org&#x2F;image-guide&#x2F;content&#x2F;windows-image.html&quot;&gt;http:&#x2F;&#x2F;docs.openstack.org&#x2F;image-guide&#x2F;content&#x2F;windows-image.html&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Windows on OpenStack: Best Practices and Pitfalls (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=JMDxpAmR_XQ&quot;&gt;https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=JMDxpAmR_XQ&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Creating a Windows Image on OpenStack (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;blog.gridcentric.com&#x2F;bid&#x2F;297627&#x2F;Creating-a-Windows-Image-on-OpenStack&quot;&gt;http:&#x2F;&#x2F;blog.gridcentric.com&#x2F;bid&#x2F;297627&#x2F;Creating-a-Windows-Image-on-OpenStack&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Linux centralized management: Installing SSH with Puppet parameterized classes</title>
        <published>2013-11-24T00:00:00+00:00</published>
        <updated>2013-11-24T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/school/linux-centralized-management/installing-ssh-with-puppet-parameterized-classes/"/>
        <id>/school/linux-centralized-management/installing-ssh-with-puppet-parameterized-classes/</id>
        
        <content type="html" xml:base="/school/linux-centralized-management/installing-ssh-with-puppet-parameterized-classes/">&lt;p&gt;First, I created the default module structure:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;mkdir&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; -&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;p&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &#x2F;modules&#x2F;sshporttest&#x2F;manifests&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;mkdir&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; -&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;p&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &#x2F;modules&#x2F;sshporttest&#x2F;templates&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Then I created the init.pp file to manifests-directory:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;nano&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &#x2F;modules&#x2F;sshporttest&#x2F;manifests&#x2F;init.pp&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;And wrote the following settings to it:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;puppet&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;class&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt; sshporttest&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span&gt;$&lt;&#x2F;span&gt;&lt;span&gt;port&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; 22&lt;&#x2F;span&gt;&lt;span&gt;) &lt;&#x2F;span&gt;&lt;span&gt;{&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;        package&lt;&#x2F;span&gt;&lt;span&gt; { &lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;openssh-server&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;                ensure &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;installed&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;         file&lt;&#x2F;span&gt;&lt;span&gt; { &lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&#x2F;etc&#x2F;ssh&#x2F;sshd_config&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;                content &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; template&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;sshporttest&#x2F;sshd_config.erb&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;),&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;                require &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; Package&lt;&#x2F;span&gt;&lt;span&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;openssh-server&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;                notify &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; Service&lt;&#x2F;span&gt;&lt;span&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;ssh&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;        service&lt;&#x2F;span&gt;&lt;span&gt; { &lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;ssh&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;                ensure &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;running&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;                enable &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;true&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;                require &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; Package&lt;&#x2F;span&gt;&lt;span&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;openssh-server&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span&gt;,    &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;                hasstatus &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;false&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;                status &lt;&#x2F;span&gt;&lt;span&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&#x2F;etc&#x2F;init.d&#x2F;ssh status|grep running&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I added a parameter for port on the class line. This can be used on the class apply command, so that we can change the port to install SSH into.&lt;&#x2F;p&gt;
&lt;p&gt;I copied the default SSH config file to the templates directory:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;cp&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &#x2F;etc&#x2F;ssh&#x2F;sshd_config&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &#x2F;home&#x2F;joni&#x2F;puppet&#x2F;modules&#x2F;sshporttest&#x2F;templates&#x2F;sshd_config.erb&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;And edited the header to test if my module would work:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;installing-ssh-with-puppet-parameterized-classes&#x2F;sshd-test-edit.png&quot; alt=&quot;ssh-test-edit&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Finally, tested to run the module:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; puppet&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; apply&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; -&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;-modulepath&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; modules&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; -&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;e&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;class {&amp;quot;sshporttest&amp;quot;:}&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Then I checked that the &#x2F;etc&#x2F;ssh&#x2F;sshd_config file was modified:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;installing-ssh-with-puppet-parameterized-classes&#x2F;sshd-test-edit-worked.png&quot; alt=&quot;ssh-test-edit-worked&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;I edited the &#x2F;modules&#x2F;sshporttest&#x2F;templates&#x2F;sshd_config.erb file so it would take the port number from the class parameter:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;installing-ssh-with-puppet-parameterized-classes&#x2F;sshd-port-edit.png&quot; alt=&quot;sshd-port-edit&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Then I applied the module again with a parameter port =&amp;gt; 2222 to set the SSH port to 2222:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; puppet&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; apply&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; -&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;-modulepath&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; modules&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; -&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;e&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;class {&amp;quot;sshporttest&amp;quot;: port =&amp;gt; 2222}&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Finally, I tested that the port has changed:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;installing-ssh-with-puppet-parameterized-classes&#x2F;sshd-port-test-change.png&quot; alt=&quot;sshd-port-test-change&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;sources&quot;&gt;Sources&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;Learning Puppet – Class Parameters (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;docs.puppetlabs.com&#x2F;learning&#x2F;modules2.html&quot;&gt;http:&#x2F;&#x2F;docs.puppetlabs.com&#x2F;learning&#x2F;modules2.html&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Tero Karvinen: Linux Centralized Management Lecture 4 (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2013&#x2F;aikataulu-%E2%80%93-linuxin-keskitetty-hallinta-%E2%80%93-ict4tn011-4-syksylla-2013&quot;&gt;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2013&#x2F;aikataulu-%E2%80%93-linuxin-keskitetty-hallinta-%E2%80%93-ict4tn011-4-syksylla-2013&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Linux centralized management: Configuring Puppetmaster and client-server testing</title>
        <published>2013-11-17T00:00:00+00:00</published>
        <updated>2013-11-17T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/school/linux-centralized-management/configuring-puppetmaster-and-client-server-testing/"/>
        <id>/school/linux-centralized-management/configuring-puppetmaster-and-client-server-testing/</id>
        
        <content type="html" xml:base="/school/linux-centralized-management/configuring-puppetmaster-and-client-server-testing/">&lt;p&gt;Steps:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Install Vagrant and create VMs using a Vagrantfile&lt;&#x2F;li&gt;
&lt;li&gt;Setup Avahi and test connectivity between VMs&lt;&#x2F;li&gt;
&lt;li&gt;Install and configure Puppetmaster&lt;&#x2F;li&gt;
&lt;li&gt;Install and configure Puppet on client VMs&lt;&#x2F;li&gt;
&lt;li&gt;Configure modules to deploy from master VM&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;Installing Vagrant and creating Vagrantfile&lt;&#x2F;p&gt;
&lt;p&gt;I started by installing Vagrant to my development machine:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;sudo apt-get install vagrant&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Then I created a new project directory and created a Vagrantfile into it:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;mkdir&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; -&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;p&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; ~&#x2F;Projects&#x2F;puppetmaster&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;cd&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; ~&#x2F;Projects&#x2F;puppetmaster&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;nano&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; Vagrantfile&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I wrote this into the Vagrantfile:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;ruby&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;Vagrant&lt;&#x2F;span&gt;&lt;span&gt;::&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;Config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;run&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; do&lt;&#x2F;span&gt;&lt;span&gt; |&lt;&#x2F;span&gt;&lt;span&gt;config&lt;&#x2F;span&gt;&lt;span&gt;|&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;       config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;vm&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;define&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; :&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;puppetmaster&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; do&lt;&#x2F;span&gt;&lt;span&gt; |&lt;&#x2F;span&gt;&lt;span&gt;master_config&lt;&#x2F;span&gt;&lt;span&gt;|&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;               master_config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;vm&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;box&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;puppetmaster&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;               master_config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;vm&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;box_url&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;http:&#x2F;&#x2F;files.vagrantup.com&#x2F;precise32.box&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;               config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;vm&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;network&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; :&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;bridged&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;       end&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;       config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;vm&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;define&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; :&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;apache&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; do&lt;&#x2F;span&gt;&lt;span&gt; |&lt;&#x2F;span&gt;&lt;span&gt;apache_config&lt;&#x2F;span&gt;&lt;span&gt;|&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;               apache_config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;vm&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;box&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;apache&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;               apache_config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;vm&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;box_url&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;http:&#x2F;&#x2F;files.vagrantup.com&#x2F;precise32.box&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;               config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;vm&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;network&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; :&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;bridged&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;       end&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;       config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;vm&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;define&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; :&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;mysql&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; do&lt;&#x2F;span&gt;&lt;span&gt; |&lt;&#x2F;span&gt;&lt;span&gt;mysql_config&lt;&#x2F;span&gt;&lt;span&gt;|&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;               mysql_config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;vm&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;box&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;mysql&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;               mysql_config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;vm&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;box_url&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;http:&#x2F;&#x2F;files.vagrantup.com&#x2F;precise32.box&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;               config&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;vm&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;network&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; :&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;bridged&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;       end&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;end&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The code above tells Vagrant to create two virtual machine instances named “apache” and “mysql” from the default Ubuntu Lucid box. It will also make Vagrant to put the virtual machines into a bridged network, so the virtual machines vill get the IP straight from the physical network that the host machine is connected.&lt;&#x2F;p&gt;
&lt;p&gt;Finally, I created the virtual machines:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;vagrant up&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;p&gt;After about 5 minutes, I had three functional virtual machines:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;configuring-puppetmaster-and-client-server-testing&#x2F;vagrant-three-vms-150x150.png&quot; alt=&quot;vagrant-three-vms&quot; &#x2F;&gt;(vagrant-three-vms.png)&lt;&#x2F;p&gt;
&lt;p&gt;Configure the enviroment&lt;&#x2F;p&gt;
&lt;p&gt;To get the Puppetmaster working, it is needed that the virtual machines can connect to themselves and knows their hostnames. I needed to change the hostname in these files:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&#x2F;etc&#x2F;hostname&lt;&#x2F;li&gt;
&lt;li&gt;&#x2F;etc&#x2F;hosts&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;configuring-puppetmaster-and-client-server-testing&#x2F;changed-hostname-150x150.png&quot; alt=&quot;changed-hostname&quot; &#x2F;&gt;(changed-hostname.png)
&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;configuring-puppetmaster-and-client-server-testing&#x2F;steps-150x150.png&quot; alt=&quot;steps&quot; &#x2F;&gt;(steps.png)&lt;&#x2F;p&gt;
&lt;p&gt;After I changed the the hostname, I installed avahi-utils for the FQDN-names to work(eq. puppetmaster.local). Lastly i restarted the VM so the settings would come live. This step needs to be done all of the virtual machines, as I do not have a functional DNS-server in my environment.&lt;&#x2F;p&gt;
&lt;p&gt;Installing and configuring puppetmaster&lt;&#x2F;p&gt;
&lt;p&gt;I created three virtual machines in the previous step: puppetmaster, apache and mysql. First, I will install and configure Puppetmaster to the puppetmaster-machine:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;vagrant ssh puppetmaster&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Install Puppetmaster:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; apt-get&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; update&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; apt-get&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; install&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; puppetmaster&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Configure Puppetmaster&lt;&#x2F;p&gt;
&lt;p&gt;As in Tero’s tutorial, I needed to stop the service, remove created certificates, edit the config file to match my FQDN an restart the service:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; service&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; puppetmaster&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; stop&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; rm&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; -&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;r&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &#x2F;var&#x2F;lib&#x2F;puppet&#x2F;ssl&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; nano&lt;&#x2F;span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; &#x2F;etc&#x2F;puppet&#x2F;puppet.conf&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;In the puppet.conf I needed to add the dns_alt_names line to the configuration file:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;configuring-puppetmaster-and-client-server-testing&#x2F;puppet.conf-editing.png&quot;&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;configuring-puppetmaster-and-client-server-testing&#x2F;puppet.conf-editing-150x150.png&quot; alt=&quot;puppet.conf-editing&quot; &#x2F;&gt;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;sudo service puppetmaster start&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;p&gt;After that it shows the newly created certificates:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;sudo ls &#x2F;var&#x2F;lib&#x2F;puppet&#x2F;ssl&#x2F;certs&#x2F;&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;configuring-puppetmaster-and-client-server-testing&#x2F;puppetmaster-certificates.png&quot;&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;configuring-puppetmaster-and-client-server-testing&#x2F;puppetmaster-certificates-150x150.png&quot; alt=&quot;puppetmaster-certificates&quot; &#x2F;&gt;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Configuring the client machines&lt;&#x2F;p&gt;
&lt;p&gt;Install puppet:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;sudo apt-get install puppet&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Edit the &#x2F;etc&#x2F;puppet&#x2F;puppet.conf and add the server FQDN to it:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;sudo nano &#x2F;etc&#x2F;puppet&#x2F;puppet.conf&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;configuring-puppetmaster-and-client-server-testing&#x2F;agent-config.png&quot;&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;configuring-puppetmaster-and-client-server-testing&#x2F;agent-config-150x150.png&quot; alt=&quot;agent-config&quot; &#x2F;&gt;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Because Puppet is not started automatically by default, we need to edit the &#x2F;etc&#x2F;default&#x2F;puppet file and set START=yes:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;configuring-puppetmaster-and-client-server-testing&#x2F;puppet-autostart-config.png&quot;&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;configuring-puppetmaster-and-client-server-testing&#x2F;puppet-autostart-config-150x150.png&quot; alt=&quot;puppet-autostart-config&quot; &#x2F;&gt;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;After doing the configuration, restart the Puppet agent:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;sudo service puppet restart&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Accepting the client machine certificates&lt;&#x2F;p&gt;
&lt;p&gt;Go to the puppetmaster VM:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;sudo puppet cert --list&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;sources&quot;&gt;Sources&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;Vagrant Documentation – Multi-VM environments (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;docs-v1.vagrantup.com&#x2F;v1&#x2F;docs&#x2F;multivm.html&quot;&gt;http:&#x2F;&#x2F;docs-v1.vagrantup.com&#x2F;v1&#x2F;docs&#x2F;multivm.html&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Tero Karvinen: Linux centralized management lecture 3 (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2013&#x2F;aikataulu-%E2%80%93-linuxin-keskitetty-hallinta-%E2%80%93-ict4tn011-4-syksylla-2013&quot;&gt;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2013&#x2F;aikataulu-%E2%80%93-linuxin-keskitetty-hallinta-%E2%80%93-ict4tn011-4-syksylla-2013&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;PuppetMaster on Ubuntu 12.04 (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2012&#x2F;puppetmaster-on-ubuntu-12-04&quot;&gt;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2012&#x2F;puppetmaster-on-ubuntu-12-04&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Linux centralized management: Installing PuppetMaster and configuring client-server setup on Debian 7</title>
        <published>2013-11-17T00:00:00+00:00</published>
        <updated>2013-11-17T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/school/linux-centralized-management/installing-puppetmaster-and-configuring-client-server-setup-on-debian-7/"/>
        <id>/school/linux-centralized-management/installing-puppetmaster-and-configuring-client-server-setup-on-debian-7/</id>
        
        <content type="html" xml:base="/school/linux-centralized-management/installing-puppetmaster-and-configuring-client-server-setup-on-debian-7/">&lt;p&gt;I started by creating three clones of my default Debian VM in VMWare Fusion. I named them &lt;strong&gt;debian1-master&lt;&#x2F;strong&gt;, &lt;strong&gt;debian1&lt;&#x2F;strong&gt; and &lt;strong&gt;debian2&lt;&#x2F;strong&gt;. Debian1-master will be the master server with Puppetmaster and the two others will be client machines.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;setting-up-name-resolving&quot;&gt;Setting up name resolving&lt;&#x2F;h3&gt;
&lt;p&gt;Because there is no functional DNS server on my network, I will be using Avahi to get the VMs to resolve each other with their hostnames. The VMs need to find themselves with names, because Puppet uses those names to check the identity of the clients. I did the following steps on every machine:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;sudo hostname “machine name” (debian1-master, debian1, debian2)&lt;&#x2F;li&gt;
&lt;li&gt;sudo nano &#x2F;etc&#x2F;hostname&lt;&#x2F;li&gt;
&lt;li&gt;sudo nano &#x2F;etc&#x2F;hosts&lt;&#x2F;li&gt;
&lt;li&gt;sudo apt-get install avahi-utils&lt;&#x2F;li&gt;
&lt;li&gt;sudo shutdown -r now&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;After these steps, I tested with ping that the master server would see the client machines:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ping debian1.local&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ping debian2.local&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;installing-puppetmaster-and-configuring-client-server-setup-on-debian-7&#x2F;puppetmaster-ping.png&quot; alt=&quot;puppetmaster-ping&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;I also tested that the client machines would see the master server:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;installing-puppetmaster-and-configuring-client-server-setup-on-debian-7&#x2F;debian1-pinging-master.png&quot; alt=&quot;debian1-pinging-master&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;installing-puppetmaster-and-configuring-client-server-setup-on-debian-7&#x2F;debian2-pinging-master.png&quot; alt=&quot;debian2-pinging-master&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;installing-puppetmaster&quot;&gt;Installing Puppetmaster&lt;&#x2F;h3&gt;
&lt;p&gt;On the master server I installed Puppetmaster and configured it:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo apt-get install puppetmaster&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo service puppetmaster stop&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo rm -r &#x2F;var&#x2F;lib&#x2F;puppet&#x2F;ssl&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;In the last line we are deleting the invalid certificates that we can create the valid ones. Next I added the &lt;strong&gt;dns_alt_names&lt;&#x2F;strong&gt; directive to the &lt;strong&gt;&#x2F;etc&#x2F;puppet&#x2F;puppet.conf&lt;&#x2F;strong&gt;-file as &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2012&#x2F;puppetmaster-on-ubuntu-12-04&quot;&gt;Tero’s tutorial&lt;&#x2F;a&gt; suggests:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;installing-puppetmaster-and-configuring-client-server-setup-on-debian-7&#x2F;puppet.conf-edit.png&quot; alt=&quot;puppet-conf-edit&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Then I just started the Puppetmaster:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo service puppetmaster start&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h3 id=&quot;configuring-client-machines&quot;&gt;Configuring client machines&lt;&#x2F;h3&gt;
&lt;p&gt;On the client machines you need to install Puppet, configure it to connect to server and set it to start automatically:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo apt-get install puppet&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo nano &#x2F;etc&#x2F;puppet&#x2F;puppet.conf&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I added the following to the config file:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[agent]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;server = debian1-master.local&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;installing-puppetmaster-and-configuring-client-server-setup-on-debian-7&#x2F;puppet-agent-config.png&quot; alt=&quot;puppet-agent-config&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Then I edited the &lt;strong&gt;&#x2F;etc&#x2F;default&#x2F;puppet&lt;&#x2F;strong&gt; file and set the START=no to yes:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;installing-puppetmaster-and-configuring-client-server-setup-on-debian-7&#x2F;start-to-yes.png&quot; alt=&quot;start-to-yes&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;After making the configuration changes I restarted the Puppet agent:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo service puppet restart&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h3 id=&quot;sign-the-client-sertificates&quot;&gt;Sign the client sertificates&lt;&#x2F;h3&gt;
&lt;p&gt;On the master server you need to sign the client machine certificates. This is the method Puppet checks that the client machines are allowed to receive orders from the server. You can list the certificates waiting for approval on the master server with this command:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo puppet cert --list&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;You can sign or approve the certs with this command:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo puppet cert --sign &amp;quot;machine name&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;installing-puppetmaster-and-configuring-client-server-setup-on-debian-7&#x2F;puppet-sign-certs.png&quot; alt=&quot;puppet-sign-certs&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;deploying-a-test-module&quot;&gt;Deploying a test module&lt;&#x2F;h3&gt;
&lt;p&gt;Start by creating a module directory structure in &lt;strong&gt;&#x2F;etc&#x2F;puppet&#x2F;modules&lt;&#x2F;strong&gt; directory:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo mkdir -p hellotest&#x2F;manifests&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo nano hellotest&#x2F;manifests&#x2F;init.pp&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I wrote this to the &lt;strong&gt;init.pp&lt;&#x2F;strong&gt; file:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;class hellotest {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        file {&amp;#39;&#x2F;tmp&#x2F;hellotest&amp;#39;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                content =&amp;gt; &amp;quot;testing from master\n&amp;quot;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;After saving the module I created a new &lt;strong&gt;site.pp&lt;&#x2F;strong&gt; file that defines what the Puppetmaster should do to the environment:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo nano &#x2F;etc&#x2F;puppet&#x2F;manifests&#x2F;site.pp&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I wrote this to the site.pp file:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;class {&amp;#39;hellotest&amp;#39;:}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This tells Puppetmaster to deploy the created &lt;strong&gt;hellotest-module&lt;&#x2F;strong&gt; to all client machines.&lt;&#x2F;p&gt;
&lt;p&gt;After this I reloaded the Puppet agent on client machines, so they would fetch the new configuration from the master server:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo service puppet restart&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;And the client machines should have the &lt;strong&gt;&#x2F;tmp&#x2F;hellotest&lt;&#x2F;strong&gt;-file in them ordered by the testing module:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;installing-puppetmaster-and-configuring-client-server-setup-on-debian-7&#x2F;hellotest-moduletest.png&quot; alt=&quot;hellotest-moduletest&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;configure-nodes&quot;&gt;Configure nodes&lt;&#x2F;h3&gt;
&lt;p&gt;To get the PuppetMaster to configure different modules to different clients, you need to use node-marking in th site.pp file. I edited the site.pp file to look like this:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;node &amp;#39;debian1.localdomain&amp;#39; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        class {&amp;#39;install-apache&amp;#39;:}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;node &amp;#39;debian2.localdomain&amp;#39; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        class {&amp;#39;hellotest&amp;#39;:}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;(The install-apache-module is a module that I have done in a &lt;a href=&quot;&#x2F;blog&#x2F;installing-apache2-and-userdir-with-puppet-module&#x2F;&quot; title=&quot;Installing and configuring Apache2 with Puppet module&quot;&gt;earlier post&lt;&#x2F;a&gt;.)&lt;&#x2F;p&gt;
&lt;p&gt;After saving the configuration, I deleted the &lt;strong&gt;&#x2F;tmp&#x2F;hellotest&lt;&#x2F;strong&gt;-file from both client machines to see if the node setting is working. Then I just restarted the Puppet agent on both machines and then tested if there was the hellotest-file on the machines:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;installing-puppetmaster-and-configuring-client-server-setup-on-debian-7&#x2F;hellotest-nodes.png&quot; alt=&quot;hellotest-nodes&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Then I tested if Apache was only installed in debian1-machine:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;installing-puppetmaster-and-configuring-client-server-setup-on-debian-7&#x2F;apache-module-testing.png&quot; alt=&quot;apache-module-testing&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;conclusion&quot;&gt; Conclusion&lt;&#x2F;h3&gt;
&lt;p&gt;Puppetmaster is quite complicated thing to set up, but is very rewarding when the system works as intended.&lt;&#x2F;p&gt;
&lt;p&gt;I originally started to work on this assignment using Vagrant, but instead ended up using virtual machines on my local machine as setting a Vagrant environment took too much time and effort to get running smoothly.&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;On Lucid32 boxes the Puppet agents didn’t contact to the master server for certificate signing. The VMs could see each other and pinging worked between the machines.&lt;&#x2F;li&gt;
&lt;li&gt;Once I got the Precise32 boxes working on Vagrant, for some reason those VMs would not get in to bridged network as I described in the Vagrantfile.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;sources&quot;&gt;Sources&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;Learning Puppet – Basic Agent&#x2F;Master Puppet (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;docs.puppetlabs.com&#x2F;learning&#x2F;agent_master_basic.html&quot;&gt;http:&#x2F;&#x2F;docs.puppetlabs.com&#x2F;learning&#x2F;agent_master_basic.html&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;PuppetMaster on Ubuntu 12.04 – Tero Karvinen (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2012&#x2F;puppetmaster-on-ubuntu-12-04&quot;&gt;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2012&#x2F;puppetmaster-on-ubuntu-12-04&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Tero Karvinen: Linux Centralized Management – PuppetMaster Lecture (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2013&#x2F;aikataulu-%E2%80%93-linuxin-keskitetty-hallinta-%E2%80%93-ict4tn011-4-syksylla-2013&quot;&gt;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2013&#x2F;aikataulu-%E2%80%93-linuxin-keskitetty-hallinta-%E2%80%93-ict4tn011-4-syksylla-2013&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Linux centralized management: Installing and configuring Apache2 with Puppet module</title>
        <published>2013-11-09T00:00:00+00:00</published>
        <updated>2013-11-09T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/school/linux-centralized-management/installing-apache2-and-userdir-with-puppet-module/"/>
        <id>/school/linux-centralized-management/installing-apache2-and-userdir-with-puppet-module/</id>
        
        <content type="html" xml:base="/school/linux-centralized-management/installing-apache2-and-userdir-with-puppet-module/">&lt;p&gt;I made a module to Puppet that installs and configures Apache2 package. I changed the default listening port for Apache from port 80 to port 8080 using the a template from a config file.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;installing-and-starting-apache-with-a-puppet-module&quot;&gt;Installing and starting Apache with a Puppet module&lt;&#x2F;h3&gt;
&lt;p&gt;First I created the usual module directory structure:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mkdir -p install-apache&#x2F;manifests&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nano install-apache&#x2F;manifests&#x2F;init.pp&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I wrote the following in the init-file:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;class install-apache {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	package {&amp;#39;apache2&amp;#39;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		ensure =&amp;gt; &amp;#39;present&amp;#39;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	service {&amp;#39;apache2&amp;#39;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		enable =&amp;gt; &amp;#39;true&amp;#39;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		ensure =&amp;gt; &amp;#39;running&amp;#39;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The following code checks that apache2 is installed, and if it is not, it will install it. It will also check that Apache is running. Next I applied the new module with the following command:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo puppet apply --modulepath modules&#x2F; -e &amp;#39;class {&amp;quot;install-apache&amp;quot;:}&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;installing-apache2-and-userdir-with-puppet-module&#x2F;install-apache-1.png&quot; alt=&quot;install-apache-1&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;After that I tested with my browser if Apache was installed and started:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;installing-apache2-and-userdir-with-puppet-module&#x2F;apache2-installed1.png&quot; alt=&quot;apache2-installed1&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;adding-a-modified-config-file&quot;&gt;Adding a modified config file&lt;&#x2F;h3&gt;
&lt;p&gt;First create a templates-directory to module root:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mkdir install-apache&#x2F;templates&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;cp &#x2F;etc&#x2F;apache2&#x2F;ports.conf modules&#x2F;install-apache&#x2F;templates&#x2F;ports.conf.erb&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I edited the template so that the default port for Apache would be 8080 instead of normal 80:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;installing-apache2-and-userdir-with-puppet-module&#x2F;apache-port-config.png&quot; alt=&quot;apache-port-config&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Then I edited the init.pp manifest file so that it would update the config file with new modifications to update the config file:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;file {&amp;#39;&#x2F;etc&#x2F;apache2&#x2F;ports.conf&amp;#39;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   content =&amp;gt; template(&amp;#39;install-apache&#x2F;ports.conf.erb&amp;#39;),&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   notify =&amp;gt; Service[&amp;#39;apache2&amp;#39;],&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;installing-apache2-and-userdir-with-puppet-module&#x2F;apache-config-edit.png&quot; alt=&quot;apache-config-edit&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Finally, I applied the module modifications:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo puppet apply --modulepath modules&#x2F; -e &amp;#39;class {&amp;quot;install-apache&amp;quot;:}&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;installing-apache2-and-userdir-with-puppet-module&#x2F;module-apache-applied.png&quot; alt=&quot;module-apache-applied&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Modifications has been successfully applied, now to see that the port has changed:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;installing-apache2-and-userdir-with-puppet-module&#x2F;apache-port-changed1.png&quot; alt=&quot;apache-port-changed1&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;installing-apache2-and-userdir-with-puppet-module&#x2F;apache-port-changed2.png&quot; alt=&quot;apache-port-changed2&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;In the first picture I tried to use the normal 80 port, where Apache is not listening anymore. When I tried on port 8080, Apache responds me a directory listing, so the module config template works!&lt;&#x2F;p&gt;
&lt;h3 id=&quot;sources&quot;&gt;Sources&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;Learning Puppet – Resource Ordering &#x2F; Package-File-Service (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;docs.puppetlabs.com&#x2F;learning&#x2F;ordering.html#packagefileservice&quot;&gt;http:&#x2F;&#x2F;docs.puppetlabs.com&#x2F;learning&#x2F;ordering.html#packagefileservice&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Tero Karvinen: Linux Centralized Management lecture 2 (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2013&#x2F;aikataulu-%E2%80%93-linuxin-keskitetty-hallinta-%E2%80%93-ict4tn011-4-syksylla-2013&quot;&gt;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2013&#x2F;aikataulu-%E2%80%93-linuxin-keskitetty-hallinta-%E2%80%93-ict4tn011-4-syksylla-2013&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Linux centralized management: Puppet: Using Templates and Facter facts</title>
        <published>2013-11-09T00:00:00+00:00</published>
        <updated>2013-11-09T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/school/linux-centralized-management/puppet-using-templates-and-facter-facts/"/>
        <id>/school/linux-centralized-management/puppet-using-templates-and-facter-facts/</id>
        
        <content type="html" xml:base="/school/linux-centralized-management/puppet-using-templates-and-facter-facts/">&lt;p&gt;I did some experimenting on using templates and Facter on Puppet with Package-File-Service manifest structure.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;rewriting-etc-motd-file-using-a-puppet-module-template&quot;&gt;Rewriting &#x2F;etc&#x2F;motd-file using a Puppet module template&lt;&#x2F;h3&gt;
&lt;p&gt;For the template testing I decided to use it on motd-file, which is used to display a message when you log on a linux-machine from command line.&lt;&#x2F;p&gt;
&lt;p&gt;First I created the directory structure for the new module “motdtest” with the following command:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mkdir -p motdtest&#x2F;manifests&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Then I created a new manifest file:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nano motdtest&#x2F;manifests&#x2F;init.pp&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I wrote the following to the init.pp-file:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;class motdtest {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	file { &amp;#39;&#x2F;etc&#x2F;motd&amp;#39;:&amp;lt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		content =&amp;gt; template(&amp;quot;motdtest&#x2F;motdtest.erb&amp;quot;),&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Then I created the templates directory to the  module root:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mkdir motdtest&#x2F;templates&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nano motdtest&#x2F;templates&#x2F;motdtest.erb&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;And wrote a message in the file:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;puppet-using-templates-and-facter-facts&#x2F;puppet-template-motd.png&quot; alt=&quot;puppet-template-motd&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;After saving the template file I made a test run on the module to see if it would work:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo puppet apply --modulepath modules&#x2F; -e &amp;#39;class {&amp;quot;motdtest&amp;quot;:}&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;(Sudo is needed because we are making changes to a system config file with this module.)&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;puppet-using-templates-and-facter-facts&#x2F;motd-template-working.png&quot; alt=&quot;motd-template-working&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;After I run the command above, it says that it has updated the content on &#x2F;etc&#x2F;motd-file. Let’s see if my message is in the file:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;puppet-using-templates-and-facter-facts&#x2F;puppet-module-motdtest-working.png&quot; alt=&quot;puppet-module-motdtest-working&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;adding-facter-variables&quot;&gt;Adding Facter variables&lt;&#x2F;h3&gt;
&lt;p&gt;I edited the template file to look like this:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;puppet-using-templates-and-facter-facts&#x2F;puppet-template-with-facter-facts.png&quot; alt=&quot;puppet-template-with-facter-facts&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;You can find more facts available with command “facter” and even more with “facter -p”. After saving the changes to the template, I applied the module again:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo puppet apply --modulepath modules&#x2F; -e &amp;#39;class {&amp;quot;motdtest&amp;quot;:}&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;puppet-using-templates-and-facter-facts&#x2F;apply-changes-facter-facts.png&quot; alt=&quot;apply-changes-facter-facts&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;And this is the result of the modifications:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;puppet-using-templates-and-facter-facts&#x2F;motd-with-facts-working.png&quot; alt=&quot;motd-with-facts-working&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;sources&quot;&gt;Sources&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;Puppet CookBook: Show all facter facts (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;www.puppetcookbook.com&#x2F;posts&#x2F;list-facter-facts.html&quot;&gt;http:&#x2F;&#x2F;www.puppetcookbook.com&#x2F;posts&#x2F;list-facter-facts.html&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Learning Puppet – Templates (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;docs.puppetlabs.com&#x2F;learning&#x2F;templates.html&quot;&gt;http:&#x2F;&#x2F;docs.puppetlabs.com&#x2F;learning&#x2F;templates.html&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Tero Karvinen: Linux centralized management lecture (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2013&#x2F;aikataulu-%E2%80%93-linuxin-keskitetty-hallinta-%E2%80%93-ict4tn011-4-syksylla-2013&quot;&gt;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2013&#x2F;aikataulu-%E2%80%93-linuxin-keskitetty-hallinta-%E2%80%93-ict4tn011-4-syksylla-2013&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Linux project: From VMWare ESXi-system to open source alternatives</title>
        <published>2013-11-05T00:00:00+00:00</published>
        <updated>2013-11-05T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/school/linux-project/from-esxi-to-open-source-alternatives/"/>
        <id>/school/linux-project/from-esxi-to-open-source-alternatives/</id>
        
        <content type="html" xml:base="/school/linux-project/from-esxi-to-open-source-alternatives/">&lt;p&gt;Linux-projekti-kurssille ajattelin seuraavanlaista projektia:&lt;&#x2F;p&gt;
&lt;h3 id=&quot;siirtyminen-vmware-esxi-ymparistosta-avoimen-lahdekoodin-ymparistoon&quot;&gt;Siirtyminen VMWare ESXi-ympäristöstä avoimen lähdekoodin ympäristöön&lt;&#x2F;h3&gt;
&lt;p&gt;Projektin tarkoituksena olisi muuntaa nykyinen VMWare ESXi-pohjainen labraympäristö pyörimään avoimen lähdekoodin työkaluilla ja alustalla. Uusi järjestelmä tulisi pyörimään joko Debianin tai Ubuntun päällä ja se saa mahdollisesti myös graafisen päätteen mediacenter&#x2F;server-toimintoja ajatellen. Projekti tehdään parityönä Aleksi Kulmalan kanssa.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;vaatimukset-uudelle-ymparistolle&quot;&gt;Vaatimukset uudelle ympäristölle&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;Hallintatyökalut etäkäytettäviä ja alustariippumattomia (web-pohjaisuus?)&lt;&#x2F;li&gt;
&lt;li&gt;Järjestelmä pyörii Linuxin päällä (Distribuutio mielellään Debian tai Ubuntu)&lt;&#x2F;li&gt;
&lt;li&gt;Mahdollisuus ajaa Windows-guesteja&lt;&#x2F;li&gt;
&lt;li&gt;Snapshotit&lt;&#x2F;li&gt;
&lt;li&gt;Verkkojen konfigurointi&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;tutkittavat-jarjestelmat&quot;&gt;Tutkittavat järjestelmät&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Vagrant&lt;&#x2F;strong&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Virtualbox&lt;&#x2F;strong&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;OpenStack&lt;&#x2F;strong&gt;&lt;&#x2F;li&gt;
&lt;li&gt;OpenVZ&lt;&#x2F;li&gt;
&lt;li&gt;KVM&lt;&#x2F;li&gt;
&lt;li&gt;Xen&lt;&#x2F;li&gt;
&lt;li&gt;XenServer&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;alustava-aikataulu&quot;&gt;Alustava aikataulu&lt;&#x2F;h3&gt;
&lt;ol&gt;
&lt;li&gt;Seulotaan vaatimuksiin sopivat järjestelmät&lt;&#x2F;li&gt;
&lt;li&gt;Asennetaan valitut järjestelmät testattavaksi -&amp;gt; raportointi&lt;&#x2F;li&gt;
&lt;li&gt;Valitaan sopivin järjestelmä lopulliseen systeemiin&lt;&#x2F;li&gt;
&lt;li&gt;Asennetaan valittu järjestelmä kohderaudalle ja konfiguroidaan toimivaksi&lt;&#x2F;li&gt;
&lt;li&gt;Luodaan uudet virtuaalikoneet tai tehdään migraatio vanhoista virtuaalikoneista&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;h3 id=&quot;milestonet&quot;&gt;Milestonet&lt;&#x2F;h3&gt;
&lt;h4 id=&quot;viikko-46&quot;&gt;Viikko 46&lt;&#x2F;h4&gt;
&lt;ul&gt;
&lt;li&gt;Projektisuunnitelman luominen&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h4 id=&quot;viikko-47&quot;&gt;Viikko 47&lt;&#x2F;h4&gt;
&lt;ul&gt;
&lt;li&gt;Seulotaan vaatimuksiin sopivat järjestelmät&lt;&#x2F;li&gt;
&lt;li&gt;Testataan valitut järjestelmät -&amp;gt; raportit&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h4 id=&quot;viikko-48&quot;&gt;Viikko 48&lt;&#x2F;h4&gt;
&lt;ul&gt;
&lt;li&gt;Valitaan sopivin järjestelmä lopulliseen rautaan&lt;&#x2F;li&gt;
&lt;li&gt;Asennetaan valittu järjestelmä kohderautaan ja viilataan toimintakuntoon&lt;&#x2F;li&gt;
&lt;li&gt;Luodaan uudet virtuaalikoneet tai tehdään migraatio vanhoista koneista&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h4 id=&quot;viikko-49&quot;&gt;Viikko 49&lt;&#x2F;h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Projektin DL 4.12.2013!&lt;&#x2F;strong&gt;&lt;&#x2F;li&gt;
&lt;li&gt;Viilataan demot ja esitys kuntoon&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h4 id=&quot;viikko-50&quot;&gt;Viikko 50&lt;&#x2F;h4&gt;
&lt;ul&gt;
&lt;li&gt;Esitys?&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h4 id=&quot;viikko-51&quot;&gt;Viikko 51&lt;&#x2F;h4&gt;
&lt;ul&gt;
&lt;li&gt;Esitys?&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Linux centralized management: Some Puppet module testing</title>
        <published>2013-11-03T00:00:00+00:00</published>
        <updated>2013-11-03T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/school/linux-centralized-management/some-puppet-module-testing/"/>
        <id>/school/linux-centralized-management/some-puppet-module-testing/</id>
        
        <content type="html" xml:base="/school/linux-centralized-management/some-puppet-module-testing/">&lt;p&gt;After I got Puppet running in my test VM, I wanted to test some simple tasks it could do. After reading the chapter &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;docs.puppetlabs.com&#x2F;learning&#x2F;ral.html&quot;&gt;Resources and the RAL&lt;&#x2F;a&gt; from Puppet documentation, I started to test it on my test VM.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;creating-a-user&quot;&gt;Creating a user&lt;&#x2F;h3&gt;
&lt;p&gt;I started testing with user creation. I created the default module directory structure for the module “puppetUserTest”:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mkdir -p puppetUserTest&#x2F;manifests&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;(The &lt;strong&gt;-p&lt;&#x2F;strong&gt; argument lets us to create the two directories with one command.)&lt;&#x2F;p&gt;
&lt;p&gt;Then I started to write the init.pp file that is needed for Puppet modules:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nano &#x2F;puppetUserTest&#x2F;manifests&#x2F;init.pp&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I wrote the following code to the file:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;class puppetUserTest {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	user { &amp;#39;puppetUser&amp;#39;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		ensure =&amp;gt; &amp;#39;present&amp;#39;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		home =&amp;gt; &amp;#39;&#x2F;home&#x2F;puppetUser&amp;#39;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		shell =&amp;gt; &amp;#39;&#x2F;bin&#x2F;bash&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Then I saved the file and tested it with the following command (sudo is needed in this case as I am creating a user):&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo puppet apply puppetUserTest&#x2F;manifests&#x2F;init.pp&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;some-puppet-module-testing&#x2F;create_puppetuser.png&quot; alt=&quot;create-puppetuser&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;And voilà, we have a new user in the system:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;some-puppet-module-testing&#x2F;puppetuser-created.png&quot; alt=&quot;puppetuser-created&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Listing from &#x2F;etc&#x2F;passwd file.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;installing-a-software-package&quot;&gt;Installing a software package&lt;&#x2F;h3&gt;
&lt;p&gt;Next I tested if I could simply install Apache Web Server to my VM and check that it was started.&lt;&#x2F;p&gt;
&lt;p&gt;Again I created a new directory structure with the following command:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mkdir -p installApache2&#x2F;manifests&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Then I created the configuration file with the command:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nano installApache2&#x2F;manifests&#x2F;init.pp&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I wrote the following configuration to the file:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;class installApache2 {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	# Install Apache2 if it isn&amp;#39;t already&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	package { &amp;#39;apache2&amp;#39;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		ensure =&amp;gt; installed,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	# Ensure that Apache2 is running&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	service { &amp;#39;apache2&amp;#39;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; 		ensure =&amp;gt; running,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; 		enable =&amp;gt; true,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;After I was done with the configuration, I made a test run on it with the command:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo puppet apply installApache2&#x2F;manifests&#x2F;init.pp&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;So, the result was a wall of text with error messages:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;some-puppet-module-testing&#x2F;apache2-install-errors.png&quot; alt=&quot;apache2-install-errors&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;As I investigated the resolving errors, I found out that my internet connection was down. When I switched over to mobile broadband, I was able to continue to try again my puppet module.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;some-puppet-module-testing&#x2F;apache2-installed.png&quot; alt=&quot;apache2-installed&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;From the process listing we can see that apache2 is running. I tested if it was really working by going to the server with a browser:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;some-puppet-module-testing&#x2F;working-apache.png&quot; alt=&quot;working-apache&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Yay, it works!&lt;&#x2F;p&gt;
&lt;h3 id=&quot;conclusion&quot;&gt;Conclusion&lt;&#x2F;h3&gt;
&lt;p&gt;As I made these tests on my test VM, I was amazed how simple it was to make these config files. It took me less than an hour to do all this, including writing this post which took most of the time.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;sources&quot;&gt;Sources&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;Learning Puppet – Resources and RAL (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;docs.puppetlabs.com&#x2F;learning&#x2F;ral.html&quot;&gt;http:&#x2F;&#x2F;docs.puppetlabs.com&#x2F;learning&#x2F;ral.html&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Learning Puppet – Modules and Classes (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;docs.puppetlabs.com&#x2F;learning&#x2F;modules1.html&quot;&gt;http:&#x2F;&#x2F;docs.puppetlabs.com&#x2F;learning&#x2F;modules1.html&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Tero Karvinen: Puppet Reading List (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2012&#x2F;puppet-reading-list&quot;&gt;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2012&#x2F;puppet-reading-list&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Linux centralized management: Installing and testing Puppet on Debian 7</title>
        <published>2013-10-29T00:00:00+00:00</published>
        <updated>2013-10-29T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/school/linux-centralized-management/installing-and-testing-puppet-on-debian-7/"/>
        <id>/school/linux-centralized-management/installing-and-testing-puppet-on-debian-7/</id>
        
        <content type="html" xml:base="/school/linux-centralized-management/installing-and-testing-puppet-on-debian-7/">&lt;p&gt;Installing and configuring Puppet on Debian isn’t very different than in Ubuntu as they are practically the same platform. Here is my notes from testing Puppet on Debian.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;installing-puppet-client&quot;&gt;Installing Puppet client&lt;&#x2F;h2&gt;
&lt;p&gt;Installing the client is easy and can be installed straight from apt:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo apt-get update&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo apt-get install puppet&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;(And yes, I have &lt;em&gt;sudo&lt;&#x2F;em&gt; installed on my Debian test box for convenience.)&lt;&#x2F;p&gt;
&lt;h2 id=&quot;first-puppet-test-program&quot;&gt;First Puppet test program&lt;&#x2F;h2&gt;
&lt;p&gt;When the installation is ready, you should test Puppet to make sure it is working. This can be done with a simple one line puppet program in terminal (Thanks to Tero for this nifty example):&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;puppet apply -e &amp;#39;file { &amp;quot;&#x2F;tmp&#x2F;helloPuppet&amp;quot;: content =&amp;gt; &amp;quot;This is a Puppet example!\n&amp;quot; }&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;If everything is working, you should see notice-line in the terminal window saying that the “content is defined as md5” etc.&lt;&#x2F;p&gt;
&lt;p&gt;If you try to run the same line again, you will only get response “Finished catalog run in x.xx seconds” as the file has not changed:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;installing-and-testing-puppet-on-debian-7&#x2F;puppet_working.png&quot; alt=&quot;puppet-working&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;What if we change the content of the command? Let’s test it:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;puppet apply -e &amp;#39;file { &amp;quot;&#x2F;tmp&#x2F;helloPuppet&amp;quot;: content =&amp;gt; &amp;quot;This is a modified Puppet example!\n&amp;quot; }&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;As we can see, Puppet detects that the file &#x2F;tmp&#x2F;helloPuppet has different content than what we told it in the command above and will update the file. When we run the same command again, it detects that the file does not differ from the content on our command and will not update it:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-centralized-management&#x2F;installing-and-testing-puppet-on-debian-7&#x2F;puppet_test_modified.png&quot; alt=&quot;puppet-test-modified&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;sources&quot;&gt;Sources&lt;&#x2F;h2&gt;
&lt;p&gt;– Introduction on Puppet at Linux Centralized Management course (Tero Karvinen) – &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2013&#x2F;aikataulu-%E2%80%93-linuxin-keskitetty-hallinta-%E2%80%93-ict4tn011-4-syksylla-2013&quot;&gt;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2013&#x2F;aikataulu-%E2%80%93-linuxin-keskitetty-hallinta-%E2%80%93-ict4tn011-4-syksylla-2013&lt;&#x2F;a&gt;
– Tero Karvinen: Hello Puppet revisited – on Ubuntu 12.04 – &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2013&#x2F;hello-puppet-revisited-%E2%80%93-on-ubuntu-12-04-lts&quot;&gt;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2013&#x2F;hello-puppet-revisited-%E2%80%93-on-ubuntu-12-04-lts&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Installing PDF Viewer to SRWare Iron on Mac</title>
        <published>2013-10-10T00:00:00+00:00</published>
        <updated>2013-10-10T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/posts/installing-pdf-support-to-srware-iron-on-mac/"/>
        <id>/posts/installing-pdf-support-to-srware-iron-on-mac/</id>
        
        <content type="html" xml:base="/posts/installing-pdf-support-to-srware-iron-on-mac/">&lt;p&gt;If you are using SRWare Iron, you might have noticed that it does not open PDF-files in browser like Google Chrome does. Here is how to get the PDF-viewer to Iron:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Download Google Chrome, open the dmg-image but don’t install it.&lt;&#x2F;li&gt;
&lt;li&gt;Right-click (or Ctrl+click) the Chrome application and select “Show package contents”.&lt;&#x2F;li&gt;
&lt;li&gt;Navigate to “Contents&#x2F;Versions&#x2F;&lt;version number&gt;&#x2F;Google Chrome Framework.framework&#x2F;Internet Plug-Ins&#x2F;”. In this folder you should see a file named “PDF.plugin”, copy it to your desktop. You can close now the Finder window and unmount the Chrome installation image.&lt;&#x2F;li&gt;
&lt;li&gt;Close Iron if it is running. Open Finder and go to your &#x2F;Applications folder. Right-click (or Ctrl+click) the  SRWare Iron application and select “Show package contents”.&lt;&#x2F;li&gt;
&lt;li&gt;Navigate to “Contents&#x2F;Versions&#x2F;&lt;version number&gt;&#x2F;Chromium Framework.framework&#x2F;Internet Plug-Ins&#x2F;”.&lt;&#x2F;li&gt;
&lt;li&gt;Copy the “PDF.plugin” file from your desktop to this folder.&lt;&#x2F;li&gt;
&lt;li&gt;Close all Finder windows and re-open Iron. Now you should be able to view PDF files in your browser!&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;h2 id=&quot;sources&quot;&gt;Sources&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;wiredhut.blogspot.it&#x2F;2012&#x2F;06&#x2F;how-to-get-chromes-pdf-viewer-in-srware.html&quot;&gt;How to Get Chrome’s PDF Viewer in SRWare Iron (http:&#x2F;&#x2F;wiredhut.blogspot.it&#x2F;2012&#x2F;06&#x2F;how-to-get-chromes-pdf-viewer-in-srware.html)&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Projektityö: Varashälytin Arduinolla</title>
        <published>2013-05-10T00:00:00+00:00</published>
        <updated>2013-05-10T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/school/prototyping-course/projektityo-varashalytin-arduinolla/"/>
        <id>/school/prototyping-course/projektityo-varashalytin-arduinolla/</id>
        
        <content type="html" xml:base="/school/prototyping-course/projektityo-varashalytin-arduinolla/">&lt;p&gt;Prototyypin rakentaminen-kurssin projektityönä minulla on varashälytin, joka liikkeen sekä oven avaamisen. Se kerää lokitiedostoa tietokoneelle ja lähettää hälytyksen sähköpostitse jos hälytys laukeaa.&lt;&#x2F;p&gt;
&lt;p&gt;Laitteeseen on kytketty näyttö, josta näkee tilatietoa varashälyttimen tilasta. Laitteessa on myös RFID-lukija, jolla varashälytin aktivoidaan ja deaktivoidaan.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;prototyping-course&#x2F;projektityo-varashalytin-arduinolla&#x2F;varashalytin2_bb.png&quot; alt=&quot;varashalytin2-bb&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;prototyping-course&#x2F;projektityo-varashalytin-arduinolla&#x2F;varashalytin-hardware.jpg&quot; alt=&quot;varashalytin-hardware&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;arduinon-pinnijarjestys&quot;&gt;Arduinon pinnijärjestys&lt;&#x2F;h2&gt;
&lt;p&gt;Arduinon lähes kaikki digitaalipinnit ovat käytössä. Seuraavassa lista pinneistä ja mihin ne on kytketty:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;2: LCD pin D7&lt;&#x2F;li&gt;
&lt;li&gt;3: LCD pin D6&lt;&#x2F;li&gt;
&lt;li&gt;4: LCD pin D5&lt;&#x2F;li&gt;
&lt;li&gt;5: LCD pin D4&lt;&#x2F;li&gt;
&lt;li&gt;6: Vihreä led&lt;&#x2F;li&gt;
&lt;li&gt;7: Magneettikytkimen signaalijohto&lt;&#x2F;li&gt;
&lt;li&gt;8: Liiketunnistimen signaalijohto&lt;&#x2F;li&gt;
&lt;li&gt;9: Piezo&lt;&#x2F;li&gt;
&lt;li&gt;10: iButton RFID-lukija&lt;&#x2F;li&gt;
&lt;li&gt;11: LCD pin Enable&lt;&#x2F;li&gt;
&lt;li&gt;12: LCD pin RS&lt;&#x2F;li&gt;
&lt;li&gt;13: Punainen Led&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;arduinon-ohjelmalogiikka&quot;&gt;Arduinon ohjelmalogiikka&lt;&#x2F;h2&gt;
&lt;p&gt;Varashälyttimen toimintalogiikka Arduinossa on jaettu SchedulerARMAVR-kirjaston avulla kahteen looppiin, joista toinen tarkkailee RFID-lukijaa sekä ohjaa näyttöä, ja toinen joka tarkkailee magneettisensoria ja liiketunnistinta.&lt;&#x2F;p&gt;
&lt;p&gt;Varashälytin tarkkailee jatkuvasti sensoreita, mutta ilmoittaa tapahtumista näytöllä vain “Armed”-tilassa. Sarjaportin yli tapahtumia kirjataan jatkuvasti hälytyksen tilasta riippumatta.&lt;&#x2F;p&gt;
&lt;p&gt;Kun hälytin kytketään “Armed”-tilaan, Arduino tarkkailee magneettikytkintä ja liiketunnistinta. Jos liikettä havaitaan tai ovi on auki yli 10 sekunnin ajan(toteutuksessa on havaittu ettei aikaraja aina täsmää jos liike ei ole jatkuvaa), hälytys laukeaa joka ilmoitetaan äänimerkillä, näytöllä sekä sarjaportin ylitse tietokoneelle. Aikaraja näkyy näytön oikeassa yläreunassa. Hälytyksen voi kuitata vain oikealla RFID-tunnisteella tai painamalla Arduinon Reset-painiketta.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;prototyping-course&#x2F;projektityo-varashalytin-arduinolla&#x2F;varashalytin_naytto.jpeg&quot; alt=&quot;varashalytin-naytto&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;varashalytin-final-ino&quot;&gt;&lt;a href=&quot;&#x2F;school&#x2F;prototyping-course&#x2F;projektityo-varashalytin-arduinolla&#x2F;varashalytin_final.ino.txt&quot;&gt;varashalytin_final.ino:&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;#include &amp;lt;SchedulerARMAVR.h&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;#include &amp;lt;OneWire.h&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;*&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  Varashälytinohjelma, joka tarkkailee liikettä&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ja magneettikytkintä ja hälyttää niistä sarja-&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  portin ylitse.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  Author: Joni Junni&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  Date: 13.5.2013&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;*&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;&#x2F; initialize the library with the numbers of the interface pins&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;int redLedPin = 13;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;int greenLed = 6;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;int pirPin = 8;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;int magnetPin = 7;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;int pirState = LOW;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;int val = 0;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;int i = 0;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;int sensorPin = 0;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;int alertTimer = 10;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;boolean armedState;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;boolean magnetState;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;boolean motionState;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;boolean alarmConfirmed;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;&#x2F; Piezo stuff&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;int  NOTEg = 2550;    &#x2F;&#x2F; 392 Hz &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;int  NOTEC = 1912;    &#x2F;&#x2F; 523 Hz &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;int  NOTER = 0;      &#x2F;&#x2F; REST-note&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;int speakerOut = 9;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;int melody[] = {NOTEC, NOTEg};&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;int beats[]  = {16, 16}; &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;int MAX_COUNT = sizeof(melody) &#x2F; 2; &#x2F;&#x2F; Melody length, for looping.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;long tempo = 10000;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;int rest_count = 100;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;int tone_ = 0;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;int beat = 0;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;long duration  = 0;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;void playTone() {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  long elapsed_time = 0;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  if (tone_ &amp;gt; 0) { &#x2F;&#x2F; if this isn&amp;#39;t a Rest beat, while the tone has &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &#x2F;&#x2F;  played less long than &amp;#39;duration&amp;#39;, pulse speaker HIGH and LOW&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    while (elapsed_time &amp;lt; duration) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      digitalWrite(speakerOut,HIGH);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      delayMicroseconds(tone_ &#x2F; 2);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      digitalWrite(speakerOut, LOW);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      delayMicroseconds(tone_ &#x2F; 2);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      elapsed_time += (tone_);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    } &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  else { &#x2F;&#x2F; Rest beat; loop times delay&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    for (int j = 0; j &amp;lt; rest_count; j++) { &#x2F;&#x2F; See NOTE on rest_count&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      delayMicroseconds(duration);  &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }                                &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }                                 &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;&#x2F; RFID Stuff&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;OneWire ds(10); &#x2F;&#x2F; iButton reader pin&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;byte addr[8]; &#x2F;&#x2F; Data read from the iButton reader&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;int but[6] = {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  195,133,181,20,0,0}; &#x2F;&#x2F; Allowed RFID-authentication button&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;String keyStatus=&amp;quot;&amp;quot;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;void setup() {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  Serial.begin(9600);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  pinMode(redLedPin, OUTPUT);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  pinMode(greenLed, OUTPUT);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  pinMode(magnetPin, INPUT);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  pinMode(pirPin, INPUT);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  pinMode(speakerOut, OUTPUT); &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  lcd.begin(16, 2);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  armedState = false;    &#x2F;&#x2F; Used for setting system state&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  motionState = false;  &#x2F;&#x2F; Used for detecting motion state&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  magnetState = false;  &#x2F;&#x2F; Used for detecting door state&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  alarmConfirmed = false;  &#x2F;&#x2F; Used to reset triggered alarm&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  Scheduler.startLoop(loop2);  &#x2F;&#x2F; Starts additional loop function&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;void loop() {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &#x2F;&#x2F; Check for auth key button&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  getKeyCode();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  if(armedState == false) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    lcd.clear();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    lcd.print(&amp;quot;SYSTEM:DISARMED&amp;quot;);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  } &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  else {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    if(alertTimer == 0 &amp;amp;&amp;amp; alarmConfirmed == false) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      lcd.clear();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      lcd.print(&amp;quot;ALARM TRIGGERED!&amp;quot;);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      lcd.setCursor(0, 1);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      lcd.print(&amp;quot;EMAIL SENT!&amp;quot;);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    } else {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    lcd.clear();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    lcd.print(&amp;quot;SYSTEM:ARMED  &amp;quot;);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    lcd.print(alertTimer);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    if(motionState == true) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      lcd.setCursor(0, 1);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      lcd.print(&amp;quot;MOTION DETECTED&amp;quot;);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    if(magnetState == true) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      lcd.setCursor(0, 1);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      lcd.print(&amp;quot;                &amp;quot;);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      lcd.setCursor(0, 1);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      lcd.print(&amp;quot;DOOR OPEN&amp;quot;);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  Scheduler.delay(1000); &#x2F;&#x2F; Poll every second&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;void loop2() {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  checkPirSensor();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  checkMagnetSensor();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  Scheduler.delay(1000);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  yield();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;void checkPirSensor() {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  val = digitalRead(pirPin);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &#x2F;&#x2F; Motion detected&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  if (val == HIGH) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    motionState = true;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    if(armedState == true) {    &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      if(alertTimer &amp;gt; 0) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        alertTimer = alertTimer - 1;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      } &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      else {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        Serial.println(&amp;quot;ALARM&amp;quot;);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        &#x2F;&#x2F; Trigger alarm&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        triggerAlarm();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      blinkAlertLed();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Serial.println(&amp;quot;P&amp;quot;);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  } &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  else {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &#x2F;&#x2F; Send a signal to serial port that motion has stopped&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    if(motionState == true) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      Serial.println(&amp;quot;PS&amp;quot;);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    motionState = false;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;void checkMagnetSensor() {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  val = digitalRead(magnetPin);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &#x2F;&#x2F; Magnet switch is open (Door is open)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  if (val == HIGH) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &#x2F;&#x2F;lcd.clear();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    lcd.setCursor(0, 1);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    magnetState = true;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    if(armedState == true) {    &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      if(alertTimer &amp;gt; 0) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        alertTimer = alertTimer - 1;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      } &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      else {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        &#x2F;&#x2F; Trigger alarm&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        Serial.println(&amp;quot;ALARM&amp;quot;);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        triggerAlarm();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      blinkAlertLed();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Serial.println(&amp;quot;M&amp;quot;);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  } &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  else {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &#x2F;&#x2F; Send a signal to serial port that door has been closed&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    if(magnetState == true) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      Serial.println(&amp;quot;MS&amp;quot;);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    magnetState = false;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;void checkLogin() {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &#x2F;&#x2F; If key button format is ok&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  if(keyStatus==&amp;quot;ok&amp;quot;){&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &#x2F;*&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  byte i;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;     for( i = 5; i &amp;gt;0; i--) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;     Serial.print(&amp;quot; : &amp;quot;);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;     Serial.print(addr[i], DEC);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;     }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;     Serial.println();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;     *&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &#x2F;&#x2F; Check if user is authorized&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    if(addr[1] == but[0] &amp;amp;&amp;amp; addr[2] == but[1] &amp;amp;&amp;amp; addr[3] == but[2] &amp;amp;&amp;amp; addr[4] == but[3]) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      FlashGreenLed();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      Serial.println(&amp;quot;AU&amp;quot;);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      if(armedState == false) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        setArmed();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      } &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      else {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        setDisarmed();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      if(alarmConfirmed == false &amp;amp;&amp;amp; alertTimer == 0) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        alarmConfirmed = true;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    } &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    else {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      Serial.println(&amp;quot;UU&amp;quot;);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      blinkAlertLed();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;void getKeyCode(){&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  keyStatus=&amp;quot;&amp;quot;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &#x2F;&#x2F; If there is nothing to read, stop and return&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  if ( !ds.search(addr)) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    ds.reset_search();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    return;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  keyStatus=&amp;quot;ok&amp;quot;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  checkLogin();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ds.reset();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;void blinkAlertLed() {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &#x2F;&#x2F; Blink the alert led&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  for(i=0;i&amp;lt;5;i++) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    digitalWrite(redLedPin, HIGH);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Scheduler.delay(200);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    digitalWrite(redLedPin, LOW);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Scheduler.delay(200);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  } &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;void FlashGreenLed() {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  digitalWrite(greenLed, HIGH);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  Scheduler.delay(1500);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  digitalWrite(greenLed, LOW);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;void setArmed() {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  Serial.println(&amp;quot;A&amp;quot;);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  armedState = true;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  alertTimer = 10; &#x2F;&#x2F; Reset alert timer&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  alarmConfirmed = false;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;void setDisarmed() {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  Serial.println(&amp;quot;D&amp;quot;);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  armedState = false; &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;void triggerAlarm() {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &#x2F;&#x2F; Set up a counter to pull from melody[] and beats[]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  while(alarmConfirmed == false) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    for (int i=0; i&amp;lt;MAX_COUNT; i++) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      tone_ = melody[i];&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      beat = beats[i];&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      duration = beat * tempo; &#x2F;&#x2F; Set up timing&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      playTone(); &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      Scheduler.delay(1);    &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;sarjaporttikommunikaatio-tietokoneen-kanssa&quot;&gt;Sarjaporttikommunikaatio tietokoneen kanssa&lt;&#x2F;h2&gt;
&lt;p&gt;Varashälytin kommunikoi tietokoneen kanssa sarjaportin yli lokitiedoston kirjoittamista sekä varoitusviestin lähettämistä varten. Määritin varashälyttimen koodiin seuraavanlaiset komennot jota se voi tietokoneelle lähettää:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;P: Liiketunnistin havaitsee liikettä&lt;&#x2F;li&gt;
&lt;li&gt;M: Ovi on auki (magneettikytkin)&lt;&#x2F;li&gt;
&lt;li&gt;AU: Sallittu käyttäjä tunnistautunut (RFID)&lt;&#x2F;li&gt;
&lt;li&gt;UU: Ei-sallittu käyttäjä tunnistautunut (RFID)&lt;&#x2F;li&gt;
&lt;li&gt;A: Hälytin Armed-tilassa&lt;&#x2F;li&gt;
&lt;li&gt;D: Hälytin Disarmed-tilassa&lt;&#x2F;li&gt;
&lt;li&gt;ALARM: Hälytys on lauennut&lt;&#x2F;li&gt;
&lt;li&gt;MS: Ovi on sulkeutunut (magneettikytkin)&lt;&#x2F;li&gt;
&lt;li&gt;PS: Liiketunnistin ei havaitse enää liikettä&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Tietokoneen päässä on python-ohjelma kuuntelemassa sarjaporttia ja se suorittaa komentoja sen mukaan mitä varashälytin sille syöttää. Ohjelma hoitaa tapahtumien kirjoittamisen lokiin sekä sähköpostivaroituksen lähettämisen jos hälytys laukeaa.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;varashalytin-py&quot;&gt;&lt;a href=&quot;&#x2F;school&#x2F;prototyping-course&#x2F;projektityo-varashalytin-arduinolla&#x2F;varashalytin.py.txt&quot;&gt;varashalytin.py:&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;#!&#x2F;usr&#x2F;bin&#x2F;env python&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;#coding: utf8&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# Ohjelma joka kuuntelee varashälyttimen sarjaporttia&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# ja suorittaa komentoja sen mukaan mitä hälytin käskee&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# Author: Joni Junni&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# Date: 13.5.2013&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;import serial&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;import time&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;import smtplib&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ser1 = serial.Serial(&amp;quot;&#x2F;dev&#x2F;tty.usbmodem1421&amp;quot;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;while True:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	try:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		line = ser1.readline()&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		#print(line)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		timestamp = time.asctime( time.localtime(time.time()) )&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		if line.find(&amp;#39;ALARM&amp;#39;) !=-1:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;			message =  timestamp + &amp;#39;: ALARM WAS TRIGGERED&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;			sender = &amp;#39;arduinohalytys@gmail.com&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;			receivers = [&amp;#39;joni.junni@me.com&amp;#39;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;			emailmsg = &amp;quot;&amp;quot;&amp;quot;From: Arduino Alert &amp;lt;arduinohalytys@gmail.com&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;To: Joni Junni &amp;lt;joni.junni@me.com&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Subject: Alert was triggered!&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Your home might be intruded.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;						&amp;quot;&amp;quot;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;			try:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;				smtpObj = smtplib.SMTP(&amp;#39;smtp.gmail.com&amp;#39;, 587)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;				smtpObj.ehlo()&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;				smtpObj.starttls()&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;				smtpObj.ehlo()&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;				smtpObj.login(&amp;#39;arduinohalytys&amp;#39;,&amp;#39;Trolololo&amp;#39;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   				smtpObj.sendmail(sender, receivers, emailmsg)         &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   				print &amp;quot;Successfully sent email&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;			except smtplib.SMTPException:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   				print &amp;quot;Error: unable to send email&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   			&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		elif line.find(&amp;#39;UU&amp;#39;) !=-1:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;			message = timestamp + &amp;#39;: Unauthorized user tried to log in&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		elif line.find(&amp;#39;AU&amp;#39;) !=-1:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;			message = timestamp + &amp;#39;: Authorized user has been logged&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		elif line.find(&amp;#39;MS&amp;#39;) !=-1:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;			message = timestamp + &amp;#39;: Door was Closed&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		elif line.find(&amp;#39;PS&amp;#39;) !=-1:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;			message = timestamp + &amp;#39;: Motion stopped&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		elif line.find(&amp;#39;P&amp;#39;) !=-1:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;			message = timestamp + &amp;#39;: Motion detected&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		elif line.find(&amp;#39;M&amp;#39;) !=-1:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;			message = timestamp + &amp;#39;: Door Open&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		elif line.find(&amp;#39;A&amp;#39;) !=-1:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;			message = timestamp + &amp;#39;: System Armed&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		elif line.find(&amp;#39;D&amp;#39;) !=-1:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;			message = timestamp + &amp;#39;: System Disarmed&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		f = open(&amp;#39;alertLog.log&amp;#39;,&amp;#39;a&amp;#39;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		f.write(message + &amp;#39;\n&amp;#39;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		print message&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	except (serial.serialutil.SerialException, OSError):&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		pass&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;lahteet&quot;&gt;Lähteet&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;Python Date &amp;amp; Time (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;www.tutorialspoint.com&#x2F;python&#x2F;python_date_time.htm&quot;&gt;http:&#x2F;&#x2F;www.tutorialspoint.com&#x2F;python&#x2F;python_date_time.htm&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Python Errors &amp;amp; Exceptions (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;docs.python.org&#x2F;2&#x2F;tutorial&#x2F;errors.html#exceptions&quot;&gt;http:&#x2F;&#x2F;docs.python.org&#x2F;2&#x2F;tutorial&#x2F;errors.html#exceptions&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Arduino SchedulerARMAVR-kirjasto (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;arduino.cc&#x2F;forum&#x2F;index.php?topic=142101.0&quot;&gt;http:&#x2F;&#x2F;arduino.cc&#x2F;forum&#x2F;index.php?topic=142101.0&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Arduino – Scheduler Reference (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;arduino.cc&#x2F;en&#x2F;Reference&#x2F;Scheduler&quot;&gt;http:&#x2F;&#x2F;arduino.cc&#x2F;en&#x2F;Reference&#x2F;Scheduler&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Joni Junni: RFID-sensori Arduinolla (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;www.junni.org&#x2F;2013&#x2F;04&#x2F;prototyypin-rakentaminen-rfid-sensori-arduinolla&#x2F;&quot;&gt;http:&#x2F;&#x2F;www.junni.org&#x2F;2013&#x2F;04&#x2F;prototyypin-rakentaminen-rfid-sensori-arduinolla&#x2F;&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Suvi Kiviniemi: Arduino-testailuja: iButton (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;suvikiviniemi.com&#x2F;skivinie&#x2F;arduino-testailuja-ibutton&#x2F;&quot;&gt;http:&#x2F;&#x2F;suvikiviniemi.com&#x2F;skivinie&#x2F;arduino-testailuja-ibutton&#x2F;&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;The iButton garage-door opener (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;www.instructables.com&#x2F;id&#x2F;The-iButton-garage-door-opener-Arduino&#x2F;&quot;&gt;http:&#x2F;&#x2F;www.instructables.com&#x2F;id&#x2F;The-iButton-garage-door-opener-Arduino&#x2F;&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Joni Junni: LCD-näytöt ja sarjaporttiliikenne (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;www.junni.org&#x2F;2013&#x2F;04&#x2F;prototyypin-rakentaminen-lcd-naytot-ja-sarjaporttiliikenne&#x2F;&quot;&gt;http:&#x2F;&#x2F;www.junni.org&#x2F;2013&#x2F;04&#x2F;prototyypin-rakentaminen-lcd-naytot-ja-sarjaporttiliikenne&#x2F;&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Arduino Playground – OneWire (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;playground.arduino.cc&#x2F;Learning&#x2F;OneWire&quot;&gt;http:&#x2F;&#x2F;playground.arduino.cc&#x2F;Learning&#x2F;OneWire&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Arduino: Tehtävän ajastus arduinolla</title>
        <published>2013-05-09T00:00:00+00:00</published>
        <updated>2013-05-09T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/school/prototyping-course/arduino-tehtavan-ajastus-arduinolla/"/>
        <id>/school/prototyping-course/arduino-tehtavan-ajastus-arduinolla/</id>
        
        <content type="html" xml:base="/school/prototyping-course/arduino-tehtavan-ajastus-arduinolla/">&lt;p&gt;Huomasin varashälytintä tehdessä että tehtävien ajoitus aiheuttaa ongelmia ohjelmalogiikan luomisessa. Koska Arduino normaalisti ajaa vain yhtä looppia jossa tehtävät menevät peräkkäin, ongelmaksi muodostuu sellaiset tehtävät jotka pitäisi voida suorittaa samaan aikaan jonkin toisen prosessin kanssa. Varashälyttimeni kanssa ongelmaksi muodostui hälytyksen sammuttaminen, koska Arduino keskittyi hälytyksen suorittamiseen eikä ottanut huomioon kuittausnappia.&lt;&#x2F;p&gt;
&lt;p&gt;Pienen googletuksen tuloksena löysin Arduino Unolle portatun &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;arduino.cc&#x2F;forum&#x2F;index.php?topic=142101.0&quot;&gt;SchedulerARMAVR-kirjaston&lt;&#x2F;a&gt;, jonka avulla on mahdollista ajaa Arduinossa useampaa loop-funtiota rinnakkain.&lt;&#x2F;p&gt;
&lt;p&gt;Seuraavassa esimerkki kirjaston käyttämisestä:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;*&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Program blinks two leds using two different loop-functions&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Author: Joni Junni&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Date:   9.5.2013&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;*&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;#include &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;void setup() {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;&#x2F; Start the other loop function &amp;quot;loop2&amp;quot; using Scheduler&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	Scheduler.startLoop(loop2);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	pinMode(13, OUTPUT); &#x2F;&#x2F; Red led&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	pinMode(6, OUTPUT);  &#x2F;&#x2F; Green led&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;void loop() {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	digitalWrite(13, HIGH);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	Scheduler.delay(500);  &#x2F;&#x2F; ms&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	digitalWrite(13, LOW);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	Scheduler.delay(500);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;void loop2() {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	digitalWrite(6, HIGH);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	Scheduler.delay(200);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	digitalWrite(6, LOW);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	Scheduler.delay(500);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	yield();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Kirjaston käyttö ei eroa Arduino Duelle tarkoitetusta &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;arduino.cc&#x2F;en&#x2F;Reference&#x2F;Scheduler&quot;&gt;Scheduler-kirjastosta&lt;&#x2F;a&gt; ja sen referenssisivut kannattaa lukea läpi.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;lahteet&quot;&gt;Lähteet&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;Android ARM &amp;lt;Scheduler.h&amp;gt; PORTED on AVR (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;arduino.cc&#x2F;forum&#x2F;index.php?topic=142101.0&quot;&gt;http:&#x2F;&#x2F;arduino.cc&#x2F;forum&#x2F;index.php?topic=142101.0&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Arduino – Scheduler (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;arduino.cc&#x2F;en&#x2F;Reference&#x2F;Scheduler&quot;&gt;http:&#x2F;&#x2F;arduino.cc&#x2F;en&#x2F;Reference&#x2F;Scheduler&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Arduino-projekti: Varashälytin näytöllä ja RFID-aktivoinnilla</title>
        <published>2013-04-26T00:00:00+00:00</published>
        <updated>2013-04-26T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/school/prototyping-course/arduino-projekti-varashalytin-naytolla-ja-rfid-aktivoinnilla/"/>
        <id>/school/prototyping-course/arduino-projekti-varashalytin-naytolla-ja-rfid-aktivoinnilla/</id>
        
        <content type="html" xml:base="/school/prototyping-course/arduino-projekti-varashalytin-naytolla-ja-rfid-aktivoinnilla/">&lt;p&gt;Projektin tarkoitus on saada yhdistetty varashälytin- ja kulunvalvontajärjestelmä, jonka voi aktivoida ja kytkeä pois RFID-tunnisteella.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;kuvaus-toiminnasta&quot;&gt;Kuvaus toiminnasta&lt;&#x2F;h2&gt;
&lt;p&gt;Hälytin- ja kulunvalvontajärjestelmä joka vahtii ovia, ikkunoita ja liiketunnistimen avulla liikettä. Laite voidaan kytkeä päälle ja pois RFID-tunnisteella jotka ovat käyttäjäkohtaisia. Laitteen paneeliin tulee LCD-näyttö, josta näkee järjestelmän tilan sekä ledit ilmoittamaan hälytyksen päälläolosta ja sensorien havaitsemasta toiminnasta. Laite kirjaa sarjaportin yli tietokoneelle tapahtumia sensoreilta sekä autentikointikerrat. Jos aikaa jää, voidaan yhdistellä ominaisuuksia muista samankaltaisista projekteista.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;tarvittavat-osat&quot;&gt;Tarvittavat osat&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;Arduino&lt;&#x2F;li&gt;
&lt;li&gt;LCD-näyttö&lt;&#x2F;li&gt;
&lt;li&gt;Liiketunnistin (PIR)&lt;&#x2F;li&gt;
&lt;li&gt;Magneetti&#x2F;reedkytkimiä&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;samankaltaisia-projekteja&quot;&gt;Samankaltaisia projekteja&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;Arduino Security System (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;code.google.com&#x2F;p&#x2F;arduino-security-system&#x2F;&quot;&gt;https:&#x2F;&#x2F;code.google.com&#x2F;p&#x2F;arduino-security-system&#x2F;&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Arduino Burglar Alarm (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;www.freetronics.com&#x2F;blogs&#x2F;news&#x2F;7142724-diy-burglar-and-fire-alarm-system-with-arduino&quot;&gt;http:&#x2F;&#x2F;www.freetronics.com&#x2F;blogs&#x2F;news&#x2F;7142724-diy-burglar-and-fire-alarm-system-with-arduino&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt; &lt;&#x2F;p&gt;
&lt;h2 id=&quot;lahteet&quot;&gt;Lähteet&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;BIS0001-liiketunnistimen käyttö Arduinossa (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;www.instructables.com&#x2F;id&#x2F;PIR-Motion-Sensor-Tutorial&#x2F;&quot;&gt;http:&#x2F;&#x2F;www.instructables.com&#x2F;id&#x2F;PIR-Motion-Sensor-Tutorial&#x2F;&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;LCD-näytön kytkeminen Arduinoon (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;arduino.cc&#x2F;en&#x2F;Tutorial&#x2F;LiquidCrystal&quot;&gt;http:&#x2F;&#x2F;arduino.cc&#x2F;en&#x2F;Tutorial&#x2F;LiquidCrystal&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Prototyypin rakentaminen: LCD-näytöt ja sarjaporttiliikenne</title>
        <published>2013-04-26T00:00:00+00:00</published>
        <updated>2013-04-26T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/school/prototyping-course/prototyypin-rakentaminen-lcd-naytot-ja-sarjaporttiliikenne/"/>
        <id>/school/prototyping-course/prototyypin-rakentaminen-lcd-naytot-ja-sarjaporttiliikenne/</id>
        
        <content type="html" xml:base="/school/prototyping-course/prototyypin-rakentaminen-lcd-naytot-ja-sarjaporttiliikenne/">&lt;p&gt;Tehtävässä oli tarkoituksena kommunikoida tietokoneen avulla sarjaportitse Arduinon kanssa. Päätin tehdä Arduinolla näytön, joka ottaa sisään sarjakonsolista tekstiä ja tulostaa sen Arduinoon kytkettyyn LCD-näyttöön.&lt;&#x2F;p&gt;
&lt;p&gt;Aloitin tutkimalla kuinka LCD-paneelin saa kytkettyä Arduinoon. Löysin &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;arduino.cc&#x2F;en&#x2F;Tutorial&#x2F;LiquidCrystal&quot;&gt;Arduinon omilta sivuilta&lt;&#x2F;a&gt; ohjeet LiquidCrystal-luokan käyttöön.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;nayton-kytkeminen-arduinoon&quot;&gt;Näytön kytkeminen Arduinoon&lt;&#x2F;h1&gt;
&lt;p&gt;Näytön datapinnit D4-D7 kytketään Arduinon digital-pinneihin 2-5, näytön RS-pinni kytketään Arduinon pinniin 6 ja näytön Enable-pinni Arduinon pinniin 7. Näytön VSS kytketään maihin ja VDD kytketään +5 volttiin. Näytön taustavalon anodi kytketään +5 volttiin ja katodi maihin. Näytön V0-pinni kytketään potentiometrin keskimmäiseen jalkaan. Potentiometrin vasen jalka kytketään +5 volttiin ja oikea jalka maihin.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;prototyping-course&#x2F;prototyypin-rakentaminen-lcd-naytot-ja-sarjaporttiliikenne&#x2F;seriallcd_kytkenta.png&quot; alt=&quot;seriallcd-kytkenta&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h1 id=&quot;koodi-nayton-ohjaamiseen-sarjakonsolista&quot;&gt;Koodi näytön ohjaamiseen sarjakonsolista&lt;&#x2F;h1&gt;
&lt;p&gt;Hetken yrityksen ja erehdyksen kautta sain seuraavanlaisen koodin tehtyä joka lukee sarjakonsolista tekstiä ja syöttää sen Arduinoon kytketylle näytölle:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;*&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Arduinon näyttöön tulostaminen sarjakonsolista.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Author: Joni Junni&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Date: 26.4.2013&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Kytkentä:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;VSS: Ground&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;VDD: +5v&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;V0:  potentiometrin keskijalkaan&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;RS:  pin 6&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;RW:  Ground&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;E:   pin 7&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;D0-3:  NC&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;D4:  pin 2&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;D5:  pin 3&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;D6:  pin 4&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;D7:  pin 5&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;A:   +5v&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;K:   Ground&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;*&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;#include&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;&#x2F; Luodaan lcd &amp;quot;olio&amp;quot; määritettyihin pinneihin&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;LiquidCrystal lcd(6, 7, 2, 3, 4, 5);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;void setup() {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	Serial.begin(9600);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	&#x2F;&#x2F; Asetetaan näytön koko&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	lcd.begin(16, 2);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;void loop() {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	&#x2F;&#x2F; Jos sarjaportissa on uutta dataa,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	&#x2F;&#x2F; tyhjennetään näyttö ja tulostetaan uusi teksti näytölle&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	if(Serial.available()) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		delay(200);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		lcd.clear();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		&#x2F;&#x2F; Kirjoitetaan teksti näytölle kirjain kirjaimelta&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		while(Serial.available() &amp;gt; 0) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;			lcd.write(Serial.read()); &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Lopputuloksena syntyi Arduinolla toteutettu näyttö johon voi syöttää tekstiä sarjakonsolista:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;prototyping-course&#x2F;prototyypin-rakentaminen-lcd-naytot-ja-sarjaporttiliikenne&#x2F;serialmonitor.png&quot; alt=&quot;serialmonitor&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;prototyping-course&#x2F;prototyypin-rakentaminen-lcd-naytot-ja-sarjaporttiliikenne&#x2F;serialLcdFinal.jpeg&quot; alt=&quot;serialLcdFinal&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;lahteet&quot;&gt;Lähteet&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;Arduino – LiquidCrystal (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;arduino.cc&#x2F;en&#x2F;Tutorial&#x2F;LiquidCrystal&quot;&gt;http:&#x2F;&#x2F;arduino.cc&#x2F;en&#x2F;Tutorial&#x2F;LiquidCrystal&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Arduino – Serial (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;arduino.cc&#x2F;en&#x2F;Reference&#x2F;serial&quot;&gt;http:&#x2F;&#x2F;arduino.cc&#x2F;en&#x2F;Reference&#x2F;serial&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Tero Karvinen: Yhteydet suureen maailmaan-luento (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2012&#x2F;aikataulu-prototyypin-rakentaminen-bus4tn007-4-loppukevat-2013&quot;&gt;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2012&#x2F;aikataulu-prototyypin-rakentaminen-bus4tn007-4-loppukevat-2013&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Prototyypin rakentaminen: RFID-sensori Arduinolla</title>
        <published>2013-04-20T00:00:00+00:00</published>
        <updated>2013-04-20T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/school/prototyping-course/prototyypin-rakentaminen-rfid-sensori-arduinolla/"/>
        <id>/school/prototyping-course/prototyypin-rakentaminen-rfid-sensori-arduinolla/</id>
        
        <content type="html" xml:base="/school/prototyping-course/prototyypin-rakentaminen-rfid-sensori-arduinolla/">&lt;p&gt;Sain tehtäväkseni saada toimimaan jonkinlainen RFID-lukija Arduinossa. Pienen googletuksen jälkeen löysin &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;www.instructables.com&#x2F;id&#x2F;The-iButton-garage-door-opener-Arduino&#x2F;step2&#x2F;iButton-opening-the-door&#x2F;&quot;&gt;tämän sivuston&lt;&#x2F;a&gt;, jossa kyseisellä saamallani lukijalla oli toteutettu autotallin oveen kulunvalvonta. Esimerkki vaikutti hankalalta, mutta löysin pienen jatko-googletuksen jälkeen kurssin edellisen &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;suvikiviniemi.com&#x2F;skivinie&#x2F;arduino-testailuja-ibutton&#x2F;&quot;&gt;toteutuksen osallistujan muistiinpanot&lt;&#x2F;a&gt;, josta löytyikin valmis koodi jolla laitteen sai toimimaan.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;ledien-lisaaminen-paasyn-merkiksi&quot;&gt;Ledien lisääminen pääsyn merkiksi&lt;&#x2F;h1&gt;
&lt;p&gt;Päätin lisätä kytkentään kaksi lediä, vihreän ja punaisen. Vihreä valo kertoo että pääsy on sallittu, ja punainen kertoo että pääsy on kielletty.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;prototyping-course&#x2F;prototyypin-rakentaminen-rfid-sensori-arduinolla&#x2F;rfid_bb.png&quot; alt=&quot;kaaviokuva-kytkennöistä&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;prototyping-course&#x2F;prototyypin-rakentaminen-rfid-sensori-arduinolla&#x2F;rfid-valot.jpeg&quot; alt=&quot;Valmis-ratkaisu-ledeineen&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h1 id=&quot;koodi&quot;&gt;Koodi&lt;&#x2F;h1&gt;
&lt;p&gt;Alla on toimiva versio RFID-lukijakoodista johon on lisättynä pääsyindikaattoriledit.&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;*&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;* RFID-lukijatesti kahdella ledi-indikaattorilla.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;* Author: Joni Junni (Original version: http:&#x2F;&#x2F;suvikiviniemi.com&#x2F;skivinie&#x2F;arduino-testailuja-ibutton&#x2F;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;* Date: 20.4.2013&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;*&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;#include&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;OneWire ds(10); &#x2F;&#x2F;onewire-laitteeni on siis pinnissä 12.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;byte addr[8]; &#x2F;&#x2F;tilaa iButtonin &amp;quot;sormenjäljelle&amp;quot;. Otetaan vastaan bitteinä lukijalta.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;int but[6] = {195,133,181,20,0,0};&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;&#x2F;&amp;quot;sormenjälki&amp;quot; on tätä pidempi, mutta vain osa sen numeroista on yksilöllistä tunnistetta.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;String keyStatus=&amp;quot;&amp;quot;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;int greenLed = 12;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;int redLed = 11;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;void setup(void) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	Serial.begin(9600);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	pinMode(greenLed, OUTPUT);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	pinMode(redLed, OUTPUT);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;void loop(void) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	getKeyCode(); &#x2F;&#x2F;tsekataan keyCoden avulla onko koodi ylipäänsä olemassa ja ds1990a-napin koodi&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Serial.println();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	if(keyStatus==&amp;quot;ok&amp;quot;){&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		&#x2F;&#x2F;jos getKeyCode on lukenut oikeanlaisen napin, jatketaan tähän.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		byte i;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		for( i = 5; i &amp;gt;0; i--) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;			Serial.print(&amp;quot; : &amp;quot;);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;			Serial.print(addr[i], DEC);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		&#x2F;&#x2F; Jos nappi vastaa määritettyä nappia, syttyy vihreä ledi&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		&#x2F;&#x2F; Jos väärällä koodilla oleva nappi, vilkutetaan punaista lediä&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		if(addr[1] == but[0] &amp;amp;&amp;amp; addr[2] == but[1] &amp;amp;&amp;amp; addr[3] == but[2] &amp;amp;&amp;amp; addr[4] == but[3]) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;			digitalWrite(greenLed, HIGH);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;			delay(1500);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;			digitalWrite(greenLed, LOW);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    	} else {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;			digitalWrite(greenLed, LOW);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    		int j;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;			for(j = 5; j &amp;gt; 0; j--) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;				digitalWrite(redLed, HIGH);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;				delay(500);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;				digitalWrite(redLed, LOW);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;				delay(200);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;			}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    	}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	} else if (keyStatus!=&amp;quot;&amp;quot;) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		Serial.print(keyStatus);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;delay(1000);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;void getKeyCode(){&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	keyStatus=&amp;quot;&amp;quot;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	&#x2F;&#x2F;jos lukija ei saa kontaktia (l. nappia ei ole), palataan alkuun jo tässä.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	if ( !ds.search(addr)) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		&#x2F;&#x2F;keyStatus=&amp;quot;testi&amp;quot;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		&#x2F;&#x2F;tämän kirjoitin testiksi, ja totesinkin lukijan olevan väärässä pinnissä&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		&#x2F;&#x2F;(ohjeen mukainen 2, ei koodin mukainen 12),&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		&#x2F;&#x2F;kun ohjelma tulosti koko ajan pelkkää &amp;quot;testiä&amp;quot;.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		ds.reset_search();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		return;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	&#x2F;&#x2F;en ymmärrä täysin, ilmeisesti onewiren koko tunnuksen kohta 7 on aina sama tms?&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	if ( OneWire::crc8( addr, 7) != addr[7]) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    	keyStatus=&amp;quot;CRC invalid&amp;quot;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		return;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	&#x2F;&#x2F;tämä liittyy ds1990a-mallin perhetunnukseen -&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	&#x2F;&#x2F;tämän ilmoituksen siis saisi, jos yrittäisi käyttää eri mallin nappia.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	&#x2F;&#x2F;Testata en voinut, ei ole muita nappeja.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	if ( addr[0] != 0x01) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		keyStatus=&amp;quot;not DS1990A&amp;quot;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;		return;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	&#x2F;&#x2F;jos ei palattu missään aiemmassa kohdassa,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	&#x2F;&#x2F;keyStatus on ok = lukija luki ds1990a-mallin napin.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	keyStatus=&amp;quot;ok&amp;quot;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	ds.reset();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h1 id=&quot;lahteet&quot;&gt;Lähteet&lt;&#x2F;h1&gt;
&lt;ul&gt;
&lt;li&gt;PJRC: OneWire Library (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;www.pjrc.com&#x2F;teensy&#x2F;td_libs_OneWire.html&quot;&gt;http:&#x2F;&#x2F;www.pjrc.com&#x2F;teensy&#x2F;td_libs_OneWire.html&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Suvi Kiviniemi: Arduino-testailuja: iButton (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;suvikiviniemi.com&#x2F;skivinie&#x2F;arduino-testailuja-ibutton&#x2F;&quot;&gt;http:&#x2F;&#x2F;suvikiviniemi.com&#x2F;skivinie&#x2F;arduino-testailuja-ibutton&#x2F;&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;The iButton garage-door opener (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;www.instructables.com&#x2F;id&#x2F;The-iButton-garage-door-opener-Arduino&#x2F;&quot;&gt;http:&#x2F;&#x2F;www.instructables.com&#x2F;id&#x2F;The-iButton-garage-door-opener-Arduino&#x2F;&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Tero Karvinen: Anturit, Androidin silmät-luento (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2012&#x2F;aikataulu-prototyypin-rakentaminen-bus4tn007-4-loppukevat-2013&quot;&gt;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2012&#x2F;aikataulu-prototyypin-rakentaminen-bus4tn007-4-loppukevat-2013&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Prototyypin rakentaminen: Servojen ohjaus</title>
        <published>2013-04-15T00:00:00+00:00</published>
        <updated>2013-04-15T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/school/prototyping-course/prototyypin-rakentaminen-servojen-ohjaus/"/>
        <id>/school/prototyping-course/prototyypin-rakentaminen-servojen-ohjaus/</id>
        
        <content type="html" xml:base="/school/prototyping-course/prototyypin-rakentaminen-servojen-ohjaus/">&lt;p&gt;11.4.2013 klo 17.39&lt;&#x2F;p&gt;
&lt;p&gt;Tehtävän tarkoituksena oli ohjata servomoottoria kahdella eri tavalla, Arduinon sisäisellä Servo-luokalla sekä käsin syöttämällä signaaleja sille suoraan.&lt;&#x2F;p&gt;
&lt;p&gt;Aloitin tehtävän tekemällä vaadittavat kytkennät arduinon ja servon välillä.  Servoni on mallia Tower Pro Micro Serve 9g SG90. Servomoottorissa on normaaleista moottoreista poiketen kolme johtoa: plus-johto johon tulee jatkuva jännite; miinus-johto joka tulee maihin sekä yleensä oranssi signaalijohto, jolla servoa ohjataan.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;prototyping-course&#x2F;prototyypin-rakentaminen-servojen-ohjaus&#x2F;servokytkenta_bb.png&quot; alt=&quot;servokytkenta-bb&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;prototyping-course&#x2F;prototyypin-rakentaminen-servojen-ohjaus&#x2F;servokytkenta.jpg&quot; alt=&quot;servokytkenta-hardware&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Kun kytkentä oli tehty, avasin Arduinon kehitysympäristön koneelle ja avasin File -&amp;gt; Examples -&amp;gt; Servo -&amp;gt; Sweep-esimerkkiohjelman servokytkennän testausta varten. Latasin ohjelman piirilevylle ja servo alkoi liikkumaan edes takas juuri niinkuin ohjelma käskee tekemään. Esimerkkiohjelmassa käytetään Arduinon sisäistä Servo-luokkaa servon ohjaamiseen.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;prototyping-course&#x2F;prototyypin-rakentaminen-servojen-ohjaus&#x2F;arduino_sweep.png&quot; alt=&quot;arduino-sweep&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h1 id=&quot;servon-ohjaaminen-manuaalisesti-pulsseilla&quot;&gt;Servon ohjaaminen manuaalisesti pulsseilla&lt;&#x2F;h1&gt;
&lt;p&gt;Servoa on myös mahdollista ohjata itse syöttämällä sille digitalWrite-funktiolla pulsseja tuohon pulse-johtoon. Seuraavalla koodilla sain servon liikkumaan puoli senttiä edestakaisin:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;int servopin = 9;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    void setup() {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      pinMode(servopin, OUTPUT);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    void loop() {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      eteenpain();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      delay(2000);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      taaksepain();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      delay(2000);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    void eteenpain() {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      digitalWrite(servopin, HIGH);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      delayMicroseconds(500);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      digitalWrite(servopin, LOW);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    void taaksepain() {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      digitalWrite(servopin, HIGH);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      delayMicroseconds(2200);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      digitalWrite(servopin, LOW);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Ongelmaksi muodostui saada servo liikkumaan varmemmin oikeaan suuntaan sekä saada se laajemmin liikkumaan. Koska en saanut säätämällä edellistä toimimaan paremmin, päätin kokeilla netistä löytynyttä lähdekoodimallia josko se toimisi odotetummin: &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;blog.zipwhip.com&#x2F;2012&#x2F;03&#x2F;28&#x2F;manual-control-of-a-servo-on-the-arduino-for-the-zipwhip-textspresso-machine&#x2F;&quot;&gt;http:&#x2F;&#x2F;blog.zipwhip.com&#x2F;2012&#x2F;03&#x2F;28&#x2F;manual-control-of-a-servo-on-the-arduino-for-the-zipwhip-textspresso-machine&#x2F;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;11.4.2013 klo 21.22&lt;&#x2F;p&gt;
&lt;p&gt;Pitkän säätämisen jälkeen tuo netistä löytynyt koodinpätkä toimi vielä huonommin kuin itse kirjoittamani versio aikaisemmin. Servossani on varmaankin jokin omituinen pulssisykli, koska en saanut sitä toimimaan mitenkään järkevästi muulla kuin Arduinon omalla Servo-luokalla.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Prototyypin rakentaminen: Arduinon kehitysympäristön pystyttäminen Macille</title>
        <published>2013-04-02T00:00:00+00:00</published>
        <updated>2013-04-02T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/school/prototyping-course/prototyypin-rakentaminen-arduinon-kehitysympariston-pystyttaminen-macille/"/>
        <id>/school/prototyping-course/prototyypin-rakentaminen-arduinon-kehitysympariston-pystyttaminen-macille/</id>
        
        <content type="html" xml:base="/school/prototyping-course/prototyypin-rakentaminen-arduinon-kehitysympariston-pystyttaminen-macille/">&lt;p&gt;Arduinon kehitysympäristön pystyttäminen Macille on suht suoraviivaista. Ensiksi ladataan asennuspaketti Arduinon kotisivuilta: &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;arduino.googlecode.com&#x2F;files&#x2F;arduino-1.0.4-macosx.zip&quot;&gt;http:&#x2F;&#x2F;arduino.googlecode.com&#x2F;files&#x2F;arduino-1.0.4-macosx.zip&lt;&#x2F;a&gt;&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;arduino.cc&#x2F;en&#x2F;Main&#x2F;Software&quot;&gt;&lt;br &#x2F;&gt;
&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Tämän jälkeen puretaan paketti, raahataan Arduino-ohjelma Ohjelmat-hakemistoon ja avataan se tuplaklikkaamalla.&lt;&#x2F;p&gt;
&lt;p&gt;Kun kehitysympäristö avautuu, kytketään Arduino USB-johdolla koneeseen kiinni ja valitaan Tools -&amp;gt; Serial Port-valikon alta oikea sarjaportti(minun tapauksessani “&#x2F;dev&#x2F;tty.usbmodemfa131”):
&lt;img src=&quot;&#x2F;school&#x2F;prototyping-course&#x2F;prototyypin-rakentaminen-arduinon-kehitysympariston-pystyttaminen-macille&#x2F;arduinoport.png&quot; alt=&quot;arduinoport&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Varmistetaan että Tools -&amp;gt; Board-valikossa on valittuna oikea ohjainmalli (Arduino Uno).&lt;&#x2F;p&gt;
&lt;p&gt;Ladataan piirilevylle vilkkuledi-esimerkki avaamalla File -&amp;gt; Examples -&amp;gt; Basics -&amp;gt; Blink:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;prototyping-course&#x2F;prototyypin-rakentaminen-arduinon-kehitysympariston-pystyttaminen-macille&#x2F;arduino_blink.png&quot; alt=&quot;arduino-blink&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Lopuksi painetaan Upload-painiketta, jolloin ohjelma käännetään ja syötetään piirilevylle muistiin. Jos kaikki meni oikein, Arduino-piirilevyllä pitäisi vilkkua keltainen LED-valo.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;lahteet&quot;&gt;Lähteet&lt;&#x2F;h1&gt;
&lt;ul&gt;
&lt;li&gt;Arduino Sofware Download (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;arduino.cc&#x2F;en&#x2F;Main&#x2F;Software&quot;&gt;http:&#x2F;&#x2F;arduino.cc&#x2F;en&#x2F;Main&#x2F;Software&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Prototyypin rakentaminen-kurssin aloitusluento, Tero karvinen (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;terokarvinen.com&#x2F;&quot;&gt;http:&#x2F;&#x2F;terokarvinen.com&#x2F;&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Prototyypin rakentaminen: Yksinkertaiset liikennevalot Arduinolla</title>
        <published>2013-04-02T00:00:00+00:00</published>
        <updated>2013-04-02T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/school/prototyping-course/prototyypin-rakentaminen-yksinkertaiset-liikennevalot-arduinolla/"/>
        <id>/school/prototyping-course/prototyypin-rakentaminen-yksinkertaiset-liikennevalot-arduinolla/</id>
        
        <content type="html" xml:base="/school/prototyping-course/prototyypin-rakentaminen-yksinkertaiset-liikennevalot-arduinolla/">&lt;p&gt;Päätin tehdä pienenä lediprojektina liikennevalot, jotka vaihtuvat tietyin väliajoin samalla tavalla kuin oikeatkin liikennevalot.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;tekninen-toteutus&quot;&gt;Tekninen toteutus&lt;&#x2F;h1&gt;
&lt;p&gt;Teknisesti toteutus ei ole kovin vaikea, tarvitaan vain kolme eriväristä ledia(punainen, keltainen ja vihreä), koekytkentälevy ja muutamia kytkentäjohtoja. Kytkin jokaisen ledin katodijalan(miinus&#x2F;maajalan) samaan riviin koekytkentärivillä, josta vedin johdon Arduinon maaliittimeen(GND). Kytkin ledien anodijalat(positiiviset johtimet) omiin riveihinsä, joista vedin jokaiselle oman värikoodatun johdon Arduinon digitaalisen puolen pinneihin 3,4 ja 5.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;prototyping-course&#x2F;prototyypin-rakentaminen-yksinkertaiset-liikennevalot-arduinolla&#x2F;liikennevalot_schem_pieni.png&quot; alt=&quot;liikennevalot-schem-pieni&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;prototyping-course&#x2F;prototyypin-rakentaminen-yksinkertaiset-liikennevalot-arduinolla&#x2F;liikennevalot_bb_pieni.png&quot; alt=&quot;liikennevalot-bb-pieni&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h1 id=&quot;ohjelmalogiikan-luominen&quot;&gt;Ohjelmalogiikan luominen&lt;&#x2F;h1&gt;
&lt;p&gt;Aloitin ohjelmalogiikan luomisen luonnostelemalla miten oikeat liikennevalot toimivat. Liikennevalothan kiertävät jatkuvasti samaa rataa: vihreästä keltaiseksi, keltaisesta punaiseksi ja yhtäaikaisesta punaisesta ja keltaisesta vihreäksi. Selkeämmin ilmaistuna: “vihreä -&amp;gt; keltainen -&amp;gt; punainen -&amp;gt; punainen+keltainen -&amp;gt; vihreä“.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;prototyping-course&#x2F;prototyypin-rakentaminen-yksinkertaiset-liikennevalot-arduinolla&#x2F;valologiikka.png&quot; alt=&quot;valologiikka&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h1 id=&quot;logiikan-toteutus-koodiksi&quot;&gt;Logiikan toteutus koodiksi&lt;&#x2F;h1&gt;
&lt;p&gt;Kun sain logiikan hiottua kuntoon, toteutin ohjelman koodiksi joka näyttää seuraavanlaiselta:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;*&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Liikennevalosovellus&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Tekijä: Joni Junni&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Pvm: 2.4.2013&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;*&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;int PUN_led = 3;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;int KELT_led = 4;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;int VIHR_led = 5;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;void setup() { &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	pinMode(PUN_led, OUTPUT);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	pinMode(KELT_led, OUTPUT);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	pinMode(VIHR_led, OUTPUT);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;void loop() {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;&#x2F; Vihreä valo palaa 10 sek&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	digitalWrite(PUN_led, LOW);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	digitalWrite(KELT_led, LOW);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	digitalWrite(VIHR_led, HIGH);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	delay(10000); &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;&#x2F; Keltainen palaa 3 sek&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	digitalWrite(PUN_led, LOW);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	digitalWrite(KELT_led, HIGH);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	digitalWrite(VIHR_led, LOW);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	delay(3000);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;&#x2F; Punainen palaa 10 sek&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	digitalWrite(PUN_led, HIGH);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	digitalWrite(KELT_led, LOW);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	digitalWrite(VIHR_led, LOW);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	delay(10000);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;&#x2F; Punainen ja keltainen palaa 1,5 sek&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	digitalWrite(PUN_led, HIGH);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	digitalWrite(KELT_led, HIGH);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	digitalWrite(VIHR_led, LOW);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	delay(1500);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h1 id=&quot;lopputulos&quot;&gt;Lopputulos&lt;&#x2F;h1&gt;
&lt;p&gt;Lopputuloksena on toimivat liikennevalot ledeistä jotka vaihtuvat omaa tahtia:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;prototyping-course&#x2F;prototyypin-rakentaminen-yksinkertaiset-liikennevalot-arduinolla&#x2F;lopputulos.jpg&quot; alt=&quot;lopputulos&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;prototyping-course&#x2F;prototyypin-rakentaminen-yksinkertaiset-liikennevalot-arduinolla&#x2F;valot.jpg&quot; alt=&quot;valot&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Linux palvelimena: deb-paketin teko ja repositoryn luominen</title>
        <published>2013-03-08T00:00:00+00:00</published>
        <updated>2013-03-08T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/school/linux-palvelimena/linux-palvelimena-deb-paketin-teko-ja-repositoryn-luominen/"/>
        <id>/school/linux-palvelimena/linux-palvelimena-deb-paketin-teko-ja-repositoryn-luominen/</id>
        
        <content type="html" xml:base="/school/linux-palvelimena/linux-palvelimena-deb-paketin-teko-ja-repositoryn-luominen/">&lt;p&gt;Tehtävän tarkoituksena on luoda yksinkertaiselle shell-skriptille deb-asennuspaketti, jotta sen voi helposti jaella pakettivaraston kautta ns. “orjakoneille”. Paketin luonnin jälkeen konfiguroidaan pakettivarasto (repository) paketin jakelua varten, allekirjoitetaan se sekä lisätään oma pakettivarasto orjakoneiden pakettivarastoihin.&lt;&#x2F;p&gt;
&lt;p&gt;Käytin harjoituksissa jo olemassa olevaa Debian-virtuaalikonetta seuraavilla spekseillä:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Käyttöjärjestelmä: Debian 6.0&lt;&#x2F;li&gt;
&lt;li&gt;RAM: 2048 Mb&lt;&#x2F;li&gt;
&lt;li&gt;HDD: 20 Gb&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h1 id=&quot;shell-skriptin-paketointi&quot;&gt;Shell-skriptin paketointi&lt;&#x2F;h1&gt;
&lt;p&gt;Aloitin tekemällä kotihakemistoon &lt;strong&gt;hello-world.sh&lt;&#x2F;strong&gt;-nimisen esimerkkiskriptin komenolla&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo nano hello-world.sh&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Tiedoston sisään kirjoitin yksinkertaisen rivin joka tulostaa “Hello, world!” näytölle.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-deb-paketin-teko-ja-repositoryn-luominen&#x2F;helloworldscript.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Skripti ei tässä tapauksessa tee mitään ihmeellistä, tulostaa vain “Hello, world!”-tekstin ruudulle ajettaessa. Hyödyllistä voisi olla paketoida esimerkiksi jokin yrityksen varmuuskopiointiskripti tms.&lt;&#x2F;p&gt;
&lt;p&gt;Paketointi onnistuu näppärästi equivs-työkalulla, joka löytyy vakiona ainakin Debianista ja Ubuntusta. Ensiksi asensin tarvittavat työkalut komennolla&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo apt-get install equivs lintian&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Tämän jälkeen tein kotihakemistoon “joni-hello-world”-nimisen hakemiston. Nimeä hakemisto yksilöllisesti, että samannimistä pakettia ei löydy jo järjestelmästä. Hyvä nimeämistapa on esimerkiksi “organisaationnimi-paketin-tarkoitus”. Hakemiston luomisen jälkeen siirrytään kyseiseen hakemistoon ja ajetaan siellä equivs-control, joka luo hakemistoon tyhjän asetustiedoston:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mkdir joni-hello-world&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;cd joni-hello-world&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;equivs-control joni-hello-world.cfg&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Sitten avasin equivs-controlin luoman asetustiedoston ja muokkasin sinne omat tietoni. Huomattavaa on, että Files-riville pitää määritellä tuo skriptitiedoston polku mikä aikaisemmin luotiin parina kuten asetustiedostossa ohjeistetaan.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-deb-paketin-teko-ja-repositoryn-luominen&#x2F;joni-hello-world-cfg.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Tämän jälkeen kopioin skriptin paketin omaan hakemistoon joka luotiin aiemmin komennolla&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;cp ..&#x2F;hello-world.sh .&#x2F;hello-world.sh&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Kun asetustiedoston kohdat on määritelty ja poistettu kommenttimerkit muokatuilta riveiltä, voidaan ajaa paketointikomento equivs-build:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;equivs-build joni-hello-world.cfg&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Ja tämän jälkeen testataan lintianilla paketin toimivuus:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;lintian joni-hello-world_1.0.2_all.deb&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Jos lintian menee virheittä läpi, paketti on sääntöjen mukainen. Itselläni tuli muutama varoitus johtuen siitä että skripti laitettiin binäärihakemistoon tiedostopäätteen kera ja ilman man-sivuja:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-deb-paketin-teko-ja-repositoryn-luominen&#x2F;lintianwarnings.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h1 id=&quot;pakettivaraston-luominen&quot;&gt;Pakettivaraston luominen&lt;&#x2F;h1&gt;
&lt;p&gt;Pakettivaraston (repositoryn) luomista varten koneella pitää olla Apache konfiguroituna. Tein &#x2F;var&#x2F;www-hakemiston alle hakemiston “apt” johon aion pakettivaraston tehdä sekä sen alle “conf”-hakemisto jossa sijaitsee asetustiedosto jonka luon myöhemmin.&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo mkdir apt&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo mkdir apt&#x2F;conf&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo apt-get install reprepro&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Jälkimmäisellä komennolla asensin reprepron, joka on työkalu pakettivaraston luomiseen.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;asetustiedoston-luominen&quot;&gt;Asetustiedoston luominen&lt;&#x2F;h2&gt;
&lt;p&gt;apt&#x2F;conf-hakemiston alle loin asetustiedoston “distributions” johon syötin seuraavanlaiset rivit:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Origin: Joni Junni&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Label: Oma repository&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Suite: stable&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Codename: squeeze&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Version: 6.0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Architectures: i386 amd64&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Components: main non-free contrib&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Description: Mun oma repository&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;SignWith: yes&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Tärkeimpiä rivejä tuossa ovat lähinnä &lt;strong&gt;codename&lt;&#x2F;strong&gt;, &lt;strong&gt;version&lt;&#x2F;strong&gt;, &lt;strong&gt;architectures,&lt;&#x2F;strong&gt; **components **sekä &lt;strong&gt;SignWith&lt;&#x2F;strong&gt;. Näiden perusteella orjakoneet määrittelevät ovatko pakettivaraston paketit niille sopivia. SignWith määrittelee että pakettivarasto tulee allekirjoittaa.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;avaimen-luominen-pakettivarastoa-varten&quot;&gt;Avaimen luominen pakettivarastoa varten&lt;&#x2F;h2&gt;
&lt;p&gt;Avaimen luonti tapahtuu komennolla&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo gpg --gen-key&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Kannattaa huomata että käytän tässä ohjeessa sudoa, koska määritin pakettivarastoni sijainniksi &#x2F;var&#x2F;www-hakemiston joka ei ole normaalin käyttäjän muokattavissa. Koska repreprota joutuu ajamaan sudona tästä syystä myös, on gpg-avain luotava sudona myöskin jotta reprepro suostuu allekirjoittamaan pakettivaraston.&lt;&#x2F;p&gt;
&lt;p&gt;Ohjelma kyselee sinulta tietoja avaimen luontia varten. Itse laitoin seuraavanlaiset asetukset:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Vaihtoehto 1 RSA&lt;&#x2F;li&gt;
&lt;li&gt;Pituudeksi laitoin oletusavaimen 2048&lt;&#x2F;li&gt;
&lt;li&gt;Avaimen kestoksi 1 vuosi&lt;&#x2F;li&gt;
&lt;li&gt;Oma nimi+ sähköpostiosoite&lt;&#x2F;li&gt;
&lt;li&gt;Salasanaksi salasana1 (käytä jotakin vahvempaa)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Seuraavaksi exporttasin allekirjoitusavaimen komennolla&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo gpg --armor --export *sähköpostiosoite* --output gpgkey.gpg.key&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Ylempi komento ei jostakin syystä tee tiedostoa parametristä huolimatta, vaan tulostaa avaimen näytölle. Kopioin avaimen ja tallensin sen tuonnimiseen tiedostoon. Tämä tiedosto tallennetaan pakettivaraston yhteyteen jotta orjakoneet voivat varmistaa pakettivaraston oikeellisuuden.&lt;&#x2F;p&gt;
&lt;p&gt;Seuraavaksi ajetaan reprepro. Varmistetaan että ollaan siellä hakemistossa mihin repo halutaan luoda ja sen jälkeen ajetaan reprepro:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;cd &#x2F;var&#x2F;www&#x2F;apt&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo reprepro -Vb . includedeb squeeze &#x2F;home&#x2F;joni&#x2F;joni-hello-world&#x2F;joni-hello-world_1.0.2_all.deb&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Jos repreprop meni virheettä läpi, meillä on toimiva pakettivarasto:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-deb-paketin-teko-ja-repositoryn-luominen&#x2F;repo.png&quot; alt=&quot;Kuvassa selaimeen avattuna Apachen tarjoilema pakettivaraston juuri.&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h1 id=&quot;pakettivaraston-maarittely-orjakoneille&quot;&gt;Pakettivaraston määrittely orjakoneille&lt;&#x2F;h1&gt;
&lt;p&gt;Orjakoneille täytyy siis enään tuoda julkinen avain pakettivaraston autentikointia varten sekä lisätä pakettivaraston osoite &#x2F;etc&#x2F;sources.list-tiedostoon. Lisätään avain koneelle komennolla:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;wget -O - http:&#x2F;&#x2F;srv-deb2&#x2F;apt&#x2F;gpgkey.gpg.key | sudo apt-key add -&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Tämän jälkeen lisätään &#x2F;etc&#x2F;apt&#x2F;sources.list-tiedostoon uusi rivi pakettivarastolle:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;deb http:&#x2F;&#x2F;srv-deb2&#x2F;apt&#x2F; squeeze main&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Lopuksi testataan että pakettivarasto toimii ja paketti löytyy aptista:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo apt-get update&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo apt-cache search joni&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Ensimmäisellä komennolla päivitettiin aptin välimuisti jolloin se haki uuden pakettivaraston pakettilistauksen. Jälkimmäisellä haetaan aptista uuden paketin tiedot näytölle:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-deb-paketin-teko-ja-repositoryn-luominen&#x2F;lopputulos.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Viimeiselllä rivillä näkyy itse tehty paketti valmiina asennettavaksi. Asennus tapahtuu niinkuin minkä tahansa muunkin paketin komennolla&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo apt-get install joni-hello-world&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h1 id=&quot;lahteet&quot;&gt;Lähteet&lt;&#x2F;h1&gt;
&lt;ul&gt;
&lt;li&gt;Howto: create “configuration packages” with equivs (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;ubuntuforums.org&#x2F;showthread.php?t=726317&quot;&gt;http:&#x2F;&#x2F;ubuntuforums.org&#x2F;showthread.php?t=726317&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Creating your own Signed APT repository and Debian packages (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;blog.jonliv.es&#x2F;2011&#x2F;04&#x2F;26&#x2F;creating-your-own-signed-apt-repository-and-debian-packages&#x2F;&quot;&gt;http:&#x2F;&#x2F;blog.jonliv.es&#x2F;2011&#x2F;04&#x2F;26&#x2F;creating-your-own-signed-apt-repository-and-debian-packages&#x2F;&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Setting up your own APT repository with upload support (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;www.debian-administration.org&#x2F;articles&#x2F;286&quot;&gt;http:&#x2F;&#x2F;www.debian-administration.org&#x2F;articles&#x2F;286&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Setting up a personal debian repository (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;ianlawrence.info&#x2F;random-stuff&#x2F;setting-up-a-personal-debian-repository&quot;&gt;http:&#x2F;&#x2F;ianlawrence.info&#x2F;random-stuff&#x2F;setting-up-a-personal-debian-repository&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Tero Karvinen: Metapaketit-luento (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;www.terokarvinen.com&quot;&gt;http:&#x2F;&#x2F;www.terokarvinen.com&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt; &lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Linux palvelimena: Web-palvelimen optimointi Varnishilla</title>
        <published>2013-02-17T00:00:00+00:00</published>
        <updated>2013-02-17T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/school/linux-palvelimena/linux-palvelimena-web-palvelimen-optimointi-varnishilla/"/>
        <id>/school/linux-palvelimena/linux-palvelimena-web-palvelimen-optimointi-varnishilla/</id>
        
        <content type="html" xml:base="/school/linux-palvelimena/linux-palvelimena-web-palvelimen-optimointi-varnishilla/">&lt;p&gt;17.2.2013 klo 13.21&lt;&#x2F;p&gt;
&lt;p&gt;Tehtävänä oli asentaa johonkin web-palvelimeen Varnish-käänteisproxy ja testata sillä web-palvelun mahdollista nopeutumista. Päätin tälläkertaa tehdä tehtävän käyttäen Vagrantissa ajettavaa virtuaalikonetta käyttäen. Fyysisenä laitteistona toimii Lenovo Thinkpad T410 seuraavilla specseillä:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Intel Core i5-480-prosessori&lt;&#x2F;li&gt;
&lt;li&gt;8Gt RAM&lt;&#x2F;li&gt;
&lt;li&gt;60Gt SSD+500Gt 5400 RPM HDD&lt;&#x2F;li&gt;
&lt;li&gt;Intel Quadro NVS 3100M 512Mt-näytönohjain&lt;&#x2F;li&gt;
&lt;li&gt;Käyttöjärjestelmä: Xubuntu 12.04 64-bit&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h1 id=&quot;vagrantin-konfigurointi&quot;&gt;Vagrantin konfigurointi&lt;&#x2F;h1&gt;
&lt;p&gt;Koneessa oli jo aikasemmin asentamani Vagrant, mutta virtuaalikone siitä puuttui. Hain uuden virtuaalikoneen siihen komennolla (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;docs.vagrantup.com&#x2F;v1&#x2F;docs&#x2F;getting-started&#x2F;index.html&quot;&gt;Vagrant Get Started documentation&lt;&#x2F;a&gt;):&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;vagrant box add lucid32 http:&#x2F;&#x2F;files.vagrantup.com&#x2F;lucid32.box&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Latauksen meni n. 10 minuuttia hitaasta yhteydestä johtuen. kun lataus valmistui, ajoin komennot&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;vagrant init lucid32&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;vagrant up&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;vagrant ssh&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Ylin komento luo Vagrantfile-nimisen tiedoston joka sisältää virtuaalikoneen asetukset sen käyttöönottoa varten. Keskimmäinen komento käynnistää virtuaalikoneen ja viimeinen ottaa SSH-yhteyden koneeseen.&lt;&#x2F;p&gt;
&lt;p&gt;Seuraavaksi asensin virtuaalikoneeseen LAMP-stackin. En mene tässä postauksessa keskity LAMPin asennukseen, tarkemmat yksityiskohdat LAMP:n ja wordpressin konfigurointiin löydät täältä: &lt;a href=&quot;&#x2F;blog&#x2F;linux-palvelimena-lamp-stackin-ja-wordpressin-asennus-konfigurointi&#x2F;&quot;&gt;https:&#x2F;&#x2F;jonijunni.com&#x2F;blog&#x2F;linux-palvelimena-lamp-stackin-ja-wordpressin-asennus-konfigurointi&#x2F;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;vagrantin-virtuaalikoneen-http-porttiohjaus&quot;&gt;Vagrantin virtuaalikoneen HTTP-porttiohjaus&lt;&#x2F;h2&gt;
&lt;p&gt;Jotta virtuaalikoneen Apachen saa näkymään paikallisella koneella, pitää poistaa kommentointi Vagrantfilen rivillä “config.vm.forward_port 80, 8080”.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-web-palvelimen-optimointi-varnishilla&#x2F;apacheporttiohjaus.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Kun Vagrantfilestä on tuo muokkaus tehty, voidaan virtuaalikone käynnistää uudelleen komennolla:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;vagrant reload&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Testataan ohjauksen toimivuus avaamalla osoite localhost:8080 selaimessa:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-web-palvelimen-optimointi-varnishilla&#x2F;apachetoimii1.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h1 id=&quot;varnishin-asennus&quot;&gt;Varnishin asennus&lt;&#x2F;h1&gt;
&lt;p&gt;Asensin Varnishin komennolla:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo apt-get install varnish&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;apachen-porttimuutokset&quot;&gt;Apachen porttimuutokset&lt;&#x2F;h2&gt;
&lt;p&gt;Koska Varnish oletuksena on määritelty kuuntelemaan porttia 8080, muutetaan Apachen portiksi 8080. Aluksi muokataan &#x2F;etc&#x2F;apache2&#x2F;ports.conf-tiedostoa:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-web-palvelimen-optimointi-varnishilla&#x2F;apache_porttimuutos1.png&quot; alt=&quot;Muokkaa NameVirtualHost- ja Listen-rivejä niin että ne kuuntelevat porttia 8080 portin 80 sijasta.&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Sitten muokataan tiedostoa &#x2F;etc&#x2F;apache2&#x2F;sites-enabled&#x2F;000-default:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-web-palvelimen-optimointi-varnishilla&#x2F;apache_porttimuutos2.png&quot; alt=&quot;Muuta VirtualHost-riviä niin että se kuuntelee porttia 8080.&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Koska käytän vagrantia, minun pitäisi muuttaa porttiohjausta niin, että apacheen määritetty uusi portti ohjautuisi oikein. En tee sitä, koska tiedän muutoksen onnistuneen kun apache ei enää vastaa portissa 8080:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-web-palvelimen-optimointi-varnishilla&#x2F;apache_porttimuutos3.png&quot; alt=&quot;apache_porttimuutos3&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Kannattaa huomata, että paikallisessa koneessa portit ovat ohjattuna eri tavalla virtuaalikoneeseen kuin mitä virtuaalikoneessa on ohjattuna. Esimerkiksi Apacheen tehty porttimuutos EI vaikuta Vagrantissa tehtyihin porttiohjauksiin. Jos muuttaisin Vagrantfilen “config.vm.forward_port 80, 8080”-asetusta muotoon “config.vm.forward_port 8080, 8080”, saisin Apachen tarjoaman sivuston taas näkyviin. Mutta en tee niin nyt koska päämääränä oli saada Varnish Apachen ja asiakkaan välille proxyksi.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;varnishin-porttimuutokset&quot;&gt;Varnishin porttimuutokset&lt;&#x2F;h2&gt;
&lt;p&gt;Varnishin asetukset löytyvät kahdesta paikkaa: &#x2F;etc&#x2F;default&#x2F;varnish-tiedostosta sekä &#x2F;etc&#x2F;varnish&#x2F;default.vcl. Ensimmäisestä tiedostosta löytyy asetukset mitä asetuksia Varnishin käynnistykseen käytetään ja jälkimmäisessä on sisältöpalvelimen asetukset.&lt;&#x2F;p&gt;
&lt;p&gt;Muokataan &#x2F;etc&#x2F;default&#x2F;varnish-tiedostoa ja määritetään Varnish kuuntelemaan porttia 80 portin 6081 sijaan:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo nano &#x2F;etc&#x2F;default&#x2F;varnish&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-web-palvelimen-optimointi-varnishilla&#x2F;varnish_porttimuutos.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Oletuksena Varnish on määritetty hakemaan sisältöä osoitteesta 127.0.0.1 portista 8080 (määritetty tiedostossa &#x2F;etc&#x2F;varnish&#x2F;default.vcl), joten minun ei tarvinnut muokata kyseistä tiedostoa. Lopuksi käynnistetään molemmat palvelut:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo service apache2 start&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo service varnish start&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Ja testataan selaimella näkyykö taas WordPress-sivusto:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-web-palvelimen-optimointi-varnishilla&#x2F;varnish_toimii.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;optimoinnin-testaus&quot;&gt;Optimoinnin testaus&lt;&#x2F;h2&gt;
&lt;p&gt;Testasin Varnishin vaikutusta sivuston nopeuteen ab-ohjelmalla.&lt;br &#x2F;&gt;
Kaikki testit on tehty virtuaalikoneen sisällä ssh-yhteyden kautta.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-web-palvelimen-optimointi-varnishilla&#x2F;testaus_apacheen.png&quot; alt=&quot;Kuormitustesti suoraan Apacheen ilman Varnishia välissä&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-web-palvelimen-optimointi-varnishilla&#x2F;testaus_varnishiin.png&quot; alt=&quot;Kuormitustesti Varnishiin&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Kun vertaamme tuloksia Apachen ja Varnishin välillä, huomaamme valtavia eroja. Apachella jopa 58 pyyntöä epäonnistuu! Tutkiessani tarkemmin asiaa, vaikuttaisi siltä että palvelimesta loppuu resurssit palvella asiakkaita:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-web-palvelimen-optimointi-varnishilla&#x2F;testaus_apacheen_top1.png&quot; alt=&quot;Kuvankaappaus top-ohjelmasta samaan aikaan kun ab kuormittaa Apachea suoraan.&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Ero on merkittävä Varnishiin verrattuna. Varnishissa alkaa ilmenemään epäonnistuvia pyyntöjä vasta 1000 samanaikaisella pyynnöllä 1000 asiakkaalta samaan aikaan:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-web-palvelimen-optimointi-varnishilla&#x2F;testaus_varnishiin_1000x1000.png&quot; alt=&quot;Kuormitustesti Varnishiin 1000 samanaikaisella pyynnöllä 1000 asiakkaalta&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Varnish ei myöskään aiheuta samanlaisia pitkäaikaisia kuormapiikkejä prosessorille kuin Apache.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;iso-tiedostojen-valimuistittamisen-ohitus-varnishista&quot;&gt;ISO-tiedostojen välimuistittamisen ohitus Varnishista&lt;&#x2F;h2&gt;
&lt;p&gt;Yritin muuttaa default.vcl-tiedostoa niin että Varnish cachettaisi niitä välimuistiin vaan lataisi ne suoraan Apachesta. Laitoin seuraavan rimpsun tiedostoon:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sub vcl_recv {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        if(req.url ~ &amp;quot;^&#x2F;~vagrant&#x2F;isos&#x2F;&amp;quot;) {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                return (pass);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Jostakin syystä Varnishin kautta iso-tiedostoja noutaessa selaimeen tulee Connection Reset-virhe. Myöskään wgetillä tiedostoa ei saa hostilla noudettua, mutta paikallisesti saa ssh:n kautta. Syytä en ongelmalle keksinyt mutta oletan sen johtuvan porttiohjauksista Vagrantin kanssa. Linkki varnishin lokiin kiinnostuneille:  &lt;a href=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-web-palvelimen-optimointi-varnishilla&#x2F;varnish.txt&quot;&gt;varnishlog.txt&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h1 id=&quot;lahteet&quot;&gt;Lähteet&lt;&#x2F;h1&gt;
&lt;ul&gt;
&lt;li&gt;Vagrant Getting Started Guide (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;docs.vagrantup.com&#x2F;v1&#x2F;docs&#x2F;getting-started&#x2F;index.html&quot;&gt;http:&#x2F;&#x2F;docs.vagrantup.com&#x2F;v1&#x2F;docs&#x2F;getting-started&#x2F;index.html&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Tero Karvinen: Optimointi-luento (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2012&#x2F;aikataulu-linux-palvelimena-ict4tn003-7-ict4tn003-kevaalla-2013&quot;&gt;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2012&#x2F;aikataulu-linux-palvelimena-ict4tn003-7-ict4tn003-kevaalla-2013&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Introduction to Varnish (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;www.c50k.com&#x2F;varnish-cache.html&quot;&gt;http:&#x2F;&#x2F;www.c50k.com&#x2F;varnish-cache.html&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Linux palvelimena: LAMP-stackin ja WordPressin asennus &amp; konfigurointi</title>
        <published>2013-02-11T00:00:00+00:00</published>
        <updated>2013-02-11T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/school/linux-palvelimena/linux-palvelimena-lamp-stackin-ja-wordpressin-asennus-konfigurointi/"/>
        <id>/school/linux-palvelimena/linux-palvelimena-lamp-stackin-ja-wordpressin-asennus-konfigurointi/</id>
        
        <content type="html" xml:base="/school/linux-palvelimena/linux-palvelimena-lamp-stackin-ja-wordpressin-asennus-konfigurointi/">&lt;p&gt;11.2.2013 klo 15.16&lt;&#x2F;p&gt;
&lt;p&gt;Tehtävänä oli asentaa koneelle LAMP-stack ja sen päälle asentaa ja konfiguroida WordPress.&lt;&#x2F;p&gt;
&lt;p&gt;Tällä kertaa päätin tehdä tehtävän kannettavalla VirtualBoxin päällä. Latasin VirtualBoxin Windows-version koneelleni täältä: &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;download.virtualbox.org&#x2F;virtualbox&#x2F;4.2.6&#x2F;VirtualBox-4.2.6-82870-Win.exe&quot;&gt;http:&#x2F;&#x2F;download.virtualbox.org&#x2F;virtualbox&#x2F;4.2.6&#x2F;VirtualBox-4.2.6-82870-Win.exe&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;VirtualBoxin latautuessa latasin Xubuntu 12.10 32-bittisen version levykuvan täältä: &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;se.archive.ubuntu.com&#x2F;mirror&#x2F;cdimage.ubuntu.com&#x2F;xubuntu&#x2F;releases&#x2F;12.10&#x2F;release&#x2F;xubuntu-12.10-desktop-i386.iso&quot;&gt;http:&#x2F;&#x2F;se.archive.ubuntu.com&#x2F;mirror&#x2F;cdimage.ubuntu.com&#x2F;xubuntu&#x2F;releases&#x2F;12.10&#x2F;release&#x2F;xubuntu-12.10-desktop-i386.iso&lt;br &#x2F;&gt;
&lt;&#x2F;a&gt;Latasin 32-bittisen version lähinnä siksi, etten virtuaalikoneessa aio käyttää yli 3,5 gigaa muistia.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;virtualboxin-asennus&quot;&gt;VirtualBoxin asennus&lt;&#x2F;h1&gt;
&lt;p&gt;VirtualBoxin asennus oli nopea eikä vaatinut erityisesti mitään säädettävää. Huomattavaa on, että asennus katkaisee hetkeksi verkkoyhteydet asentaessaan virtuaalisia verkkokortteja(tuli opittua tämä kantapään kautta kun levykuvan lataaminen katkesi asennuksen aikana).&lt;&#x2F;p&gt;
&lt;h2 id=&quot;uuden-virtuaalikoneen-luominen&quot;&gt;Uuden virtuaalikoneen luominen&lt;&#x2F;h2&gt;
&lt;p&gt;Lisäsin Virtualboxiin uuden virtuaalikoneen ja käytin pohjana Ubuntun asetuksia jotka konfigurointivelho valitsi automaattisesti. Asetuksiksi määritin seuraavat:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Nimi: srv-test1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Konetyyppi: Linux - Ubuntu&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;RAM: 512 Mb&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;HDD: 8 Gb&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Network: Bridged Adapter, liitetty fyysiseen WLANiin&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Tämän jälkeen kävin lisäämässä virtuaalikoneen asetuksista Xubuntun levykuvan levyasemaan buuttaamista varten.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-lamp-stackin-ja-wordpressin-asennus-konfigurointi&#x2F;levymounttaus.png&quot; alt=&quot;levymounttaus&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Seuraavaksi käynnistin virtuaalikoneen joka käynnistyi live-imagelta. Asensin imagen koneen virtuaalilevylle jotta olisi tilaa asentaa LAMP:in osat. Asennus meni ripeästi eikä vaatinut mitään erityisiä säätöjä. Määritin seuraavat asetukset:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Asennus koko levylle&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Näppäimistökartta: Suomi&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Aikavyöhyke: Helsinki&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Konenimi: Joni-Virtualbox&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h1 id=&quot;lamp-asennus&quot;&gt;LAMP asennus&lt;&#x2F;h1&gt;
&lt;p&gt;Aloitin asentamalla SSH-daemonin virtuaalikoneeseen jotta voin käyttää konetta Puttyn kautta:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo apt-get install ssh&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Seuraavaksi asensin Apachen, MySQL:n ja PHP:n virtuaalikoneeseen:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo apt-get update&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo apt-get install apache2 libapache2-mod-php5 mysql-server&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;MySQL-palvelimen salasanaksi määritin &lt;strong&gt;SuperUser12#&lt;&#x2F;strong&gt;. Testasin Apachen toimivuuden avaamalla selaimessa palvelimen osoitteen 10.40.1.141:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-lamp-stackin-ja-wordpressin-asennus-konfigurointi&#x2F;apachetoimii.png&quot; alt=&quot;apachetoimii&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;kotihakemistot-php-lla-kayttoon&quot;&gt;Kotihakemistot PHP:llä käyttöön&lt;&#x2F;h2&gt;
&lt;p&gt;Otin käyttöön käyttäjien kotisivut Apachessa ja loin omalle käyttäjälleni kotisivuhakemiston sekä PHP:n testaustiedoston komennoilla:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo a2enmod userdir&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo &#x2F;etc&#x2F;init.d&#x2F;apache2 restart&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mkdir mkdir ~&#x2F;public_html&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;echo &amp;quot;&amp;lt;?php echo \&amp;quot;hei maailma\&amp;quot;; ?&amp;gt;&amp;quot; &amp;gt;&amp;gt; ~&#x2F;public_html&#x2F;index.php&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Lopuksi käydään vielä kommentoimassa pois muutama rivi &#x2F;etc&#x2F;apache2&#x2F;mods-enabled&#x2F;php5.conf-tiedostosta jotta saadaan käyttäjien kotisivuille PHP5 käyttöön ja käynnistetään Apache uudelleen:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo nano &#x2F;etc&#x2F;apache2&#x2F;mods-enabled&#x2F;php5.conf&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo &#x2F;etc&#x2F;init.d&#x2F;apache2 restart&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-lamp-stackin-ja-wordpressin-asennus-konfigurointi&#x2F;userdir_php5_comment.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Lopuksi testataan että käyttäjän nettisivut toimivat PHP:llä:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-lamp-stackin-ja-wordpressin-asennus-konfigurointi&#x2F;userdir_toimii.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;uuden-kayttajan-tietokannan-luominen-mysql-palvelimeen-wp-ta-varten&quot;&gt;Uuden käyttäjän+tietokannan luominen MySQL-palvelimeen WP:tä varten&lt;&#x2F;h2&gt;
&lt;p&gt;Tein tietokannan &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;www.linux.org&#x2F;article&#x2F;view&#x2F;create-mysql-database-via-command-line&quot;&gt;näillä ohjeilla&lt;&#x2F;a&gt;. Avasin yhteyden MySQL-palvelimeen komennolla:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mysql -u root -p&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Jonka jälkeen syötin MySQL-palvelimen root-käyttäjän salasanan. Loin WordPressiä varten uuden tietokannan nimeltä “&lt;strong&gt;wordpress_joni&lt;&#x2F;strong&gt;” ja sille käyttäjän “&lt;strong&gt;wp_joni&lt;&#x2F;strong&gt;” salasanalla “&lt;strong&gt;zareje@ebuf@as!5=tAQ-wr&amp;amp;dephEka9&lt;&#x2F;strong&gt;“:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;CREATE DATABASE wordpress_joni;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;GRANT ALL PRIVILEGES ON wordpress_joni.* TO wp_joni@localhost IDENTIFIED BY &amp;#39;zareje@ebuf@as!5=tAQ-wr&amp;amp;dephEka9&amp;#39;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Lopuksi annoin vielä komennon “quit” jolla poistutaan MySQL-konsolista.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;wordpressin-asennus&quot;&gt;WordPressin asennus&lt;&#x2F;h1&gt;
&lt;p&gt;Hain WordPressin asennuspaketin ja purin paketin ja siirsin puretut tiedostot public_html-hakemistoon komennoilla:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;wget http:&#x2F;&#x2F;fi.wordpress.org&#x2F;wordpress-3.5.1-fi.tar.gz&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;tar -xf wordpress-3.5.1-fi.tar.gz&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mv wordpress&#x2F;* .&#x2F;public_html&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Sitten yritin saada WordPressin asennusta käyntiin mutta sain virheilmoituksen PHP:n puuttuvasta laajennoksesta:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-lamp-stackin-ja-wordpressin-asennus-konfigurointi&#x2F;php-mysql-puuttuu.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Ongelma korjautui asentamalla php5-mysql-paketti:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo apt-get install php5-mysql&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Asennuksen jälkeen asetusvelho avautuikin ja sain syötettyä tietokannan tiedot kenttiin jonka jälkeen pyydettiin manuaalisesti luomaan wp-config.php-tiedosto. Loin uuden tiedoston nanolla ja liitin sinne velhon antaman tekstin:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nano wp-config.php&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-lamp-stackin-ja-wordpressin-asennus-konfigurointi&#x2F;wp-settings.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-lamp-stackin-ja-wordpressin-asennus-konfigurointi&#x2F;wp-config-nano.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Kun wp-config-tiedosto saatiin luotua, jatkoin asennusta ja määritin sivuston nimen, käyttäjänimen, salasanan sekä sähköpostiosoitteen. Salasanaksi määritin “&lt;strong&gt;WordPress12#&lt;&#x2F;strong&gt;” testaustarkoituksissa. Lopputuloksena meillä on toimiva WordPress-sivusto:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-lamp-stackin-ja-wordpressin-asennus-konfigurointi&#x2F;valmis-wp-asennus.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h1 id=&quot;wordpressin-konfigurointi&quot;&gt;WordPressin konfigurointi&lt;&#x2F;h1&gt;
&lt;h2 id=&quot;permalinks-kayttoon&quot;&gt;Permalinks käyttöön&lt;&#x2F;h2&gt;
&lt;p&gt;Jotta sivuston linkit näyttäisivät siisteiltä ja luettavilta, laitoin WordPressistä permalinksit käyttöön. Asetukset löytyivät kohdasta &lt;strong&gt;Asetukset-&amp;gt;Osoiterakenne&lt;&#x2F;strong&gt; Dashboardista. Valitsin asetukseksi toisen vaihtoehdon jossa on vuosi,kuukausi,päivä sekä otsikko:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-lamp-stackin-ja-wordpressin-asennus-konfigurointi&#x2F;permalinks.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Asetuksien tallennuksen jälkeen WP huomautti ettei .htaccess-tiedostoon voida kirjoittaa ja että minun pitää tehdä muutokset itse. Kopioin tekstin alta, avasin tiedoston nanolla ja liitin tekstin sinne:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nano .htaccess&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Aktivoidaan vielä Apachen Rewrite-moduuli jotta tuo muutos toimisi palvelimella:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo a2enmod rewrite&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo &#x2F;etc&#x2F;init.d&#x2F;apache2 restart&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Nyt permalinkkien pitäisi toimia. Testataan vielä selaimella:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-lamp-stackin-ja-wordpressin-asennus-konfigurointi&#x2F;permalinks-toimii.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Osoite on määritetyssä muodossa joten permalinkit toimivat.&lt;&#x2F;p&gt;
&lt;p&gt;17.25&lt;&#x2F;p&gt;
&lt;h2 id=&quot;esimerkkipostauksen-teko-teeman-vaihto&quot;&gt;Esimerkkipostauksen teko, teeman vaihto&lt;&#x2F;h2&gt;
&lt;p&gt;Teeman vaihto WP:ssä onnistuu Dashboardin Ulkoasu -&amp;gt; Teemat-valikon kautta. Esimerkkiartikkeli luotuna ja teema vaihdettuna:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-lamp-stackin-ja-wordpressin-asennus-konfigurointi&#x2F;esimerkkiteema.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;oman-teeman-teko-wordpressiin&quot;&gt;Oman teeman teko WordPressiin&lt;&#x2F;h2&gt;
&lt;p&gt;Tein oman teeman WordPressiin tämän tutoriaalin avulla: &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;www.siteground.com&#x2F;tutorials&#x2F;wordpress&#x2F;wordpress_create_theme.htm&quot;&gt;http:&#x2F;&#x2F;www.siteground.com&#x2F;tutorials&#x2F;wordpress&#x2F;wordpress_create_theme.htm&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Aloitin teeman teon luomalla omateema-hakemiston wp-content&#x2F;themes-hakemistoon jossa teemat sijaitsevat:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mkdir omateema&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Tämän jälkeen loin header.php, footer.php, index.php, sidebar.php ja style.css-tiedostot joihin kopioin tutoriaalin koodit pohjaksi. Testasin toimiiko pohja laittamalla ensin Dashboardista oletusteemaksi luomani teeman ja vilkaisin toimiiko se selaimessa:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-lamp-stackin-ja-wordpressin-asennus-konfigurointi&#x2F;rujoteema.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Muokkasin teemaa vähän vähemmän rujoksi, tosin lopputulos ei oikeastaan silmiä hivele:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-lamp-stackin-ja-wordpressin-asennus-konfigurointi&#x2F;variwp.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;wordpressin-varmuuskopioiminen&quot;&gt;WordPressin varmuuskopioiminen&lt;&#x2F;h2&gt;
&lt;p&gt;WordPressin varmuuskopioiminen onnistuu näppärästi Dasboardin kautta &lt;strong&gt;Työkalut -&amp;gt; Vie&lt;&#x2F;strong&gt; -valikosta. Valitsin kopioitavaksi kaiken sisällön.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;palomuurin-asentaminen-ja-konfiguroiminen&quot;&gt;Palomuurin asentaminen ja konfiguroiminen&lt;&#x2F;h2&gt;
&lt;p&gt;Konfiguroin palomuurin sallimaan yhteydet porttiin 80(HTTP) ja 22(SSH) seuraavilla komennoilla:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo ufw allow 80&#x2F;tcp&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo ufw allow 22&#x2F;tcp&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Lopuksi käynnistin palomuurin ja tarkistin säännöt komennoilla:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo ufw enable&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo ufw status&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Tuloksena portit 80 ja 22 on sallittuna sisäänpäin:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-lamp-stackin-ja-wordpressin-asennus-konfigurointi&#x2F;ufwstatus.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h1 id=&quot;lahteet&quot;&gt;Lähteet&lt;&#x2F;h1&gt;
&lt;ul&gt;
&lt;li&gt;Create MySQL database from command line (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;www.linux.org&#x2F;article&#x2F;view&#x2F;create-mysql-database-via-command-line&quot;&gt;http:&#x2F;&#x2F;www.linux.org&#x2F;article&#x2F;view&#x2F;create-mysql-database-via-command-line&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Tero Karvinen: Sisällönhallintajärjestelmät-luento (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2012&#x2F;aikataulu-linux-palvelimena-ict4tn003-7-ict4tn003-kevaalla-2013&quot;&gt;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2012&#x2F;aikataulu-linux-palvelimena-ict4tn003-7-ict4tn003-kevaalla-2013&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Creating WordPress theme (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;www.siteground.com&#x2F;tutorials&#x2F;wordpress&#x2F;wordpress_create_theme.htm&quot;&gt;http:&#x2F;&#x2F;www.siteground.com&#x2F;tutorials&#x2F;wordpress&#x2F;wordpress_create_theme.htm&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Linux palvelimena: Apache ja virtualhostit</title>
        <published>2013-02-02T00:00:00+00:00</published>
        <updated>2013-02-02T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/school/linux-palvelimena/linux-palvelimena-apache-ja-virtualhostit/"/>
        <id>/school/linux-palvelimena/linux-palvelimena-apache-ja-virtualhostit/</id>
        
        <content type="html" xml:base="/school/linux-palvelimena/linux-palvelimena-apache-ja-virtualhostit/">&lt;p&gt;2.2.2012 klo 12.16&lt;&#x2F;p&gt;
&lt;p&gt;Tämän viikon kotitehtävässä olisi tarkoitus konfiguroida Apacheen pari virtuaalihostia ja tutkailla niiden toimintaa. Tälläkertaa ajattelin tehdä tehtävän vähän eritavalla kuin aikaisemmin: asentaa virtuaalikoneen ESXi-hostilleni ja tehdä harjoitukset siellä.&lt;&#x2F;p&gt;
&lt;p&gt;Aloitin tehtävän kirjautumalla ESXi-hostille VMWaren vSphere Client-softalla, jolla hallitaan ESXi- ja vCenter-palvelimia:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-apache-ja-virtualhostit&#x2F;vmware-login.png&quot; alt=&quot;vmware-login&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h1 id=&quot;virtuaalikoneen-luominen-ja-asentaminen-harjoitusta-varten&quot;&gt;Virtuaalikoneen luominen ja asentaminen harjoitusta varten&lt;&#x2F;h1&gt;
&lt;p&gt;Tein hostille uuden virtuaalikoneen seuraavanlaisilla spekseillä:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Käyttöjärjestelmä: Debian 6 64-bit&lt;&#x2F;li&gt;
&lt;li&gt;CPUs: 1&lt;&#x2F;li&gt;
&lt;li&gt;RAM: 1024 Mb&lt;&#x2F;li&gt;
&lt;li&gt;HDD: 16 Gb&lt;&#x2F;li&gt;
&lt;li&gt;Network Adapters: 1 kpl, Internal network&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Tässä tapauksessa käytän Ubuntun sijasta Debiania koska palvelimellani ei sattunut olemaan Ubuntun levykuvaa.&lt;&#x2F;p&gt;
&lt;p&gt;Asetuksista määritin virtuaalikoneen käynnistymään ISO-levykuvalta palvelimen omalta datastorelta sekä virtuaalikoneen verkoksi sisäverkon, koska emme halua palvelinta näkymään julkiseen verkkoon.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-apache-ja-virtualhostit&#x2F;srv-settings1.png&quot; alt=&quot;srv-settings1&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;kayttojarjestelman-asentaminen-virtuaalikoneeseen&quot;&gt;Käyttöjärjestelmän asentaminen virtuaalikoneeseen&lt;&#x2F;h2&gt;
&lt;p&gt;Kuinka sitten asennetaan käyttöjärjestelmä tietokoneeseen joka ei fyysisesti ole olemassa? Itse asennus ja alkukonfiguroinnit tapahtuvat vSphere Clientin kautta sen sisältämän konsolitoiminnon avulla. Kun verkkoasetukset ovat kunnossa, voimme jatkaa virtuaalikoneen kanssa työskentelyä SSH-yhteyden läpi.&lt;&#x2F;p&gt;
&lt;p&gt;Jokaisella virtuaalikoneella on oma konsolinsa joka on ikäänkuin virtuaalinen “näyttöpääte”, jonka kautta voidaan olla vuorovaikutuksessa virtuaalikoneen kanssa. Konsoli-ikkunan kautta onnistuu myös näppäimistön ja hiiren käyttö virtuaalikoneen kanssa ja sen kautta voidaan hallita CD-, levyke-asemia ja USB-laitteita.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-apache-ja-virtualhostit&#x2F;vm-console.png&quot; alt=&quot;vm-console&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Itse käyttöjärjestelmän asennukseen liittyviä kohtia en tässä käy läpi, tässä tiivistettynä valitut asetukset:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Asennuskieli: Englanti&lt;&#x2F;li&gt;
&lt;li&gt;Näppäimistökartta: Suomi&lt;&#x2F;li&gt;
&lt;li&gt;Hostname: srv-deb2&lt;&#x2F;li&gt;
&lt;li&gt;Domain: hima.lan&lt;&#x2F;li&gt;
&lt;li&gt;Root-passut ja käyttäjätunnuksen määritys&lt;&#x2F;li&gt;
&lt;li&gt;Osiointi: &#x2F;-osio, käytä koko levyä + swap&lt;&#x2F;li&gt;
&lt;li&gt;Asennettavat paketit: ruksi pois kohdasta Graphical User Interface; ruksit kohtaan Web Server ja SSH Server&lt;&#x2F;li&gt;
&lt;li&gt;GRUB: asenna MBR:ään&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Asennus on valmis! Asennus alkoi 12.21 ja se oli käyttövalmiina kirjautumisruudussa 12.27. Ei paha asennusaika, ottaen huomioon että kyeessä oli netinstall-asennus.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-apache-ja-virtualhostit&#x2F;finished-install.png&quot; alt=&quot;finished-install&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;verkkoasetukset-kuntoon&quot;&gt;Verkkoasetukset kuntoon&lt;&#x2F;h2&gt;
&lt;p&gt;Nyt meillä on toimiva virtuaalikone. Määritetäänpä sille kiinteä IP DHCP-poolin ulkopuolelta:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;su&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nano &#x2F;etc&#x2F;network&#x2F;interfaces&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Ensimmäisellä komennolla otamme käyttöön pääkäyttäjän oikeudet kirjautumalla järjestelmään roottina (Debianissa ei ole oletuksena sudoa asennettuna). Sitten avaamme nanolla &#x2F;etc&#x2F;network&#x2F;interfaces-tiedoston, jossa kaikkien verkkokorttien asetukset ovat määritettyinä.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-apache-ja-virtualhostit&#x2F;interfaces-dhcp.png&quot; alt=&quot;interfaces-dhcp&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Minun tapauksessani siellä ei näy loopback-interfacen lisäksi kuin virtuaalikoneen verkkokortti eth0. Muutin sen asetukset seuraavanlaisiksi:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# The primary network interface&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;auto eth0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    iface eth0 inet static&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        address 10.40.1.11&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        netmask 255.0.0.0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        gateway 10.40.1.3&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Jotta uudet asetukset tulisivat voimaan, käynnistetään verkkoyhteys eth0 uudelleen komennolla:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ifdown eth0 &amp;amp;&amp;amp; ifup eth0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Nyt voimme kokeilla toiselta koneelta vastaako virtuaalikone pingiin:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-apache-ja-virtualhostit&#x2F;pingtest.png&quot; alt=&quot;pingtest&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;dns-asetukset&quot;&gt;DNS-asetukset&lt;&#x2F;h2&gt;
&lt;p&gt;DNS-asetukset löytyvät tiedostosta &lt;strong&gt;&#x2F;etc&#x2F;resolv.conf&lt;&#x2F;strong&gt;. Avataan ne komennolla:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nano &#x2F;etc&#x2F;resolv.conf&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Minun tapauksessani asetuksissa on määritettynä domain-osoite sekä kaksi nimipalvelinta:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-apache-ja-virtualhostit&#x2F;resolv-conf.png&quot; alt=&quot;resolv-conf&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Käytän tässä harjoituksessa verkon DNS-palvelinta osotteiden määrittelyyn. Määrittelin DNS-palvelimeen staattisen tietueen “srv-deb2” osoittamaan virtuaalipalvelimelle, jotta voin käyttää kyseistä nimeä osoitteena selaimessa:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-apache-ja-virtualhostit&#x2F;smoothwall.png&quot; alt=&quot;smoothwall&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;apachen-konfigurointi&quot;&gt;Apachen konfigurointi&lt;&#x2F;h2&gt;
&lt;p&gt;Koska valitsin jo asennusvaiheessa pakettienvalinnassa kohdan “Web Server”, on minulla Apache jo asennettuna ja toiminnassa.&lt;&#x2F;p&gt;
&lt;p&gt;Uuden virtuaalihostin luominen onnistuu näppärästi kopioimalla &#x2F;etc&#x2F;apache2&#x2F;sites-available-hakemistosta default-tiedosto sites-enablediin uudella nimellä:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;cp &#x2F;etc&#x2F;apache2&#x2F;sites-available&#x2F;default &#x2F;etc&#x2F;apache2&#x2F;sites-enabled&#x2F;pumba.com&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Sen jälkeen muokataan pumba.com-tiedostoa ja lisätään sinne ServerName-asetus ja muutetaan DocumentRoot-hakemiston polku halutuksi:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-apache-ja-virtualhostit&#x2F;pumba-servername.png&quot; alt=&quot;pumba-servername&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Sitten luodaan virtuaalihostin hakemisto ja lisätään sinne index.html-tiedosto:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mkdir &#x2F;var&#x2F;www&#x2F;pumba-com&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;echo &amp;quot;Jee Pumban kotisivut&amp;quot; &amp;gt;&amp;gt; &#x2F;var&#x2F;www&#x2F;pumba-com&#x2F;index.html&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Lopuksi määritellään DNS-palvelimelle pumba.com osoittamaan virtuaalipalvelimelle:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-apache-ja-virtualhostit&#x2F;pumba-dns.png&quot; alt=&quot;pumba-dns&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Lopputuloksena klo 14.12 meillä on kaksi toimivaa virtuaalihostia joista toinen vastaa palvelimen nimellä ja IP-osoitteella sekä toinen joka vastaa pumba.com-osoitteeseen:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-apache-ja-virtualhostit&#x2F;virtualhostit.png&quot; alt=&quot;Vasemmalla default-virtualhost, oikealla pumba.com-virtualhost&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h1 id=&quot;virheilmoitukset&quot;&gt;Virheilmoitukset&lt;&#x2F;h1&gt;
&lt;h3 id=&quot;virhe-404-not-found&quot;&gt;Virhe 404 – Not found&lt;&#x2F;h3&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;10.40.1.199 - - [02&#x2F;Feb&#x2F;2013:14:25:52 +0200] &amp;quot;GET &#x2F;jee.html HTTP&#x2F;1.1&amp;quot; 404 499 &amp;quot;- &amp;quot; &amp;quot;Mozilla&#x2F;5.0 (Windows NT 6.1; WOW64) AppleWebKit&#x2F;537.17 (KHTML, like Gecko) Ch rome&#x2F;24.0.1312.57 Safari&#x2F;537.17&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Yritin hakea selaimella &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;pumba.com&#x2F;jee.html&quot;&gt;http:&#x2F;&#x2F;pumba.com&#x2F;jee.html&lt;&#x2F;a&gt;, jota ei ollut palvelimella olemassa.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;virhe-403-forbidden&quot;&gt;Virhe 403 – Forbidden&lt;&#x2F;h3&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;10.40.1.199 - - [02&#x2F;Feb&#x2F;2013:14:41:37 +0200] &amp;quot;GET &#x2F;salainen.html HTTP&#x2F;1.1&amp;quot; 403 505 &amp;quot;-&amp;quot; &amp;quot;Mozilla&#x2F;5.0 (Windows NT 6.1; WOW64) AppleWebKit&#x2F;537.17 (KHTML, like Gecko) Chrome&#x2F;24.0.1312.57 Safari&#x2F;537.17&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Yritin avata selaimella &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;pumba.com&#x2F;salainen.html&quot;&gt;http:&#x2F;&#x2F;pumba.com&#x2F;salainen.html&lt;&#x2F;a&gt;, mutta siihen ei ole oikeuksia. Otin oikeudet pois virheen aiheuttamista varten komennolla:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;chmod o-r salainen.html&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h1 id=&quot;lahteet&quot;&gt;Lähteet&lt;&#x2F;h1&gt;
&lt;ul&gt;
&lt;li&gt;NetworkConfiguration – Debian Wiki (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;wiki.debian.org&#x2F;NetworkConfiguration#Configuring_the_interface_manually&quot;&gt;http:&#x2F;&#x2F;wiki.debian.org&#x2F;NetworkConfiguration#Configuring_the_interface_manually&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;VirtualHost Examples – Apache HTTP Server (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;httpd.apache.org&#x2F;docs&#x2F;2.2&#x2F;vhosts&#x2F;examples.html&quot;&gt;http:&#x2F;&#x2F;httpd.apache.org&#x2F;docs&#x2F;2.2&#x2F;vhosts&#x2F;examples.html&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Tero Karvinen: Apache; kertaus ja edistynyttä asiaa w05 -luento (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2012&#x2F;aikataulu-linux-palvelimena-ict4tn003-7-ict4tn003-kevaalla-2013&quot;&gt;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2012&#x2F;aikataulu-linux-palvelimena-ict4tn003-7-ict4tn003-kevaalla-2013&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Linux palvelimena: palvelinmurron tutkintaa</title>
        <published>2013-01-22T00:00:00+00:00</published>
        <updated>2013-01-22T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/school/linux-palvelimena/linux-palvelimena-palvelinmurron-tutkintaa/"/>
        <id>/school/linux-palvelimena/linux-palvelimena-palvelinmurron-tutkintaa/</id>
        
        <content type="html" xml:base="/school/linux-palvelimena/linux-palvelimena-palvelinmurron-tutkintaa/">&lt;p&gt;22.1.2013 klo 17.39&lt;&#x2F;p&gt;
&lt;p&gt;Kotitehtävän tarkoituksena oli löytää saastuneen palvelimen juuriosiosta otetusta levykuvasta haittaohjelma se selvittää kuka sen on tehnyt ja mitä se tekee&#x2F;on tehnyt palvelimelle. Tehtävänannon ja saastuneen levykuvan löydät täältä: &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;old.honeynet.org&#x2F;scans&#x2F;scan15&quot;&gt;http:&#x2F;&#x2F;old.honeynet.org&#x2F;scans&#x2F;scan15&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Aloitin tehtävän käynnistämällä Xubuntun live-cd:n virtuaalikoneessa saastuneen levykuvan tutkimista varten. Määritin virtuaalikoneeseen seuraavanlaiset ominaisuudet:&lt;&#x2F;p&gt;
&lt;p&gt;Virtualisointiohjelmisto: VMWare Fusion 5.0.2&lt;br &#x2F;&gt;
Prosessori: 1 ydin&lt;br &#x2F;&gt;
Muisti: 1024 megatavua&lt;br &#x2F;&gt;
Kovalevy: ei ole, buutataan live-imagelta&lt;br &#x2F;&gt;
1 verkkokortti, NAT-moodissa&lt;&#x2F;p&gt;
&lt;p&gt;Asensin The Sleuth Kitin jotta pääsin tutkimaan ja palauttamaan tiedostoja saastuneelta levykuvalta komennolla:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo apt-get update | sudo apt-get install sleuthkit&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Tämän jälkeen latasin saastuneen levykuvan tehtävänannon sivulta(&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;old.honeynet.org&#x2F;scans&#x2F;scan15&quot;&gt;http:&#x2F;&#x2F;old.honeynet.org&#x2F;scans&#x2F;scan15&lt;&#x2F;a&gt;), purin sen ja siirryin juuri luotuun hakemistoon:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;tar -xf honeypot.tar.gz&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;cd honeypot&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Tehtävässä mainittiin että haittaohjelma oli poistettu. Käytin Sleuthkitin tsk_recover-työkalua (Kiitokset &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;www.terokarvinen.com&quot;&gt;Tero Karviselle&lt;&#x2F;a&gt; tästä vinkistä) jotta saisin palautettua poistetut tiedostot levykuvalta:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;tsk_recover honeypot.hda8.dd unallocated&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Mounttasin levykuvan honeypot -hakemistoon tarkempaa tutkimista varten:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mkdir honeypot&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo mount honeypot.hda8.dd honeypot&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h1 id=&quot;haittaohjelman-loytaminen&quot;&gt;Haittaohjelman löytäminen&lt;&#x2F;h1&gt;
&lt;p&gt;22.1.2013 klo 18.22&lt;&#x2F;p&gt;
&lt;p&gt;Haittaohjelma löytyi suht helposti kun tiedettiin tehtävän kuvauksesta että se on poistettu. Tällöin voidaan olettaa, että jos tiedostoa ei ole ylikirjoitettu, se löytyy tsk_recover-komennon luomasta unallocated-hakemistosta palautettuna.&lt;&#x2F;p&gt;
&lt;p&gt;Kun siirryin unallocated-hakemistoon, löysin sieltä hyvinkin epäilyttävän näköisen tarball-paketin. Purin paketin ja BINGO, sieltähän ne pöpön tiedostot löytyivät:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;tar -xf last.tgz&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;cd last&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ls -l&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-palvelinmurron-tutkintaa&#x2F;rootkitlistaus.png&quot; alt=&quot;rootkitlistaus&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Hakemistossa on “install”-skripti. Tarkastellaanpa lähemmin mitä se tekee:&lt;&#x2F;p&gt;
&lt;h1 id=&quot;rootkin-asennuskripti&quot;&gt;Rootkin asennuskripti&lt;&#x2F;h1&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-palvelinmurron-tutkintaa&#x2F;installskripti1.png&quot; alt=&quot;installskripti1&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-palvelinmurron-tutkintaa&#x2F;installskripti2.png&quot; alt=&quot;installskripti2&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-palvelinmurron-tutkintaa&#x2F;installskripti3.png&quot; alt=&quot;installskripti3&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Ensiksi skripti tyhjentää ruudun sekä poistaa HISTFILE-ympäristömuuttujan:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;clear&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;unset HISTFILE&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Sitten käydään läpi onko make, gcc-kääntäjä ja ssh-daemon asennettuna. Tämän jälkeen korvataan järjestelmän ohjelmia saastuneilla. Kaikki korvattavat ohjelmat ovat sellaisia mitkä voisivat näyttää rootkitin olemassaolon ja siksi rootkit vaihtaa ne piiloutuakseen järjestelmään:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;rm -rf &#x2F;sbin&#x2F;ifconfig&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mv ifconfig &#x2F;sbin&#x2F;ifconfig&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;rm -rf &#x2F;bin&#x2F;netstat&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mv netstat &#x2F;bin&#x2F;netstat&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;rm -rf &#x2F;bin&#x2F;ps&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mv ps &#x2F;bin&#x2F;ps&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;rm -rf &#x2F;usr&#x2F;bin&#x2F;top&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mv top &#x2F;usr&#x2F;bin&#x2F;top&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;cp -f mkxfs &#x2F;usr&#x2F;sbin&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Ylläoleva viimeinen rivi kopioi paketissa olleen mkxfs-ohjelman &#x2F;usr&#x2F;sbin-hakemistoon. Google osasi kertoa että kyseessä olisi jokin tiedostojärjestelmän luomisohjelma: &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;www.fiveanddime.net&#x2F;man-pages&#x2F;mkxfs.8.html&quot;&gt;http:&#x2F;&#x2F;www.fiveanddime.net&#x2F;man-pages&#x2F;mkxfs.8.html&lt;&#x2F;a&gt;. Näin ei kuitenkaan ole tässä tapauksessa, vaan ohjelma vaikuttaisi olevan ssh-daemon uudelleennimettynä(Tämän sain selville vilkaisemalla lsattr-tiedostoa edempänä):&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-palvelinmurron-tutkintaa&#x2F;mkxfs.png&quot; alt=&quot;mkxfs&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Tämän jälkeen skripti luo tiedoston &#x2F;dev&#x2F;rpm, johon se listaa ohjelmien nimiä. En tiedä miksi, mutta luulisin että siihen listautuu ohjelmat, jotka rootkit haluaa pitää piilossa näkyviltä. Se luo myös tiedoston &#x2F;dev&#x2F;last-johon kirjoitetaan numeroita, jotka vaikuttavat ip-osotteiden osilta ja osa prosessien PID-numeroilta.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;piilohakemistot-dev-ida-drag-on-ja&quot;&gt;Piilohakemistot &#x2F;dev&#x2F;ida&#x2F;.drag-on ja “.. “&lt;&#x2F;h2&gt;
&lt;p&gt;Skripti luo &#x2F;dev&#x2F;ida-hakemistoon hakemistot “drag-on” ja “.. “, jonne se kopioi samat tiedostot ja sen jälkeen poistaa alkuperäiset:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mkdir -p &#x2F;dev&#x2F;ida&#x2F;.drag-on&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mkdir -p &#x2F;dev&#x2F;ida&#x2F;&amp;quot;.. &amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;cp linsniffer logclear sense sl2 mkxdfs s ssh_host_key ssh_random_seed &#x2F;dev&#x2F;ida&#x2F;.drag-on&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;cp linsniffer logclear sense sl2 mkxdfs s ssh_host_key ssh_random_seed &#x2F;dev&#x2F;ida&#x2F;&amp;quot;.. &amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;rm -rf linsniffer logclear sense sl2 mkxfs s ssh_host_key ssh_random_seed&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;touch &#x2F;dev&#x2F;ida&#x2F;.drag-on&#x2F;tcp.log&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;touch &#x2F;dev&#x2F;ida&#x2F;&amp;quot;.. &amp;quot;&#x2F;tcp.log&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Linsniffer on jonkinlainen salasanojenhaisteluohjelma, joka haistelee salasanoja verkkoliikenteestä. Tarkastellessani &#x2F;dev&#x2F;ida&#x2F;.drag-on&#x2F;tcp.log-tiedostoa tajusin sen olevan loki linsnifferistä, josta on suodatettu kaikki muu pois paitsi salasanat ja hostnamet:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-palvelinmurron-tutkintaa&#x2F;tcplog.png&quot; alt=&quot;tcplog&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;logclear ja sense-ohjelmat ovat perl-skriptejä jotka hoitavat linsnifferin lokin suodattamisen ja siivoamisen. ssh-tiedostot ovat takaportin asettamista varten.&lt;&#x2F;p&gt;
&lt;p&gt;Skripti ylikirjoittaa &#x2F;etc&#x2F;inetd.conf ja &#x2F;etc&#x2F;services-tiedostot järjestelmässä asettaakseen oman pop3-palvelun:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-palvelinmurron-tutkintaa&#x2F;pop3.png&quot; alt=&quot;pop3&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Tämän jälkeen poistetaan &#x2F;usr&#x2F;bin&#x2F;lsattr, lisätään &#x2F;etc&#x2F;rc.d&#x2F;rc.sysinit-tiedostoon uusi rivi automaattista käynnistystä varten ja lopuksi kopioidaan rootkitin oma lsattr-tiedosto takaisin &#x2F;usr&#x2F;bin-hakemistoon:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;rm -rf &#x2F;usr&#x2F;bin&#x2F;lsattr&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;echo &amp;quot;&#x2F;usr&#x2F;bin&#x2F;lsattr -t1 -X53 -p&amp;quot; &amp;gt;&amp;gt; &#x2F;etc&#x2F;rc.d&#x2F;rc.sysinit&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;echo &amp;gt;&amp;gt; &#x2F;etc&#x2F;rc.d&#x2F;rc.sysinit&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;cp -f lsattr &#x2F;usr&#x2F;bin&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;chmod 500 &#x2F;usr&#x2F;bin&#x2F;lsattr&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;chattr +i &#x2F;usr&#x2F;bin&#x2F;lsattr&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;usr&#x2F;bin&#x2F;lsattr&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sleep 1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Katsotaampa mitä lsattr-tiedosto sisältää:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;#!&#x2F;bin&#x2F;sh&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;cd &#x2F;dev&#x2F;ida&#x2F;.drag-on&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;.&#x2F;mkxfs -f .&#x2F;s&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;.&#x2F;linsniffer &amp;gt;&amp;gt; .&#x2F;tcp.log &amp;amp;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;cd &#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;lsattr siis ajetaan koneen käynnistyksessä. Skripti siirtyy &#x2F;dev&#x2F;ida&#x2F;.drag-on-hakemistoon ja ajaa sieltä mkxfs ja linsnifferin. Mkxfs on todellisuudessa ssh-daemon, jota ajetaan s-tiedostosta haetuilla asetuksilla. Kun tarkastellaan mitä s-tiedostossa on, saadaan selville että mkxfs onkin ssh-daemon, jota ajetaan portissa 5:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-palvelinmurron-tutkintaa&#x2F;s.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;last-cgi&quot;&gt;last.cgi&lt;&#x2F;h2&gt;
&lt;p&gt;lsattr-tiedoston tuunailun jälkeen skripti näyttää etsivän paikkaa last.cgi-tiedostolle. Tarkastellessani tiedostoa catilla sain selville sen olevan toinen takaportti järjestelmään komentojen antamista varten:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-palvelinmurron-tutkintaa&#x2F;lastcgi.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;tietojen-kerays-ja-lahetys&quot;&gt;Tietojen keräys ja lähetys&lt;&#x2F;h2&gt;
&lt;p&gt;Kun last.cgi-loopit on käyty läpi, skripti kerää tietokoneesta tietoa verkosta, raudasta ja konfiguraatiosta, se lähettää ne eteenpäin sähköpostitse kahteen osoitteeseen:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-palvelinmurron-tutkintaa&#x2F;kerays.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Lopuksi se siivoaa jälkensä ja poistaa last-hakemiston, tarballin ja computer-tiedoston.&lt;&#x2F;p&gt;
&lt;p&gt;Bonuskysymyksessä kysyttiin tehtäväannossa oliko haittaohjelma asennettuna järjestelmään. Vastaus on kyllä, koska:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&#x2F;dev&#x2F;ida&#x2F;.drag-on&#x2F; ja &#x2F;dev&#x2F;ida&#x2F;”.. “-hakemistot on olemassa sisältöineen&lt;&#x2F;li&gt;
&lt;li&gt;&#x2F;dev&#x2F;rpm ja &#x2F;dev&#x2F;last -tiedostot ovat olemassa asennuskriptin syöttämine sisältöineen&lt;&#x2F;li&gt;
&lt;li&gt;&#x2F;bin&#x2F;ps, &#x2F;bin&#x2F;netstat ja &#x2F;sbin&#x2F;ifconfig-tiedostoissa on kaikissa sama päivämäärä eli 26.2.2001 ja koko kuin last-hakemiston vastaavissa tiedostoissa.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h1 id=&quot;lahteet&quot;&gt;Lähteet&lt;&#x2F;h1&gt;
&lt;ul&gt;
&lt;li&gt;Scan of the month 15 (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;old.honeynet.org&#x2F;scans&#x2F;scan15&#x2F;&quot;&gt;http:&#x2F;&#x2F;old.honeynet.org&#x2F;scans&#x2F;scan15&#x2F;&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;The Sleuth Kit (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;www.sleuthkit.org&#x2F;sleuthkit&#x2F;&quot;&gt;http:&#x2F;&#x2F;www.sleuthkit.org&#x2F;sleuthkit&#x2F;&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Tero Karvinen: “Rosvoja ja kunnon kansalaisia” -luento&lt;&#x2F;li&gt;
&lt;li&gt;Hacked by linsniffer &amp;amp; luckscan: &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;tech.dir.groups.yahoo.com&#x2F;group&#x2F;redhat&#x2F;message&#x2F;5683&quot;&gt;http:&#x2F;&#x2F;tech.dir.groups.yahoo.com&#x2F;group&#x2F;redhat&#x2F;message&#x2F;5683&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Linux palvelimena 1. kotitehtävä</title>
        <published>2013-01-21T00:00:00+00:00</published>
        <updated>2013-01-21T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="/school/linux-palvelimena/linux-palvelimena-1-kotitehtava/"/>
        <id>/school/linux-palvelimena/linux-palvelimena-1-kotitehtava/</id>
        
        <content type="html" xml:base="/school/linux-palvelimena/linux-palvelimena-1-kotitehtava/">&lt;h1 id=&quot;asennusmedian-luominen&quot;&gt;Asennusmedian luominen&lt;&#x2F;h1&gt;
&lt;p&gt;Aloitin työskentelyn tekemällä ensin Xubuntulle asennusmedian. Olen muutaman vuoden ajan tehnyt perinteisen CD-kiekon sijaan buuttaavan USB-tikun Unetbootinilla. Tikulta ajettaessa etuina ovat:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Nopea käynnistyminen&lt;&#x2F;li&gt;
&lt;li&gt;Tallennusmahdollisuus&lt;&#x2F;li&gt;
&lt;li&gt;Kestävyys (USB-tikkua ei haittaa naarmut eikä oikeastaan edes kuorien puuttuminen)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Huono puoli USB-käynnistysmetodissa on se että läheskään kaikki koneet, varsinkaan vanhemmat, ei tue buuttaamista USB:ltä. Itselläni laitteisto on sen verran tuoretta että ne tukevat sitä + ajan Linuxia usein virtuaalikoneissa.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;unetbootin&quot;&gt;Unetbootin?&lt;&#x2F;h2&gt;
&lt;p&gt;Unetbootin on kätevä monialustainen työkalu Live Linux USB:n tekemiseen. Työkalun kautta voi joko kirjoittaa tikulle valmiiksi koneelle ladatun ISO-tiedoston tai ladata työkalun kautta haluamasi distron ja se kirjoittaa sen tikulle. Unetbootinin käyttö on hyvin simppeliä:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-1-kotitehtava&#x2F;unetbootin_main.png&quot; alt=&quot;unetbootin-main&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Valitse haluamasi distro pudotusvalikosta TAI valitse koneeltasi ISO-levykuva jonka haluat kirjoittaa tikulle&lt;&#x2F;li&gt;
&lt;li&gt;Valitse oikea levyasema (HUOM! Tämä kannattaa tarkistaa todella tarkkaan, ettei ohjelma kirjoita väärälle levylle, nimim. ”kokeiltu on”)&lt;&#x2F;li&gt;
&lt;li&gt;Aloita valitsemalla ”OK”, ohjelma alkaa valintasi mukaan joko lataamaan haluamasi distron levykuvaa tai kirjoittamaan valitsemaasi ISO-tiedostoa tikulle. Tässä välissä ehtii hyvin käymään kahvikupposen hakemassa.&lt;&#x2F;li&gt;
&lt;li&gt;Valmis!&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;Latasin ja laitoin tikulle Unetbootinin avulla Xubuntu 12.04:n  x86-versiona, koska testikoneeni on sattumoisin 32-bittinen. Testikoneena toimii vanha sotaratsuni IBM Thinkpad x60s. Kytkin tikun koneeseen, käynnistin sen ja painoin käynnistyksessä F12 jolla ThinkPadeissa aukeaa käynnistysvalikko.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-1-kotitehtava&#x2F;xubuntu-x60s.jpg&quot; alt=&quot;xubuntu-x60s&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Lopputulos: Xubuntu käynnistyi ongelmitta viisivuotiaassa sotaratsussani. Operaatioon meni aikaa noin 20 minuuttia, josta levykuvan latautuminen kesti n. 15 minuuttia.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;tyoasemat-ja-tietoverkot-24-linux-koe&quot;&gt;Työasemat ja tietoverkot 24, Linux-koe&lt;&#x2F;h1&gt;
&lt;h2 id=&quot;ssh-n-asennus&quot;&gt;SSH:n asennus&lt;&#x2F;h2&gt;
&lt;p&gt;Asensin Xubuntun virtuaalikoneeseen johon se asentui heittämällä. Etäkäyttöä varten asensin koneeseen SSH-daemonin komennolla:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo apt-get install ssh&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Testasin ssh:n toimivuuden kirjautumalla omilla tunnuksilla paikalliselle koneelle:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ssh joni@localhost&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;apachen-asennus-ja-konfigurointi&quot;&gt;Apachen asennus ja konfigurointi&lt;&#x2F;h2&gt;
&lt;p&gt;Tämän jälkeen asensin web-palvelimeksi apachen, joka löytyi näppärästi paketinhallinnasta myös:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo apt-get install apache2&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Jotta kaikki käyttäjät saisivat omat nettisivut koneelle, aktivoin apachen userdir-moduulin, joka mahdollistaa käyttäjien ylläpitävän omia kotisivuja kotihakemistossa sijaitsevan public_html-hakemiston kautta. Userdir-moduulin aktivoiminen onnistuu siirtämällä userdir.conf ja userdir.load –tiedostot &#x2F;etc&#x2F;apache2&#x2F;mods-available –hakemistosta &#x2F;etc&#x2F;apache2&#x2F;mods-enabled –hakemistoon seuraavasti:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo mv &#x2F;etc&#x2F;apache2&#x2F;mods-available&#x2F;userdir.conf &#x2F;etc&#x2F;apache2&#x2F;mods-enabled&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo mv &#x2F;etc&#x2F;apache2&#x2F;mods-available&#x2F;userdir.load &#x2F;etc&#x2F;apache2&#x2F;mod-enabled&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Sitten käynnistetään apache2-daemon uudelleen:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo &#x2F;etc&#x2F;init.d&#x2F;apache2 restart&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Tämän jälkeen tehdään vielä käyttäjälle kotihakemistoon public_html-hakemisto. Tästä hakemistosta Apache hakee käyttäjien kotisivut.&lt;&#x2F;p&gt;
&lt;p&gt;Ja lopuksi testataan toimivuus avaamalla selain osoitteeseen &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;localhost&#x2F;~omak%C3%A4ytt%C3%A4j%C3%A4tunnus&quot;&gt;http:&#x2F;&#x2F;localhost&#x2F;~omakäyttäjätunnus&lt;&#x2F;a&gt;:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-1-kotitehtava&#x2F;userdir.png&quot; alt=&quot;userdir&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;kayttajien-luominen&quot;&gt;Käyttäjien luominen&lt;&#x2F;h3&gt;
&lt;p&gt;Ennen kuin aloitetaan käyttäjätunnusten luominen, tehdään &#x2F;etc&#x2F;skel –hakemistoon public_html –hakemisto. Tällä tavoin saadaan uusille käyttäjille valmiiksi tuo kotisivuhakemisto eikä sitä tarvitse itse jälkeenpäin luoda.&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo mkdir &#x2F;etc&#x2F;skel&#x2F;public_html&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Käyttäjätunnusten luominen onnistuu nopeasti komentoriviltä komennolla&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo adduser &amp;lt;käyttäjätunnus&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Jonka jälkeen ohjatusti pyydetään syöttämään tarvittavat tiedot. Lopussa lista käyttäjistä, tunnuksista ja salasanoista jota tehtävässä tehtiin.&lt;&#x2F;p&gt;
&lt;p&gt;Samalla kun tuon public_html-hakemiston teki &#x2F;etc&#x2F;skel-hakemistoon, olisi voinut laittaa hakemistoon valmiiksi index.html-tiedoston jotta sekin olisi kopioitunut valmiiksi kaikille uusille käyttäjille.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;maijan-python-ohjelma&quot;&gt;Maijan Python-ohjelma&lt;&#x2F;h3&gt;
&lt;p&gt;Tehtävässä pyydettiin tekemään Maijan kotihakemistoon ”starsign”-nimisen ohjelman hakemisto johon tuli lähdekooditiedosto, lisenssitiedosto ja readme-tiedosto. lähdekooditiedostoon ”starsign.py” syötin nanolla seuraavanlaisen rivin:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;print ”Hei, maailma!”&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Sitten kokeilin toimivuuden ajamalla ohjelman:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;python starsign.py&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Tuloksena ohjelma tulosti näytölle ”Hei, maailma!”:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-1-kotitehtava&#x2F;starsign.png&quot; alt=&quot;starsign&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Lisenssitiedoston hain suoraan gnu.orgista ja nimesin sen uudelleen:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;wget &amp;lt;a href=&amp;quot;http:&#x2F;&#x2F;www.gnu.org&#x2F;licenses&#x2F;gpl-3.0.txt&amp;quot;&amp;gt;http:&#x2F;&#x2F;www.gnu.org&#x2F;licenses&#x2F;gpl-3.0.txt&amp;lt;&#x2F;a&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mv gpl-3.0.txt LICENSE&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Lopuksi tein vielä Maijalle README-tiedoston nanolla.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;elmerin-java-ohjelma&quot;&gt;Elmerin Java-ohjelma&lt;&#x2F;h3&gt;
&lt;p&gt;Elmerille tehtiin java-ohjelma ”randomwalk” hänen kotihakemistoonsa. Aluksi tein hakemiston sovellukselle ja sinne ”randomwalk.java” tiedoston, joka tulostaa ”Hei, maailma!” ajettaessa:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;System.out.println(”Hei, maailma!”);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Yrittäessäni ajaa Elmerin sovellusta, tuli ilmoitus että java ei ole asennettuna:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-1-kotitehtava&#x2F;eijavaa.png&quot; alt=&quot;eijavaa&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Onneksi hätä ei ole suuri, kirjaudutaan vain tunnuksilla joilla on sudo-oikeudet javan asennusta varten ja asennetaan se:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo apt-get install default-jre default-jdk&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Tämän jälkeen kirjauduin takaisin Elmerin tunnuksilla, käänsin lähdekoodin ja ajoin käännetyn binäärin:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;javac randomwalk.java&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;java randomwalk&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Ohjelma toimi ja tulosti näytölle ”Hei, maailma!”.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;palomuurin-asennus&quot;&gt;Palomuurin asennus&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-1-kotitehtava&#x2F;gufw.png&quot; alt=&quot;gufw&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Palomuurin konfigurointia varten asensin graafisen GUFW-ohjelman koneelle. Ohjelma on erittäin helppokäyttöinen, määritä vain säännöt halutuille palveluille ja käynnistä muuri. Olen aikaisemmin käyttäny Firestarteria iptablesin konfigurointiin, mutta pikaisen googletuksen myötä sain tietää sen olevan vanhentunut nykyisin. Säännöiksi määrittelin ulkoa pääsyn SSH:n sekä http:hen.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;veikon-php-sivusto&quot;&gt;Veikon PHP-sivusto&lt;&#x2F;h3&gt;
&lt;p&gt;Veikkoa varten täytyi koneelle asentaa ensiksi PHP5 jotta hänen hienot sivunsa näkyisivät. Asennus onnistuu komennolla&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo apt-get install php5&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Kommentoidaan userdir-määritykset pois &#x2F;etc&#x2F;apache2&#x2F;mods-enabled&#x2F;php5.conf-tiedostosta jotta Veikko voi käyttää php:tä kotisivuillaan:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-1-kotitehtava&#x2F;php5conf.png&quot; alt=&quot;php5conf&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Lopuksi tehdään veikon public:_html-hakemistoon index.php-tiedosto johon laitetaan lähdekoodi:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-1-kotitehtava&#x2F;veikkokoodi.png&quot; alt=&quot;veikkokoodi&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h1 id=&quot;tulosteet&quot;&gt;Tulosteet&lt;&#x2F;h1&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-1-kotitehtava&#x2F;tunnukset.txt&quot;&gt;tunnukset&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-1-kotitehtava&#x2F;lslRhome.txt&quot;&gt;ls -lR &#x2F;home&#x2F;&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;curl-tulosteet (&lt;a href=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-1-kotitehtava&#x2F;curl_angstrom.txt&quot;&gt;Elmeri Ångström&lt;&#x2F;a&gt;, &lt;a href=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-1-kotitehtava&#x2F;curl_mehilainen.txt&quot;&gt;Maija Mehiläinen&lt;&#x2F;a&gt;, &lt;a href=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-1-kotitehtava&#x2F;curl_hurme.txt&quot;&gt;Veikko Hurme&lt;&#x2F;a&gt;, &lt;a href=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-1-kotitehtava&#x2F;curl_lorenz.txt&quot;&gt;Almond Lorenz&lt;&#x2F;a&gt;, &lt;a href=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-1-kotitehtava&#x2F;curl_akker.txt&quot;&gt;Per Åkker&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-1-kotitehtava&#x2F;heimaailmat.txt&quot;&gt;Hei, maailmat ( Maija, Elmeri)&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-1-kotitehtava&#x2F;home.zip&quot;&gt;Tiedostot zippinä&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-1-kotitehtava&#x2F;ufwstatus.txt&quot;&gt;sudo ufw status verbose&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-1-kotitehtava&#x2F;enabled_mods.txt&quot;&gt;Apache2 enabled mods&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-1-kotitehtava&#x2F;last30.txt&quot;&gt;last -30&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-1-kotitehtava&#x2F;passwd.txt&quot;&gt;tail -20 passwd&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-1-kotitehtava&#x2F;apachelogs.txt&quot;&gt;tail apache logs&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-1-kotitehtava&#x2F;auth-.txt&quot;&gt;auth.log&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-1-kotitehtava&#x2F;syslog.txt&quot;&gt;tail syslog&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-1-kotitehtava&#x2F;history.txt&quot;&gt;history&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;h1 id=&quot;lisatehtava-laitetietojen-listaus-tietokoneesta-lshw&quot;&gt;Lisätehtävä: Laitetietojen listaus tietokoneesta (lshw)&lt;&#x2F;h1&gt;
&lt;p&gt;Laitetietojen listaus onnistuu näppärästi seuraavalla komennolla:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo lshw&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Komento tulostaa näytölle mm. koneen mallitiedot, sarjanumeron, biosin versiotiedot sekä emolevyn, prosessorin, näytönohjaimen, kovalevyjen ja muun laitteiston tiedot. Listauksesta saa selville kaiken tiedon mitä laitteistoa tietokoneessa on.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-1-kotitehtava&#x2F;lshw.txt&quot;&gt;Esimerkki lshw-tulosteesta&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h1 id=&quot;lisatehtava-vagrantin-asennus-ja-virtuaalipalvelimen-teko&quot;&gt;Lisätehtävä: Vagrantin asennus ja virtuaalipalvelimen teko&lt;&#x2F;h1&gt;
&lt;p&gt;Vagrantin asennus onnistuu helposti suoraan Ubuntun pakettirepoista:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo apt-get install vagrant&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;docs.vagrantup.com&#x2F;v1&#x2F;docs&#x2F;getting-started&#x2F;index.html&quot;&gt;Vagrantin sivuilta&lt;&#x2F;a&gt; löytyy hyvät ohjeet alkuun pääsemiseksi. Tässä esimerkissä tehdään Vagrantin ohjeen mukaan ja haetaan Vagrantin palvelimelta valmis “konepaketti”:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;vagrant box add lucid32 &amp;lt;http:&#x2F;&#x2F;files.vagrantup.com&#x2F;lucid32.box&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Tämän jälkeen konfiguroidaan paketti käynnistystä varten ja käynnistetään se:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;vagrant init lucid32&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;vagrant up&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Jos kaikki meni putkeen eikä virheilmoituksia tullut, virtuaalikone on nyt käynnissä! Nyt voimme avata SSH-yhteyden virtuaalikoneeseen:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;vagrant ssh&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Lopputuloksena toimiva virtuaalikone johon on ssh yhteys:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;school&#x2F;linux-palvelimena&#x2F;linux-palvelimena-1-kotitehtava&#x2F;vagrantssh.png&quot; alt=&quot;vagrantssh&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;SSH-yhteyden avulla voisi virtuaalikoneeseen konfiguroida esimerkiksi Apachen ja sen avulla pyörittää nettisivuja.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;lahteet&quot;&gt;Lähteet&lt;&#x2F;h1&gt;
&lt;ul&gt;
&lt;li&gt;Vagrant Getting Started (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;docs.vagrantup.com&#x2F;v1&#x2F;docs&#x2F;getting-started&#x2F;index.html&quot;&gt;http:&#x2F;&#x2F;docs.vagrantup.com&#x2F;v1&#x2F;docs&#x2F;getting-started&#x2F;index.html&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;“Hello, World!”: A Quick Tutorial on Python (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;python.about.com&#x2F;od&#x2F;gettingstarted&#x2F;ss&#x2F;helloworld_all.htm&quot;&gt;http:&#x2F;&#x2F;python.about.com&#x2F;od&#x2F;gettingstarted&#x2F;ss&#x2F;helloworld_all.htm&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Tero Karvinen: Työasemat ja tietoverkot 24 – Linux-koe (&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2011&#x2F;tyoasemat-ja-tietoverkot-24-koe&quot;&gt;http:&#x2F;&#x2F;terokarvinen.com&#x2F;2011&#x2F;tyoasemat-ja-tietoverkot-24-koe&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
</feed>
