DevOps vs Systems Administration – Why should I care?

Originally, I was going to write about Ansible and how to run it in a Windows environment using Vagrant, but as I started to write the article, I found that I had to describe how these tools were used and developed around the culture and philosophy of DevOps. Then, it occurred to me, I needed to describe what is DevOps. According to Wikipedia, DevOps is a software development methodology that combines software development (Dev) with information technology operations (Ops). Of course, I’ll use DevOps definition in a broader sense and more oriented towards operations.

Why should I care? Isn’t systems administration and DevOps the same?
Not exactly. Being brought up on old school Unix Systems Administration, I remember when machines consisted of dedicated hardware(CPU, Memory, Framebuffer, hard drive, etc.) software and network switches and routers. I would spend hours configuring individual machines using scripts or installing software (or compiling it) one machine at a time. I would be working with a team of people it seems firefighting. Keeping up with the demands of the users and their needs for additional resources…well was a pain. Then we turned the corner with virtualization where your machine is just a disk image sharing space on high powered hardware, more efficient, easier to use programming languages such as python & ruby (though this can be debated, but these languages are easier than programming c) and working towards automation. Mass on demand Virtualization is now called “cloud computing” or what I call Commoditized Virtualization. You can get VMs on demand and pay for what you need even by the hour. Out of these merging of technologies and software development methodologies (such as Agile) is where DevOps finds its origins.

Contrasting Systems Administration with DevOps.

Systems Administration tends to focus on being a tech…that is a power user who loads and configures software and plugs in hardware into the system. DevOps on the other hand focus on programming and automation of the system and network infrastructure. The mantra is “Infrastructure is Code” where you write and run code to make running the systems and network infrastructure more predictable and controlled.

System Administration tends to be reactive. That is you plug in the hardware/software and find out if it works and fix it as you go. DevOps is proactive in its approach. Use automation in a consistent and predictable way by using tools to test in a development environment before releasing it into a production environment.

System Administration tends to follow a “waterfall” approach to planning, getting requirements and deployment. You tend to make big expenditures of capital, time and resources up front. You fix it as the complaints come in. DevOps approach is more “agile” with many smaller changes to the system with plenty of user feedback BEFORE it’s all rolled out as well as DURING and AFTER the rollout.

While your company or organization may not be a software development house, i.e. you may be a web design company or your supporting your own companies internal network, you WILL benefit from adopting a DevOps approach as this can be applied to:

1 – Rolling out new software to your internal desktop users and keeping them current.
2 – Keeping your customers websites updated using automation tools.
3 – Being able to show management (and other stakeholders) what is accomplished and what is needed. You keep them in the loop.

While this is not ment to be an exhaustive treatise on DevOps, this should open your eyes to what is useful and what is possible.

In the meantime, have a good day.

Roy

Software is perishable – Identify your HIDDEN requirements.

Software is perishable

In a world where fresh food goes stale then rots, pets are born, grow old and then die, software is perishable. What do I mean by that?

Requirements change

Isn’t software something that once it’s written just does it’s task and doesn’t change? Yes, that is true, but the REQUIREMENTS needed to keep software useful will change over time. Often the changes can be swift and rapid. This can get you and your business into trouble if you don’t keep your eye on it.

A way to look at software is what reason did you get the software in the first place. It filled a need, a requirement.

For instance, I get an accounting package…lets say KwikyBooks. I get the package for my accounting needs. Well, what are my requirements?

1 – Generate invoices of my customers.
2 – Take payments and track this information.
3 – Generate various reports.

Hidden REQUIREMENTS

However, there are HIDDEN requirements that may not be obvious until you start using your software:

1 – What kind of hardware does this software run on. If you can’t obtain or afford the hardware, the software will be useless.

2 – Is the software secure? If you can’t keep your confidential business data safe, you will lose customers because they can’t trust you to keep the information safe. It’s just a matter of time before someone or something hacks your system.

3 – Is the software keeping up with industry standards and practices? Is it compliant with Federal, State and Local laws? E-commerce businesses, depending on it’s size, for example may have to track sales tax in EVERY STATE it sells to. Every year the Federal and Local government adds new laws and regulations that affect accounting and Tax laws. Having software that is non-compliant with industry standards and laws can cost you money and even your business.

In the same way, even though your software you have purchased or have developed for your company or customers may fulfill your original requirements, the HIDDEN requirements often will change because the software doesn’t change with time.

Prepare for Hidden Requirements

With this in mined, here is what I’d suggest you do when you either purchase software or have it developed:

1 – Check on the stability of the developer or company you are getting your software from. Even if it’s AWESOME software, if the software developers who wrote it go away, you can’t get the software HIDDEN requirements fixed. If your working with an independent software developer, I would recommend you use a well known open source framework  and languages. In the worst case scenario, you can find a python or java developer to take over development ant maintenance of your software than something written in let’s say a Esoteric programming language or a language that is not as common to use these days (i.e. Fortran, Pascal, Assembly, etc.)

2 – Get or obtain a service contract or maintenance agreement for the software. With this in place, you keep the software developer vested  to keep your software up to date.

3 – Periodically review your requirements and discover what your HIDDEN requirements are and get them addressed.by the developers. The HIDDEN requirements are usually found in changes in these three categories:

a – Industry rules and standards – Software is codified expertise that follows the rules and standards of your industry.
b – Laws (Federal, State and Local) – Legal requirements affecting your industry or profession.
c – Technology  – New technology and advancements, including updates and security fixes.

I would recommend you work with your software developer or software company to help you keep track of these areas that can affect your software requirements. Incorporate this process if you are working with Agile software developer.

In summary, please re-examine your software requirements regularly and make sure you keep you software fresh. Don’t allow your software to perish along with your business.

In the meantime, have a good day.

Roy

How to write a WordPress Plugin part 3 – Creating the WordPress Plugin

Creating the WordPress Plugin

Ok, you just created the Javascript/HTML/CSS code you want to use for your WordPress site on an HTML page. How the heck you get this into your WordPress page? Well, with the magic of plugins.

What are plugins?

Plugins are a file and directory structure used by WordPress to add code to your WordPress site. Here is an example of the directory structure .

public_html/wp-content/plugins/
public_html/wp-content/plugins/movetotop/movetotop.php
public_html/wp-content/plugins/movetotop/assets
public_html/wp-content/plugins/movetotop/css
public_html/wp-content/plugins/movetotop/js
public_html/wp-content/plugins/movetotop/README.md

The main file that tells WordPress plugin how to run is movetotop.php

The other directories and files are:

README.md – Markdown readme file.
assets – image files and fonts used by plugin. Fontawesome is used here.
css – Cascading Stylesheet used by plugin. The stylesheet totop.css lives here
js – JavaScript files used by plugin. The JavaScript totop.js file code is here.

Creating the plugin.

Chop it up.

First things first, we will “chop” up the HTML and JavaScript code and place it where it needs to go.

To make the file naming consistant with the plugin name, I renamed the custom.css file to totop.css and custom.js to totop.js. Otherwise, there is no change to the content of the files or code enclosed.

I also separated the fontawesome files into assets/fontawesome-5 directory so to better organize these assets.

Movetotop.php and how it’s organized.

The real magic of WordPress plugin is found in the movetotop.php file.

There are three sections found in a plugin file:

Header. This is commented header enclosed is /* */

add_action/add_filter – this tells WordPress to execute scripts to add the CSS/HTML/JavaScript files into the HTML generated by WordPress sent to the web browser.

Function(s). This is the scripts that injects the CSS, HTML or JavaScript files when called by add_action/add_filter.

Well, let’s go into how this file is created and what is used.

Header File

Header file contains the following:

/*
Plugin Name:
Plugin URI:
Description:
Author:
Version:
Author URI:
*/

This is self explanatory. Without this information, the plugin will not show up in the WordPress plugin dashboard.

The hook function

The hook functions add_action/add_filter – This adds the CSS/HTML and JavaScript file into WordPress hooks. Generally, hooks are the location of the content.

Here are the five hooks used by this plugin:

add_action(‘wp_head’,’AddFontAwesomeCSS’);
add_action(‘wp_head’,’AddMoveToTopCSS’);
add_filter(‘the_content’,’AddMoveToTopButton’);
add_action(‘wp_footer’,’LoadJQuery’);
add_action(‘wp_footer’,’AddMoveToTopScript’);

Basically, the format is:

(Location of content(hook), Function content to be applied).

There are MORE hooks than what we’re using here (over 1,000+ hooks, see this link for a comprehensive list) which do a variety of things. For this example we’re just sticking to the basic ones.

Function

The function that injects the content inside the HTML.

Here is an example:

function AddMoveToTopCSS() {
$cssurl=plugins_url(‘/css/totop.css’,__FILE__);?>
<link rel=”stylesheet” href=”<?php echo $cssurl; ?>”>
<?php }

This function injects the css/totop.css file name and location and outputs it as a text HTML reference. This is then called by the hook function and injected in the location (hook) specified.

Wrap up.

That’s how you develop a basic WordPress plugin. We didn’t cover other stuff like an admin backend interface with configurable parameters. That we may do another time.

In the meantime, have a good day.

Roy

 

 

 

 

How to write a WordPress Plugin part 2 – Static HTML/CSS/JavaScript

When you write a WordPress plugin, you are essentially inserting HTML and JavaScript code into a webpage. The first thing you do is write a static HTML page with the effect you have in mind first.
While there are several kinds of plugins available for WordPress, we’ll only concern ourselves with adding a feature to the site as described above.

The first thing I did was fire up my favorite editor.
I used Visual Studio Code https://code.visualstudio.com/. You can use any editor you wish such as Sublime, Brackets, Notepad++, Atom.
I like VS Code since it integrates EMMET https://emmet.io/, has built in IntelliSense https://en.wikipedia.org/wiki/Intelligent_code_completion#IntelliSense, and supports several plugins that make it very useful.

If you follow the link https://github.com/roadkillon101/HTML-example-of-MoveToTop, you can download the source files.

The first file I’d like you to look at is the index.htm file.
If you open it up in a web browser, you will see a bunch of lorem ipsum text. You scroll down the page, the “move-to-top” button will show up at the lower right hand corner of the web page. You press the button and the page will scroll to the top of the page.
Open up this index.htm file in the editor and I’d like you to notice the following:

<script type="text/javascript" src="./js/lib/jquery/jquery-1.10.2.js"></script>
<script type="text/javascript" src="./js/custom.js"></script>
<link rel="stylesheet" type="text/css" href="./css/fontawesome-all.css"/>
<link rel="stylesheet" type="text/css" href="./css/custom.css"/>

To make the button appear, we need the following:

JQuery – for the animation effects.

FontAwesome – for the up angles in the button.

custom.js – for the JavaScript code.

custom.css – for the styling of the button.

We also have the button itself with the FontAwesome fonts in the HTML.

<button onclick="topFunction()" id="toTop" title="Go to top"><i class="fas fa-angle-double-up fa-2x"></i></button> 
</button>

This code has to first work in a static HTML page before you make it work anywhere else.
I tweeked the code until it looked right and behaved as I expected it to here before making it work as a plugin in WordPress.

I won’t go into detail about how to write JavaScript or write CSS styling. You can examine the code and see how it works.

What I want you to notice is where the snippets of code are placed in the HTML. This is where the snippets need to be placed in the WordPress dynamically generated pages.

In this case, the code is in the header of the HTML and the body.

The next article will describe how to turn it into a WordPress plugin.

 

Writing a basic WordPress plugin (MoveToTop) part 1 – Basic overview

You may wonder how you go about modifying your WordPress site just adding a piece of JavaScript code.

Perhaps you are handy with writing some HTML, CSS, and JavaScript but you don’t know where to begin with converting it into a plugin for WordPress.

I will show you how you can do this with the MoveToTop example plugin that I have created and placed on GitHub.

You don’t have to write a whole blown out plugin if you just want to add a simple code snipped or tweak to your site, plus you can use it in ANY of your sites you need this snippet.

This plugin which I use on this site, creates a button on the lower right corner of the web page. When you click on it, it moves the web page to the top of the page (Get it…move to top…) You can customize it’s behavior and appearance by modifying the CSS and JavaScript code.

To get this magic to work, the first thing you need to do is to write a basic HTML page with the plugin in question. The script (totop.js) has to be working along with the HTML (found in movetotop.php), CSS (totop.css) appropriate libraries such as J QueryFont Awesome.

I wrote a static HTML page and made this page work first.

In the next article, I will show you how I developed the test code.