<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[Edgaras Apšega]]></title><description><![CDATA[IT Enthusiast]]></description><link>http://apsega.lt/</link><generator>Ghost 0.11</generator><lastBuildDate>Tue, 26 May 2020 23:09:03 GMT</lastBuildDate><atom:link href="http://apsega.lt/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[How To: backup (and restore) Docker containers using Dropbox]]></title><description><![CDATA[<p>Backups are must-have and they should be constant; no one can argue with that, but what's the right way of doing it with Docker containers? Where to keep backups if you don't have an infrastructure for that? I'll show you my best practices for that.</p>

<h1 id="backupmanually">Backup manually</h1>

<p>In this section</p>]]></description><link>http://apsega.lt/how-to-backup-and-restore-docker-containers-using-dropbox/</link><guid isPermaLink="false">fc05eb33-d80c-4eb7-8e2c-fbe38825444b</guid><category><![CDATA[backup]]></category><category><![CDATA[docker]]></category><category><![CDATA[data]]></category><category><![CDATA[volumes]]></category><category><![CDATA[script]]></category><category><![CDATA[automation]]></category><category><![CDATA[database]]></category><category><![CDATA[restore]]></category><dc:creator><![CDATA[Edgaras Apšega]]></dc:creator><pubDate>Mon, 11 Apr 2016 22:04:07 GMT</pubDate><content:encoded><![CDATA[<p>Backups are must-have and they should be constant; no one can argue with that, but what's the right way of doing it with Docker containers? Where to keep backups if you don't have an infrastructure for that? I'll show you my best practices for that.</p>

<h1 id="backupmanually">Backup manually</h1>

<p>In this section I will describe how to perform manual backups and later one I'll provide some bash scripts so automation can take place with those.</p>

<h2 id="datavolumes">Data volumes</h2>

<p>Thats right. The only thing you want to backup is Docker container's data volumes. Except database containers where you can simply use <code>mysqldump</code> command or any other containers with custom implementation (i.e. GitLab).</p>

<p>To back up Docker container volumes (in this example container's name is <code>proxy</code>), first you have to find one (or more), simply by running the following command:</p>

<pre><code># docker inspect --format '{{range .Mounts}}{{.Source}}{{" -&gt; "}}{{.Destination}}{{"\n"}}{{end}}' proxy
/var/lib/docker/volumes/6890bad0490303e738ecae184da43fe9860e17ceca474c0a74c2d5974976e179/_data -&gt; /usr/share/nginx/html
</code></pre>

<p>Then we can simply <code>tar</code> whole data volume path:</p>

<pre><code class="language- ">tar zcfv backup.tar.gz /var/lib/docker/volumes/6890bad0490303e738ecae184da43fe9860e17ceca474c0a74c2d5974976e179/_data  
</code></pre>

<p>Untar backup with the following:</p>

<pre><code>tar zxfv backup.tar.gz -C /  
</code></pre>

<p>
This will automatically overwrite the contents of your data volume (data volume path must be the same that we've compressed).</p>

<h2 id="databasecontainers">Database containers</h2>

<p>To backup and restore databases (MySQL / MariaDB) running in a container is very simple. You can do that using the same method described about data volumes, but you can also use <code>mysqldump</code> tool that's more versatile.</p>

<p>Backup with the following command:</p>

<pre><code>  docker exec database sh -c 'exec mysqldump -uroot -p"$MYSQL_ROOT_PASSWORD" --all-databases' &gt; /tmp/backup.sql
</code></pre>

<p>This will backup all database tables of database named container to /tmp/backup.sql using <code>$MYSQL_ROOT_PASSWORD</code> environment variable as root password within container.</p>

<p>Restore simply with the following:</p>

<pre><code>docker exec -i database sh -c 'mysql -uroot -p"$MYSQL_ROOT_PASSWORD"' &lt; /tmp/backup.sql
</code></pre>

<h2 id="backuptodropbox">Backup to Dropbox</h2>

<p>Have plenty of unused space in Dropbox? Why not to use it as a backup storage? I've found that <a href="https://github.com/andreafabrizi/Dropbox-Uploader">Dropbox-Uploader</a> fits my needs perfectly. Follow all instructions on that GitHub page and setup your Dropbox.</p>

<p>Then you can simply backup your <code>.sql</code> or <code>.tar.gz</code> files:</p>

<pre><code>./dropbox_uploader.sh upload backup.tar.gz /location_in_dropbox/
</code></pre>

<h1 id="automatingbackups">Automating backups</h1>

<p>I wrote a simple bash script that decides on what's the best way of backing up a container based on its image name, i.e. if it's MySQL or MariaDB container, <code>mysqldump</code> tool will be used. On all other occasions, data volumes will be compressed using <code>tar</code> command.</p>

<p>Additionally my script can use several Dropbox accounts. The usage of a script is fairly simple:</p>

<pre><code>./backup.sh &lt;container_name&gt; [dropbox_account]
</code></pre>

<script src="https://gist.github.com/apsega/5c914286cb5caad853a64348ef0b6726.js"></script>

<p>You can add this to crontab and have daily/weekly/monthly backups.</p>

<h1 id="restorefrombackupscript">Restore from backup script</h1>

<p>As a backup, restoration script acts similarly:</p>

<pre><code>./restore.sh &lt;container_name&gt; &lt;dropbox_account&gt; &lt;days_back&gt;
</code></pre>

<p>i.e.</p>

<pre><code>./restore.sh proxy EA -1
</code></pre>

<script src="https://gist.github.com/apsega/a83d6456c682496a846e2c9177f91bbe.js"></script>]]></content:encoded></item><item><title><![CDATA[How to setup headless torrent box with RSS and DLNA (CentOS) + Docker container]]></title><description><![CDATA[<p>In this post I'll show you how easy you can setup headless torrent box with RSS and DLNA on your Linux host that's running on CentOS (Debian based distributions should not be very different).</p>

<p>There's actually two ways of going with this:</p>

<ul>
<li>Installing packages separately and do a slight configurations</li></ul>]]></description><link>http://apsega.lt/how-to-setup-headless-torrent-box-with-rss-and-dlna-centos/</link><guid isPermaLink="false">8077d9bc-a88a-4b43-91e2-14be3ce90272</guid><category><![CDATA[torrent box]]></category><category><![CDATA[dlna]]></category><category><![CDATA[rss]]></category><category><![CDATA[CentOS]]></category><category><![CDATA[docker]]></category><category><![CDATA[container]]></category><dc:creator><![CDATA[Edgaras Apšega]]></dc:creator><pubDate>Sat, 30 Jan 2016 15:39:14 GMT</pubDate><content:encoded><![CDATA[<p>In this post I'll show you how easy you can setup headless torrent box with RSS and DLNA on your Linux host that's running on CentOS (Debian based distributions should not be very different).</p>

<p>There's actually two ways of going with this:</p>

<ul>
<li>Installing packages separately and do a slight configurations (takes more time)</li>
<li>Deploying a docker container (simple, yet still in development)</li>
</ul>

<h3 id="packages">Packages</h3>

<p>We're going to use <strong>Deluge WebUI</strong> for headless torrents box, <strong>flexget</strong> for RSS integration and <strong>minidlnad</strong> for DLNA server.</p>

<p>Install required <code>epel-release</code> and <code>nux-dextop</code> repos:</p>

<pre><code>yum install -y epel-release  
wget http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm &amp;&amp; rpm -ivh nux-dextop-release-0-5.el7.nux.noarch.rpm  
</code></pre>

<p>Install required packages:</p>

<pre><code>yum install -y minidlna deluge-web  
easy_install flexget  
</code></pre>

<h3 id="configuration">Configuration</h3>

<h5 id="flexget">Flexget</h5>

<p>To integrate Flexget (RSS for torrents) into Deluge WebUI we'll need to setup authentication with it. First extract username and password:</p>

<pre><code>cat /var/lib/deluge/.config/deluge/auth | awk -F: '{print $1}'  
cat /var/lib/deluge/.config/deluge/auth | awk -F: '{print $2}'  
</code></pre>

<p>You'll see something like this:</p>

<pre><code># cat /var/lib/deluge/.config/deluge/auth | awk -F: '{print $1}'
localclient  
# cat /var/lib/deluge/.config/deluge/auth | awk -F: '{print $2}'
c120ff48a3c6fdad072fc59aa2b67fd1e000e5b7  
</code></pre>

<p><em>If you cannot find <code>auth</code> file, it's alternative location can be <code>/root/.config/deluge/auth</code></em>.</p>

<p>Download <code>config.yml</code> from <a href="https://github.com/apsega/DLNA-TorrentBox/blob/master/config.yml">GitHub</a> and place it in <code>/root/.flexget/</code>. Change <code>rss:</code> with tracker RSS link that you're using and other options with preference of yours. Change <code>username_goes_here</code> and <code>password_goes_here</code> with the details we've extracted before, in example from this:</p>

<pre><code>username: username_goes_here  
password: password_goes_here  
</code></pre>

<p>To this:  </p>

<pre><code>username: localclient  
password: c120ff48a3c6fdad072fc59aa2b67fd1e000e5b7  
</code></pre>

<p>You can test if <code>flexget</code> communicates with <code>Deluge WebUI</code> and torrent tracker (finds your shows, etc.) with the following command:</p>

<p><code>flexget execute -v</code></p>

<p>Finally, add <code>flexget</code> to cron so that it will perdiocially search for entries in RSS. Add the following line in crontab (<code>crontab -e</code>):</p>

<pre><code>@hourly /usr/bin/flexget execute -v &gt;&gt; /var/log/flexget.log 2&gt;&amp;1
</code></pre>

<h5 id="minidlna">MiniDLNA</h5>

<p>Edit <code>minidlna.conf</code> that's located in <code>/etc/</code> and define where downloaded media will be located. <a href="https://github.com/apsega/DLNA-TorrentBox/blob/master/minidlna.conf">My example</a>:</p>

<pre><code>media_dir=A,/home/Music  
media_dir=V,/home/Videos  
media_dir=P,/home/Pictures  
</code></pre>

<p>Restart <code>minidlnad</code> to apply changes:</p>

<p><code>systemctl restart minidlnad</code></p>

<h5 id="delugewebui">Deluge WebUI</h5>

<p>Deluge web client can be accessed via browser on 8112 port, i.e. <a href="http://localhost:8112">http://localhost:8112</a>. First-time password is <code>deluge</code> and can be changed instantly. Configuration is pretty straightforward, just make sure to change download path to be the same as provided in <code>minidlnad.conf</code> file.</p>

<p>That's it! You've got a fully working headless torrent box with RSS and DLNA server.</p>

<h1 id="dockercontainer">Docker Container</h1>

<p>I've made a docker container named <code>edgaras/dlna-torrentbox</code> (more info can be found on <a href="https://hub.docker.com/r/edgaras/dlna-torrentbox/">docker hub</a>). <em>Please keep in mind that it's still in development and RSS is not working at the moment</em>.</p>

<h4 id="deployment">Deployment</h4>

<p>If you have <code>docker</code> packages installed, just deploy container with the following command:</p>

<pre><code>docker run --name torrent-box -p 8112:8112 -P -v /home -d edgaras/dlna-torrentbox:latest  
</code></pre>

<p>Explanation on command-line options:</p>

<ul>
<li><p><code>--name torrent-box</code> - specify name of Docker container. In this case it'll be torrent-box.</p></li>
<li><p><code>-v /home</code> - mount /home as data volume. By default this minidlna will take media from <code>/home/Music</code>, <code>/home/Videos</code>, <code>/home/Pictures</code>.</p></li>
<li><code>-d</code> run as a daemon.</li>
<li><code>edgaras/dlna-torrentbox:latest</code> pull and use this image.</li>
</ul>

<h4 id="configuration">Configuration</h4>

<p>After container deployment is complete you should be able to reach Deluge WebUI via <a href="http://IP:8112">http://IP:8112</a> change IP to your Linux machine one of course. </p>

<p>You'll be prompted for a password. It'll be <code>deluge</code> and you'll be able to change it right away. After that change your torrent download location to <code>/home/Videos</code> so that minidlna would be able to pick it up and stream to other devices.</p>]]></content:encoded></item><item><title><![CDATA[My workstation setup (OS X)]]></title><description><![CDATA[My current setup on my main workstation (Mac OS X): configuration, software and etc., including vagrant, virtualbox, chefdk, brew.]]></description><link>http://apsega.lt/my-workstation-setup-os-x/</link><guid isPermaLink="false">23010202-4895-4bd3-bbe7-427f8e916775</guid><category><![CDATA[OS X]]></category><category><![CDATA[Chef]]></category><category><![CDATA[Kitchen]]></category><category><![CDATA[DevOps]]></category><dc:creator><![CDATA[Edgaras Apšega]]></dc:creator><pubDate>Sun, 10 Jan 2016 09:14:52 GMT</pubDate><content:encoded><![CDATA[<p>My current setup on my main workstation (Mac OS X): configuration, software and etc. </p>

<h1 id="software">Software</h1>

<h2 id="casual">Casual</h2>

<ul>
<li><a href="http://raides.blavasciunas.com">Lithuanian Keyboard</a> - "Lietuvių (skaičių eilės)"</li>
<li><a href="https://www.paragon-software.com/home/ntfs-mac/">Paragon NFTS</a> - makes NTFS writable</li>
<li><a href="https://itunes.apple.com/lt/app/skitch-snap.-mark-up.-share./id425955336?mt=12">Skitch</a> - awesome screenshoting tool</li>
<li><a href="https://ia.net/writer/mac/">iA Writer</a> - best writing machine that supports markdown</li>
<li><a href="https://itunes.apple.com/lt/app/amphetamine/id937984704?mt=12">Amphetamine</a> - does not let Mac to sleep</li>
<li><a href="https://itunes.apple.com/lt/app/pixelmator/id407963104?mt=12">Pixelmator</a> - for photo editing</li>
<li><a href="https://itunes.apple.com/lt/app/pocket/id568494494?mt=12">Pocket</a> - read it later service</li>
<li><a href="https://itunes.apple.com/lt/app/daisydisk/id411643860?mt=12">Daisy Disk</a> - shows disk space usage</li>
<li><a href="http://www.hotkey-eve.com">Hotkey-EVE</a> - helps to learn shortcuts</li>
<li><a href="https://itunes.apple.com/lt/app/battery-monitor/id413678017?mt=12">Battery Monitor</a> - displays detailed information on battery</li>
<li><a href="http://tunnelblick.net">Tunnelblick</a> - for VPN</li>
<li><a href="http://www.videolan.org/vlc/index.html">VLC</a> - best video player</li>
<li><a href="http://unclutterapp.com">Unclutter</a> - a new handy place on your desktop for storing notes, files and pasteboard clips</li>
</ul>

<h2 id="devops">DevOps</h2>

<ul>
<li><a href="https://itunes.apple.com/lt/app/slack/id803453959?mt=12">Slack</a> - chat app with lots of integrations</li>
<li><a href="https://www.iterm2.com">iTerm2</a> with <a href="http://ethanschoonover.com/solarized">Solarized Dark</a> theme</li>
<li><a href="https://atom.io">Atom.io</a> - One of the best IDEs available. It's free and has killer Git integration. Used with <a href="https://atom.io/themes/solarized-dark-ui">Solarized Dark</a> theme, <a href="https://github.com/akonwi/git-plus">git-plus</a> and  <a href="https://atom.io/packages/language-docker">language-docker</a> plugins.</li>
<li><a href="http://brew.sh">Homebrew</a> - missing package manager for OS X:</li>
</ul>

<pre><code>ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"  
</code></pre>

<ul>
<li><a href="https://git-scm.com">Git</a> - best version control system:</li>
</ul>

<pre><code>sudo brew install git  
</code></pre>

<p>With the following setup:</p>

<pre><code>git config --global user.name "Edgaras"  
git config --global user.email "email"  
git config --global core.editor vim  
git config --global help.autocorrect 1  
git config --global color.ui auto  
git config --global core.autocrlf input  
</code></pre>

<ul>
<li><a href="http://apsega.lt/getting-started-with-vagrant-and-virtualbox-on-os-x/">Vagrant + VirtualBox</a> for setting up lab environment locally:</li>
</ul>

<pre><code>sudo brew tap caskroom/cask  
sudo brew install brew-cask  
sudo brew cask install vagrant virtualbox  
</code></pre>

<ul>
<li><a href="https://downloads.chef.io/chef-dk/mac/">ChefDK</a> (+ kitchen) - to test recipes locally or manage remote Chef servers:</li>
</ul>

<pre><code>sudo brew cask install chefdk  
</code></pre>

<ul>
<li><a href="http://sourceforge.net/projects/chicken/">Chicken</a> - my favourite VNC client app</li>
</ul>

<h2 id="osxtweaks">OS X Tweaks</h2>

<ul>
<li>Increase standby delay</li>
</ul>

<pre><code>sudo pmset -a standbydelay 43200  
</code></pre>]]></content:encoded></item><item><title><![CDATA[Google Authenticator PAM module (2 step authentication for SSH)]]></title><description><![CDATA[Tutorial how to implement 2 step authentication for remote SSH login using Google Authenticator PAM module and Google Authenticator app.]]></description><link>http://apsega.lt/google-authenticator-pam-module-2-step-authentication-for-ssh/</link><guid isPermaLink="false">97bff1de-cd4a-4f00-828e-0055792bca42</guid><category><![CDATA[Linux]]></category><category><![CDATA[CentOS]]></category><category><![CDATA[Debian]]></category><dc:creator><![CDATA[Edgaras Apšega]]></dc:creator><pubDate>Sat, 09 Jan 2016 10:05:50 GMT</pubDate><content:encoded><![CDATA[<p>Major service providers like Gmail, Dropbox, GitHub, Amazon Web Services encourage their users to use <strong>2 step authentication</strong> as it is one of the safest way to protect users login. I’m using this password add-on feature to SSH to my gateway server from WAN so that I could access other hosts in that network and I think that it’s by far the most safest solution.</p>

<h4 id="packages">Packages</h4>

<p>First of all, you’ll need these packages to be installed on the Linux machine:</p>

<ul>
<li>autoconf</li>
<li>automake</li>
<li>make </li>
<li>gcc </li>
<li>wget</li>
<li>unzip</li>
<li>libtool</li>
<li>pam-devel (for CentOS / RHEL)</li>
<li>libpam0g-dev (for Debian)</li>
</ul>

<p><code>yum install pam-devel gcc make autoconf automake wget unzip libtool</code> 
or <br>
<code>apt-get install libpam0g-dev gcc make autoconf automake wget unzip libtool</code> if you’re on Debian.</p>

<p>Then, download <code>google-authenticator</code> from it’s <a href="https://github.com/google/google-authenticator">Github page</a> via <code>git clone</code> or <code>wget</code> command. An example with <code>wget</code>:</p>

<pre><code>wget https://github.com/google/google-authenticator/archive/master.zip
unzip master.zip
</code></pre>

<h4 id="compilethecode">Compile the code</h4>

<p>After the files are on the filesystem, we have to compile <code>google-authenticator</code>:</p>

<pre><code>cd google-authenticator-master/libpam/
./bootstrap.sh
./configure
make
make install
</code></pre>

<p>After <code>make install</code> successful output will look like this:</p>

<pre><code># make install
cp pam_google_authenticator.so /lib64/security
cp google-authenticator /usr/local/bin
</code></pre>

<h4 id="setupgoogleauthenticator">Set-up google-authenticator</h4>

<p>Now we need to configure <code>google-authenticator</code>, just run it and answer the questions with y/n with your preferences. I’ve answered all to <em>yes</em>:</p>

<pre><code># google-authenticator

Do you want authentication tokens to be time-based (y/n) y
Your new secret key is: RSXXXXXXXXXXXXXX
Your verification code is 010101
Your emergency scratch codes are:
  XXXXXXXXX
  XXXXXXXXX
  XXXXXXXXX
  XXXXXXXXX
  XXXXXXXXX

Do you want me to update your „/root/.google_authenticator”     file (y/n) y

Do you want to disallow multiple uses of the same authentication token? This restricts you to one login about every 30s, but it increases your chances to notice or even prevent man-in-the-middle attacks (y/n) y

Do you want to disallow multiple uses of the same authentication token? This restricts you to one login about every 30s, but it increases your chances to notice or even prevent man-in-the-middle attacks (y/n) y

By default, tokens are good for 30 seconds and in order to compensate for possible time-skew between the client and the server, we allow an extra token before and after the current time. If you experience problems with poor time synchronization, you can increase the window from its default size of 1:30min to about 4min. Do you want to do so (y/n) y

If the computer that you are logging into isn’t hardened against brute-force login attempts, you can enable rate-limiting for the authentication module. By default, this limits attackers to no more than 3 login attempts every 30s. Do you want to enable rate-limiting (y/n) y
</code></pre>

<h4 id="mobileappconfiguration">Mobile app configuration</h4>

<p>Open up your Google Authenticator application (doesn't matter if you're on Android or iOS), hit the advanced button (3 dots in upper right corner) and select setup account. </p>

<p>Now you can choose to <code>Scan a barcode</code> or <code>Enter key provided</code> and just enter provided <code>Secret key</code> earlier.</p>

<h4 id="systemconfiguration">System configuration</h4>

<p>Now we need that the system would use <code>google-authenticator</code> during SSH login.</p>

<p>We’ll need to edit <code>/etc/pam.d/sshd</code> and <code>/etc/ssh/sshd_config</code> files.</p>

<p>In <code>/etc/pam.d/sshd</code> add the following line:</p>

<pre><code>auth required pam_google_authenticator.so
</code></pre>

<p>In <code>/etc/ssh/sshd_config</code> file change </p>

<pre><code>ChallengeResponseAuthentication no
</code></pre>

<p>To</p>

<pre><code>ChallengeResponseAuthentication yes
</code></pre>

<p>Restart ssh daemon <code>systemctl restart sshd</code> or <code>/etc/init.d/ssh restart</code> if you’re on Debian.</p>]]></content:encoded></item><item><title><![CDATA[KVM installation on CentOS 7 and guest OS provisioning]]></title><description><![CDATA[<p>This is a simple guide for <strong>KVM</strong> installation on <strong>CentOS 7</strong> and provisioning guest operating system via <code>virt-install</code>.</p>

<h5 id="setup">Setup</h5>

<p>First, install required packages:</p>

<pre><code>yum install bridge-utils tunctl bridge-utils bind-utils tuned-utils-systemtap lvm virt-manager libvirt virt-install qemu-kvm xauth dejavu-lgc-sans-fonts
</code></pre>

<p>Enable IPv4 forwarding:</p>

<p><code>echo 'net.ipv4.ip_forward = 1' &gt;&gt; /etc/sysctl.</code></p>]]></description><link>http://apsega.lt/kvm-installation-on-centos-7-and-gues-os-provisioning/</link><guid isPermaLink="false">b476ea50-e985-4427-ad1b-ad950a1393d1</guid><category><![CDATA[CentOS]]></category><category><![CDATA[KVM]]></category><dc:creator><![CDATA[Edgaras Apšega]]></dc:creator><pubDate>Fri, 16 Oct 2015 07:10:08 GMT</pubDate><content:encoded><![CDATA[<p>This is a simple guide for <strong>KVM</strong> installation on <strong>CentOS 7</strong> and provisioning guest operating system via <code>virt-install</code>.</p>

<h5 id="setup">Setup</h5>

<p>First, install required packages:</p>

<pre><code>yum install bridge-utils tunctl bridge-utils bind-utils tuned-utils-systemtap lvm virt-manager libvirt virt-install qemu-kvm xauth dejavu-lgc-sans-fonts
</code></pre>

<p>Enable IPv4 forwarding:</p>

<p><code>echo 'net.ipv4.ip_forward = 1' &gt;&gt; /etc/sysctl.d/99-sysctl.conf</code></p>

<p><code>reboot</code> your system and check if you can run <code>virsh</code> command:</p>

<p><code>virsh -c qemu:///system list</code></p>

<p>Edit <code>/etc/sysconfig/network-scripts/ifcfg-eno1</code> file so it would reflect the following:</p>

<pre><code>TYPE="Ethernet"
NAME="eno1"
UUID="60093307-ad32-425c-b859-724fd9941ba7"
DEVICE="eno1"
ONBOOT="yes"
BRIDGE="br0"
</code></pre>

<p>Create br0 interface named <code>ifcfg-br0</code> and paste the following:</p>

<pre><code>DEVICE=br0
TYPE=Bridge
BOOTPROTO=dhcp
ONBOOT=yes
NAME=br0
</code></pre>

<p>Enable and start <code>libvirtd</code> daemon:</p>

<p><code>systemctl start libvirtd &amp;&amp; systemctl enable libvirtd</code></p>

<p>Stop/disable NetworkManager and restart network daemon:</p>

<p><code>systemctl stop NetworkManager; systemctl restart network</code></p>

<hr>

<h5 id="provisioning">Provisioning</h5>

<p>Run <code>osinfo-query os | grep centos</code> to get required guest OS short ID like <code>centos7.0</code> </p>

<p>Download OS base image to <code>/tmp</code>:</p>

<p><code>wget http://mirror.duomenucentras.lt/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1503-01.iso</code></p>

<p>Install guest OS via <code>virt-install</code>:</p>

<pre><code>virt-install --connect qemu:///system -n [name] -r [ram_size_in_MiBs] --vcpus=[virtual_cpus] --disk path=/var/lib/libvirt/images/[name].img,size=[size_in_GiBs] --graphics inc,listen=0.0.0.0 --noautoconsole --os-type linux --os-variant [short_id] --accelerate --network=bridge:br0 --hvm --cdrom [path_to_iso.iso]
</code></pre>

<p>i.e.:</p>

<pre><code>virt-install --connect qemu:///system -n anaconda -r 2048 --vcpus=2 --disk path=/var/lib/libvirt/images/anaconda.img,size=2 --graphics inc,listen=0.0.0.0 --noautoconsole --os-type linux --os-variant centos7.0 --accelerate --network=bridge:virbr0 --hvm --cdrom /tmp/CentOS-7-x86_64-Minimal-1503-01.iso
</code></pre>

<p>After successful provision, we need to find VNC port to connect to:</p>

<p><code>virsh vncdisplay [name]</code></p>

<p><code>:0</code> means <code>5900</code>, <code>:1</code> - <code>5901</code> and so on.</p>

<p>Accordingly open firewall port:</p>

<p><code>firewall-cmd --zone=public --add-port=5900/tcp --permanent</code></p>

<p>And reload configuration to apply changes:</p>

<p><code>firewall-cmd --reload</code></p>

<p>Connect to your guest via VNC client to finish installation. </p>

<p>Chicken example:</p>

<p><img src="http://apsega.lt/content/images/2015/10/VNC_Login_and_Editor_-_Edgaras_Ap-ega.png" alt=""></p>

<hr>

<h5 id="deletingguestosandimage">Deleting guest OS and image</h5>

<p>Destroy VM:</p>

<p><code>virsh destroy [name]</code></p>

<p>Make sure VM is not running with <code>virsh list</code> and then undefine domain (name):</p>

<p><code>virsh undefine [name]</code></p>

<p>Finally, remove VM image:</p>

<p><code>rm -rfv /var/lib/libvirt/images/[name].img</code></p>

<hr>

<h5 id="usefulcommands">Useful commands</h5>

<p><code>virsh list</code> - show all running VMs</p>

<p><code>virsh --connect qemu:///system autostart [name]</code> - enable guest OS autostart</p>

<p><code>virsh start [name]</code> - start VM.</p>

<p><code>virsh shutdown [name]</code> - stop VM.</p>

<p><code>virsh destroy [name]</code> - restart VM.</p>]]></content:encoded></item><item><title><![CDATA[A quick Chef Kitchen setup using Vagrant + VirtualBox on OS X]]></title><description><![CDATA[<p><strong>Chef Kitchen</strong> is a great way testing your <strong>Chef Cookbooks</strong> locally without breaking up your Production / UAT / Dev environments. </p>

<p>First, you have to install <strong>Vagrant</strong> and <strong>VirtualBox</strong> on your workstation (guide on how to do that easily — <a href="http://apsega.lt/getting-started-with-vagrant-and-virtualbox-on-os-x/">http://apsega.lt/getting-started-with-vagrant-and-virtualbox-on-os-x/</a>, but you can skip adding boxes and initialising VM</p>]]></description><link>http://apsega.lt/a-quick-chef-kitchen-setup-using-vagrant-virtualbox-on-os-x/</link><guid isPermaLink="false">31e12a70-7252-46ae-8aef-db87428470f9</guid><category><![CDATA[OS X]]></category><category><![CDATA[Chef]]></category><category><![CDATA[Kitchen]]></category><dc:creator><![CDATA[Edgaras Apšega]]></dc:creator><pubDate>Sun, 11 Oct 2015 13:04:53 GMT</pubDate><content:encoded><![CDATA[<p><strong>Chef Kitchen</strong> is a great way testing your <strong>Chef Cookbooks</strong> locally without breaking up your Production / UAT / Dev environments. </p>

<p>First, you have to install <strong>Vagrant</strong> and <strong>VirtualBox</strong> on your workstation (guide on how to do that easily — <a href="http://apsega.lt/getting-started-with-vagrant-and-virtualbox-on-os-x/">http://apsega.lt/getting-started-with-vagrant-and-virtualbox-on-os-x/</a>, but you can skip adding boxes and initialising VM steps).</p>

<p>Then, download and install <strong>Chef Development</strong> Kit from <a href="https://downloads.chef.io/chef-dk/mac/">chef.io</a>, or use command line and install it via <strong>brew cask</strong>:</p>

<p><code>brew cask install chefdk</code></p>

<p>After Chef DK has been successfully installed, we can create our Kitchen working directory (i.e. <code>mkdir chef</code>) and generate first Cookbook by running the following command:</p>

<p><code>chef generate cookbook nginx</code> (you can specify your own cookbook name other than nginx)</p>

<p>Change directory to newly created cookbook:</p>

<p><code>cd nginx</code></p>

<p>Needed Kitchen virtual machine configuration is in <code>.kitchen.yml</code> file, while <code>Vagrant</code> file is in <code>.kitchen/kitchen-vagrant/kitchen-nginx-default-centos71/</code> location. Editing <code>.kitchen.yml</code> is suffice for our Kitchen environment (changing box names, etc.).</p>

<p>After we've configured our desired VM state, we can bring it up easily:</p>

<p><code>kitchen converge</code></p>

<p>This command is all-in-one package that actually initialises Vagrant box, installs chef-client into it and executes your recipes. To check your VM state, you can run:</p>

<p><code>kitchen list</code></p>

<p>To login to your guest box run:</p>

<p><code>kitchen login</code></p>

<p>And you can always destroy your box with the following:</p>

<p><code>kitchen destroy</code></p>]]></content:encoded></item><item><title><![CDATA[Building more complex lab with Vagrant]]></title><description><![CDATA[<p>You can easily setup a bigger environment with a number of virtual machines using <strong>Vagrant</strong>. This helps if you want to test various more complex scenarios (high-availabilities, failures, replications, etc.) locally.</p>

<p>Once you're done with you virtual machine setup, package your <strong>Vagrant</strong> box:</p>

<p><code>vagrant package --output centos.box</code></p>

<p>Then, you</p>]]></description><link>http://apsega.lt/building-complex-lab-with-vagrant/</link><guid isPermaLink="false">ff01e532-ddcc-4a15-94c4-a1f3aabb38c0</guid><category><![CDATA[Vagrant]]></category><category><![CDATA[Linux]]></category><dc:creator><![CDATA[Edgaras Apšega]]></dc:creator><pubDate>Wed, 23 Sep 2015 23:28:53 GMT</pubDate><content:encoded><![CDATA[<p>You can easily setup a bigger environment with a number of virtual machines using <strong>Vagrant</strong>. This helps if you want to test various more complex scenarios (high-availabilities, failures, replications, etc.) locally.</p>

<p>Once you're done with you virtual machine setup, package your <strong>Vagrant</strong> box:</p>

<p><code>vagrant package --output centos.box</code></p>

<p>Then, you can add your packaged box to the vagrant:</p>

<p><code>vagrant box add centos.box --name centos</code></p>

<p>Just to double-check if the box has been added to vagrant, list all added boxes:</p>

<p><code>vagrant box list</code></p>

<p>Edit Vagrant file to add the following lines (this configuration is for 3 replicated servers):</p>

<pre><code>def config_centos(config, node_number)
config.vm.define "zipset#{node_number}" do |replica|
    replica.vm.box = "centos"
    replica.vm.hostname = "centos#{node_number}"
    replica.vm.network "private_network", ip: "192.168.50.10#{node_number}"
    end

    for node_number in 1..3
        config_centos config, node_number
    end
</code></pre>

<p>Now we can start all three servers at once with the following Vagrant command:</p>

<p><code>vagrant up /centos*/</code></p>

<p>You can check all of your <strong>Vagrant</strong> machines statuses with <code>vagrant global-status</code> command.</p>]]></content:encoded></item><item><title><![CDATA[Getting started With Vagrant and VirtualBox on OS X]]></title><description><![CDATA[A simple guide on how to setup CentOS Virtual Machine box with Vagrant in OS X via brew and cask.]]></description><link>http://apsega.lt/getting-started-with-vagrant-and-virtualbox-on-os-x/</link><guid isPermaLink="false">ede36608-b2f7-416b-860c-045321c89486</guid><category><![CDATA[Vagrant]]></category><category><![CDATA[CentOS]]></category><category><![CDATA[VirtualBox]]></category><category><![CDATA[OS X]]></category><category><![CDATA[Linux]]></category><dc:creator><![CDATA[Edgaras Apšega]]></dc:creator><pubDate>Sat, 19 Sep 2015 11:53:00 GMT</pubDate><content:encoded><![CDATA[<p><strong>Vagrant</strong> is an awesome free tool for versioning environments. Basically with it you can easily get up and running virtual machine image within seconds. It's working beautifully with Oracle's free <strong>VirtualBox</strong>.</p>

<p>To install Vagrant and VirtualBox on Mac OS X, simply start by installing brew and cask with these 3 commands:</p>

<p><code>ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"</code></p>

<p><code>brew tap caskroom/cask</code></p>

<p><code>brew install brew-cask</code></p>

<p>Then, install Vagrant and VirtualBox via <em>brew</em> and <em>cask</em>:</p>

<p><code>brew cask install vagrant virtualbox</code></p>

<p>After that you can simply check installed versions:</p>

<p><code>vagrant -v &amp;&amp; vboxmanage -v</code></p>

<p>Add CentOS image to Vagrant (you can choose other than CentOS, <a href="http://www.vagrantbox.es">here's a list of others</a>):</p>

<p><code>vagrant box add centos https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.1.0/centos-7.0-x86_64.box</code></p>

<p>To start your virtual machine, create a directory, change to it and initialise Vagrant box:</p>

<p><code>mkdir centos &amp;&amp; cd centos &amp;&amp; vagrant init centos</code></p>

<p>After that, you can start your box and SSH into it:</p>

<p><code>vagrant up</code> </p>

<p><code>vagrant ssh</code></p>

<p>That's it! You've got CentOS VM running with Vagrant! You can package your vagrant box using <code>vagrant package --output centos.box</code> command.</p>

<p>Other useful Vagrant and VirtualBox commands can be listed with <code>vagrant -h</code> and <code>vboxmanage -h | less</code>. </p>]]></content:encoded></item></channel></rss>