<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Posts | ..:: BOFH ::..</title><link>https://bofh.im/post/</link><atom:link href="https://bofh.im/post/index.xml" rel="self" type="application/rss+xml"/><description>Posts</description><generator>Wowchemy (https://wowchemy.com)</generator><language>en-us</language><copyright>© 1996-2025</copyright><image><url>https://bofh.im/media/icon_hu5405a232fba0802caf7558beb944b483_62948_512x512_fill_lanczos_center_2.png</url><title>Posts</title><link>https://bofh.im/post/</link></image><item><title>Multiplatform Testing With Molecule and Travis</title><link>https://bofh.im/post/multiplatform-testing-with-molecule-travis/</link><pubDate>Mon, 30 Mar 2020 02:53:32 +0600</pubDate><guid>https://bofh.im/post/multiplatform-testing-with-molecule-travis/</guid><description>&lt;p>Recently I had been trying to convert all my Bourne shell scripts into possible &lt;a href="https://galaxy.ansible.com" target="_blank" rel="noopener">Ansible Galaxy&lt;/a> Roles so that I can use it every now and then in my playbooks. Normally my regular job requires concentration on &lt;a href="https://freebsd.org" target="_blank" rel="noopener">FreeBSD&lt;/a> based systems only but one of my new gigs actually has a multi platform scenario running &lt;a href="https://centos.org" target="_blank" rel="noopener">CentOS&lt;/a>, &lt;a href="https://ubuntu.com" target="_blank" rel="noopener">Ubuntu&lt;/a>, &lt;a href="https://debian.org" target="_blank" rel="noopener">Debian&lt;/a>, &lt;a href="https://freebsd.org" target="_blank" rel="noopener">FreeBSD&lt;/a>, &lt;a href="https://www.archlinux.org" target="_blank" rel="noopener">Arch Linux&lt;/a> and what not. So thought about rewriting the shell scripts into reusable multi platform Ansible Roles.&lt;/p>
&lt;p>The first place I thought about heading into was &lt;a href="https://galaxy.ansible.com" target="_blank" rel="noopener">Ansible Galaxy&lt;/a> which is a platform for sharing Ansible Roles with others. Ths site is nice and clean; has a good option for searching including name, tags and platform. For a network infrastructure the first crucial part is time synching. So I started searching for ntp which supports &lt;a href="https://freebsd.org" target="_blank" rel="noopener">FreeBSD&lt;/a>. There are lots of roles supporting that search. But some are broken, some do not work on that platform, some requires earlier version of Ansible. So rather than finding the needle in the haystack it was better to write my own version. Writing a dirty oneliner or hack for an internal project is one thing and writing and sharing something on the web which will be reused by others is another thing. It requires standardized code writing and build testing. In DevOPS philosophy what we call Continuous Integration/Continuous Deployment. Whenever we are changing a line of code the code is pushed into a testing system for a successfull build; once the build is successful it is deployed into production.&lt;/p>
&lt;p>Testing Ansible Roles on multi platforms is not an easy task. For local projects we can create &lt;a href="https://docker.com" target="_blank" rel="noopener">Docker&lt;/a> containers to test specially on Linux systems or we can test with &lt;a href="https://vagrantup.com" target="_blank" rel="noopener">Vagrant&lt;/a> using &lt;a href="https://https://virtualbox.org" target="_blank" rel="noopener">Virtualbox&lt;/a>. For normal syntax check we can use &lt;code>ansible-playbook&lt;/code> with &lt;code>--syntax-check&lt;/code> or &lt;a href="https://github.com/ansible/ansible-lint" target="_blank" rel="noopener">&lt;code>ansible-lint&lt;/code>&lt;/a>. But for real world scenario we need a good Testing Framework. &lt;a href="https://github.com/ansible-community/molecule" target="_blank" rel="noopener">molecule&lt;/a> is one good framework for the purpose. It has support for multi cloud platforms to deploy our testing. We can use &lt;a href="https://github.com/ansible-community/molecule" target="_blank" rel="noopener">molecule&lt;/a> to test locally or on remote cloud platforms or integrate it with additional CI/CD platforms like &lt;a href="https://travis-ci.org/" target="_blank" rel="noopener">Travis&lt;/a> or &lt;a href="https://cirrus-ci.org" target="_blank" rel="noopener">Cirrus&lt;/a> by creating a pipline from &lt;a href="https://github.com" target="_blank" rel="noopener">Github&lt;/a> or &lt;a href="https://gitlab.com" target="_blank" rel="noopener">Gitlab&lt;/a>. Both of them have commercial versions but for Open Source applications both of them are free. &lt;a href="https://galaxy.ansible.com" target="_blank" rel="noopener">Ansible Galaxy&lt;/a> has support for &lt;a href="https://travis-ci.org" target="_blank" rel="noopener">Travis&lt;/a> and &lt;a href="https://github.com" target="_blank" rel="noopener">Github&lt;/a>. So if my role is hosted at &lt;a href="https://github.com" target="_blank" rel="noopener">Github&lt;/a> and I have a proper definition of testing in a file called &lt;code>.travis.yml&lt;/code> in my root directory; whenever I have code change pushed into the &lt;a href="https://git-scm.com/" target="_blank" rel="noopener">git&lt;/a> repository my Ansible role will be tested and the result will be notified in my &lt;a href="https://galaxy.ansible.com" target="_blank" rel="noopener">Ansible Galaxy&lt;/a> project. Now the big problem for me is that &lt;a href="https://travis-ci.org" target="_blank" rel="noopener">Travis&lt;/a> do not have support for &lt;a href="https://freebsd.org" target="_blank" rel="noopener">FreeBSD&lt;/a> like &lt;a href="https://cirus-ci.org" target="_blank" rel="noopener">Cirrus&lt;/a>.&lt;/p>
&lt;p>So testing for my roles in a multi platform is facing a Road Block. We have to be a bit innovative. &lt;a href="https://github.com/ansible-community/molecule" target="_blank" rel="noopener">molecule&lt;/a> supports &lt;a href="https://vagrantup.com" target="_blank" rel="noopener">Vagrant&lt;/a> and &lt;a href="https://vagrantup.com" target="_blank" rel="noopener">Vagrant&lt;/a> has support for multiple Providers like &lt;a href="https://https://virtualbox.org" target="_blank" rel="noopener">Virtualbox&lt;/a>, &lt;a href="https://docker.com" target="_blank" rel="noopener">Docker&lt;/a>, &lt;a href="https://vmware.com" target="_blank" rel="noopener">Vmware&lt;/a>, &lt;a href="https://libvirt.org" target="_blank" rel="noopener">libvirt&lt;/a>. For a commandline based interface &lt;a href="https://libvirt.org" target="_blank" rel="noopener">libvirt&lt;/a> looks like a good choice. So we are going to create a &lt;a href="https://vagrantup.com" target="_blank" rel="noopener">Vagrant&lt;/a> and &lt;a href="https://libvirt.org" target="_blank" rel="noopener">libvirt&lt;/a> interface within our limited access &lt;a href="https://travis-ci.org" target="_blank" rel="noopener">Travis&lt;/a> platform; and push our code into that &lt;a href="https://libvirt.org" target="_blank" rel="noopener">libvirt&lt;/a> environment. Let&amp;rsquo;s jump into the code and see how we can accomplish this with &lt;a href="https://github.com/ansible-community/molecule" target="_blank" rel="noopener">molecule&lt;/a> and &lt;a href="https://travis-ci.org" target="_blank" rel="noopener">Travis&lt;/a>.&lt;/p>
&lt;p>My &lt;code>.travis.yml&lt;/code> looks like this.&lt;/p>
&lt;pre>&lt;code class="language-yaml">---
dist: bionic
language: python
python:
- 3.6
env:
global:
- VAGRANT_VER: 2.2.7
matrix:
- MOLECULE_DISTRO_BOX: generic/ubuntu1604
- MOLECULE_DISTRO_BOX: generic/ubuntu1804
- MOLECULE_DISTRO_BOX: debian/stretch64
- MOLECULE_DISTRO_BOX: debian/buster64
- MOLECULE_DISTRO_BOX: centos/7
- MOLECULE_DISTRO_BOX: centos/8
- MOLECULE_DISTRO_BOX: generic/freebsd11
- MOLECULE_DISTRO_BOX: generic/freebsd12
install:
- sudo add-apt-repository universe &amp;amp;&amp;amp; sudo apt update
- wget https://releases.hashicorp.com/vagrant/$VAGRANT_VER/vagrant_&amp;quot;$VAGRANT_VER&amp;quot;_x86_64.deb
- sudo dpkg -i vagrant_&amp;quot;$VAGRANT_VER&amp;quot;_x86_64.deb
- sudo apt install qemu-kvm qemu-utils libvirt-bin libvirt0 libvirt-dev
- vagrant plugin install vagrant-libvirt
- pip install molecule molecule-vagrant docker python-vagrant paramiko
- sudo chmod o+rwx /var/run/libvirt/libvirt-sock
script:
# Check ansible version
- ansible --version
# Check molecule version
- molecule --version
# Basic role syntax check
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check
- molecule test
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
&lt;/code>&lt;/pre>
&lt;p>My corresponding &lt;code>molecule/default/molecule.yml&lt;/code> looks like the following:&lt;/p>
&lt;pre>&lt;code class="language-yaml">---
dependency:
name: galaxy
driver:
name: vagrant
provider:
name: libvirt
type: libvirt
driver: kvm
options:
memory: 2048
cpus: 2
platforms:
- name: instance
box: ${MOLECULE_DISTRO_BOX:-&amp;quot;&amp;quot;}
interfaces:
- network_name: public_network
dev: &amp;quot;virbr0&amp;quot;
type: &amp;quot;bridge&amp;quot;
mode: &amp;quot;bridge&amp;quot;
provisioner:
name: ansible
log: true
verifier:
name: ansible
&lt;/code>&lt;/pre>
&lt;p>In the future I will try to create a &lt;a href="https://github.com/cookiecutter/cookiecutter" target="_blank" rel="noopener">CookieCutter&lt;/a> template for my roles for easier creation of directory and files layout. Please bear in mind that &lt;a href="https://travis-ci.org" target="_blank" rel="noopener">Travis&lt;/a> is supporting the OSS culture with free access to resources and do not abuse this service.&lt;/p></description></item><item><title>Fresh Boot to My Blog</title><link>https://bofh.im/post/fresh-boot-to-my-blog/</link><pubDate>Thu, 19 Mar 2020 02:57:57 +0600</pubDate><guid>https://bofh.im/post/fresh-boot-to-my-blog/</guid><description>&lt;p>It has been a while I have stopped blogging. In the early days I used to blog in &lt;a href="https://blogger.com" target="_blank" rel="noopener">Blogger&lt;/a>. But after the &lt;a href="https://www.theguardian.com/business/2003/feb/18/digitalmedia.citynews" target="_blank" rel="noopener">acquisition of Blogger by Google&lt;/a> it was actually time for me to shut it down.&lt;/p>
&lt;p>Since then I had been saving my documents in a local webserver running &lt;a href="https://moinmo.in" target="_blank" rel="noopener">MoinMoin&lt;/a> (incidentally my nickname is Moin too). However that was alright for a local environment and at that time finding a dedicated or shared hosting running Python WSGI was not easily available. Plus getting a dedicated hosting for hosting my platform wasn&amp;rsquo;t easy either. There were other options at that time specially &lt;a href="https://www.drupal.org" target="_blank" rel="noopener">Drupal&lt;/a>, then came &lt;a href="https://wordpress.org" target="_blank" rel="noopener">Wordpress&lt;/a>, then there was &lt;a href="https://www.joomla.org" target="_blank" rel="noopener">Joomla!&lt;/a>. Have gone through all of those but it seemed like all were overly complicated for a simple blogging platform. Asking about a personal blogging site my first preference is easy to write; afterall contents are the main attraction of a blog. So rather than maintaining the site it has to be the contents on which I am spending more of my time. I have worked on large scale deployments of &lt;a href="https://wordpress.org" target="_blank" rel="noopener">Wordpress&lt;/a> where the site was a daily national newspaper site with millions of view every day. Although didn&amp;rsquo;t have to go through the development side but had to take care of the deployment part.&lt;/p>
&lt;p>Unfortunately none of them cattered that need. &lt;a href="https://www.drupal.org" target="_blank" rel="noopener">Drupal&lt;/a> is actually considered the mother of all CMS, it&amp;rsquo;s huge. it&amp;rsquo;s robust, it&amp;rsquo;s complicated. &lt;a href="https://wordpress.org" target="_blank" rel="noopener">Wordpress&lt;/a> on the other hand incepted as a blogging platform but completely moved towards a full fledget CMS platform. But in today&amp;rsquo;s world it is completely undeniable that without the contribution of &lt;a href="https://wordpress.org" target="_blank" rel="noopener">Wordpress&lt;/a> we wouldn&amp;rsquo;t have got millions of blogs and contents running and the &lt;a href="https://w3techs.com/technologies/history_overview/content_management/ms/y" target="_blank" rel="noopener">market share&lt;/a> is increasing day by day. However due to this popular usage it has also been the victim of prying eyes and &lt;a href="https://www.cvedetails.com/vendor/2337/Wordpress.html" target="_blank" rel="noopener">there are lots of bugs and exploits too&lt;/a>. But most vulnerable seemed like &lt;a href="https://www.cvedetails.com/vendor/3496/Joomla.html" target="_blank" rel="noopener">Joomla!&lt;/a>; and least vulnerable was &lt;a href="https://www.drupal.org" target="_blank" rel="noopener">Drupal&lt;/a>.&lt;/p>
&lt;p>However coming back to my requirements I needed something more easier to write with; not concentrating on HTML tags or missing an angle brace but something more easier to write through; where I could concentrate on contents rather than technicals. There seemed couple of options which supported an easier Markup language to concentrate on writing : Wikitext, Markdown and TEX/Latex. Generating HTML from Latex/TEX wasn&amp;rsquo;t easy at that time. Markdown was a better choice but none of those supported Markdown; which lead me to use &lt;a href="https://moinmo.in" target="_blank" rel="noopener">MoinMoin&lt;/a> which had a Markdown alike Wiki syntax. So my first requirement is &lt;strong>markdown&lt;/strong>.&lt;/p>
&lt;p>Then comes processing power. Whenever I am using another scripting language to render the HTML pages it needs to use a CGI process which was pretty slow and have been updated with FastCGI/WSGI/SGI which are much more faster than CGI. Even though what happens is for every request the CGI process parses and prepares the content in HTML format that needs to be rendered to the browser. Even though you have a .php or .pl extension in the browser addressbar the actual rendering engine is plain old HTML. So I was looking for something which actually supported simple HTML without any fuss; because I had no dynamic contents and alll I need to show are some HTML files. But when you go HTML you limit your contents to be static only. What on earth would I do with dynamic contents? I don&amp;rsquo;t have thousands of users and their dynamic contents which needs to be rendered. Unfortunately there were no CMS that actually supported plain HTML without any Server Side technologies. On top of that all the above mentioned CMS required a Database Engine where my contents are actually saved in SQL format and whenever someone is trying to access a page or a post that content is called by the CGI process and the HTML file is rendered. Lots of system calls, lots of system process, lots of CPU cycle, lots of memory requirements. Overall low performance for the viewers. So to maintain a blog like the ones from above you have to actually maintain security of the scripting language, a database system and the CMS itself. Actually these take places behind the scene for so many users and noone bothers those because a Website control panel like cPanel/DirectAdmin/Webmin manages those automagically behind the scene. Additionally we will have to use or build up customized plugins/thems/modules which are not easy to do unless you have a good grasp on the language. Plus comes the security of those modules. So my next requirement is a &lt;strong>STATIC site with flat file support&lt;/strong>.&lt;/p>
&lt;p>If someone has actually plan to build an easy to use blog and which has the possibility of getting BIG I would advice on &lt;a href="https://ghost.org" target="_blank" rel="noopener">Ghost&lt;/a>.&lt;/p>
&lt;p>Coming back to my requirements I started looking for automatically generating my site from couple of Markdown files. &lt;a href="https://jekyllrb.com" target="_blank" rel="noopener">Jekyll&lt;/a> seemd a very good and interesting project which does the same. &lt;a href="https://jekyllrb.com" target="_blank" rel="noopener">Jekyll&lt;/a> along with &lt;a href="https://octopress.org" target="_blank" rel="noopener">OCTOPRESS&lt;/a> seemed like a good combination for me. Unfortunately it seems like &lt;a href="https://octopress.org" target="_blank" rel="noopener">OCTOPRESS&lt;/a> development has been stalled; &lt;a href="https://github.com/octopress/octopress" target="_blank" rel="noopener">last update looks like in 2016&lt;/a>. Then about &lt;a href="https://jekyllrb.com" target="_blank" rel="noopener">Jekyll&lt;/a> is not fit to generate thousands of pages; it&amp;rsquo;s just not that scalable and robust. On top of that I don&amp;rsquo;t know but &lt;a href="https://ruby-lang.org" target="_blank" rel="noopener">Ruby&lt;/a> didn&amp;rsquo;t look like something of my cup of tea. So if I required to hack something I might get stuck. In the meantime there was another project called &lt;a href="https://gohugo.io" target="_blank" rel="noopener">HUGO&lt;/a> which has been in the market for long. It was written in &lt;a href="https://golang.org" target="_blank" rel="noopener">go&lt;/a> so literally you will need one single binary file as most of the other modules and everything is built withing that binary. &lt;a href="https://gohugo.io" target="_blank" rel="noopener">HUGO&lt;/a> utilizes &lt;a href="https://jamstack.org" target="_blank" rel="noopener">JAMSTACK&lt;/a> technology. This application really intrigued me making my blog public again. Specially when I saw the following video.
&lt;div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
&lt;iframe src="https://www.youtube.com/embed/CdiDYZ51a2o" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" allowfullscreen title="YouTube Video">&lt;/iframe>
&lt;/div>
&lt;/p>
&lt;p>So &lt;a href="https://gohugo.io" target="_blank" rel="noopener">HUGO&lt;/a> is going to be my next Blogging Platform. If you are keen to try out other &lt;a href="https://jamstack.org" target="_blank" rel="noopener">JAMSTACK&lt;/a> platforms you can head to &lt;a href="https://www.staticgen.com/" target="_blank" rel="noopener">StaticGen&lt;/a> a site maintained by &lt;a href="https://www.netlify.com" target="_blank" rel="noopener">netlify&lt;/a>; a Company supporting Jamstack hosting with CDN.&lt;/p>
&lt;div class="alert alert-warning">
&lt;div>
There are so many dead or development stalled projects listed in &lt;a href="https://www.staticgen.com">StaticGen&lt;/a>. So please chose wisely.
&lt;/div>
&lt;/div>
&lt;p>As a techie from my point of view the deployment and maintenance didn&amp;rsquo;t look complex to me. I can maintain my contents in flat files and more over I can do Version Control by keeping them in a git repository. From there I can create a Continuous Integration/Continuous Delivery pipeline and deploy my site in seconds to the web server. Now I need a good theme. So I have chosen &lt;a href="https://sourcethemes.com/academic/" target="_blank" rel="noopener">Academic&lt;/a>. It really matches my requirements in point of content management and display. As I am a Conference Hopper and have papers published; it allows me to easily maintain and showcase those. Additionally I am planning to write tutorials and Courses which is supported really well. Keep an eye on this site for my upcoming tutorials on Networking/DevOPS/FreeBSD/System Administration.&lt;/p></description></item></channel></rss>