Ferry Boender

Programmer, DevOpper, Open Source enthusiast.

Email: ferry.boender@gmail.com
Github: https://www.github.com/fboender
Résumé: PDF, Dutch
PGP key: PGP key
Blog: Electricmonk.nl
Keybase: fboender

Introducing ScriptForm: Stand-alone webserver that generates forms to serve as frontends to scripts

Monday, December 7th, 2015

I've just releases v1.0 of ScriptForm.

ScriptForm is a stand-alone webserver that automatically generates forms from JSON to serve as frontends to scripts. It takes a JSON file which contains form definitions, constructs web forms from this JSON and serves these to users over HTTP. The user can select a form and fill it out. When the user submits the form, it is validated and the associated script is called. Data entered in the form is passed to the script through the environment. See the Example to learn more about how it works.

I wrote ScriptForm to quickly give non-technical users the ability to perform restricted actions through a friendly web interface. Some use-cases I've used it for so far:

  • Allow users to upload CSV files that need to be processed
  • Let non-technical users create and modify Apache htpasswd files (add, delete and reset user passwords).
  • Give customers the ability to view their services' status and restart certain services which tend to hang every so often.
  • Given a certain date range, export data as CSV files.
  • Serve as a simple REST API that's incredibly easy to set up and use. 

Some features it includes are:

  • Very rapidly construct forms with backends.
  • Completely standalone HTTP server; only requires Python.
  • Callbacks to any kind of script / program that supports environment variables.
  • User authentication support through Basic HTAuth.
  • Validates form values before calling scripts.
  • Uploaded files are automatically saved to temporary files, which are passed on to the callback.
  • Multiple forms in a single JSON definition file.
  • Scripts can produce normal output, HTML output or stream their own HTTP response to the client. The last one lets you stream images or binaries to the browser.
  • Run scripts as different users without requiring sudo.

ScriptForm is Free Software / Open Source software released under the GNU GPL v3.

Some links for further information:

Github repository / sourcehttps://github.com/fboender/scriptform
Download releaseshttps://github.com/fboender/scriptform/releases, packages are available for Debian, Redhat and other Linux-bases systems.

Ansible-cmdb v1.8: Bugfixes and new columns

Saturday, December 5th, 2015

I've just released ansible-cmdb v1.9. Ansible-cmdb takes the output of Ansible's fact gathering and converts it into a static HTML overview page containing system configuration information. It supports multiple templates and extending information gathered by Ansible with custom data.

This is a feature and bugfix release, including the following changes:

  • Always output UTF-8.
  • Added the 'json' template, which dumps the entire inventory including variables and groups in JSON format.
  • Included a manual page in the packages.
  • The -t/–template switch can now point to an actual filename, and no longer requires the .tpl extension to be stripped.
  • html_fancy: Fixed a bug where the search field was not properly focussed.
  • html_fancy: Use vcpus for cores + hyperthreading count (Rowin Andruscavage)
  • html_fancy: New cpu, memory, swap columns and improved sorting (Rowin Andruscavage)
  • html_fancy: Show a hosts groups in the detailed view
  • html_fancy: Move and disable/enable some default columns.
  • html_fancy: Network overview table for host details.

Here's a screenshot showing some of the new columns:


Get the new release from the Github releases page.

Bexec v0.9 has been released

Saturday, December 5th, 2015

Bexec is a vim plugin that allows the user to execute the current buffer. Version 0.9 has just been released.

This version changes Bexec so it's autoloaded on demand, rather than always. This reduces Vim startup times if you're not going to use Bexec. Many thanks to Lucas Hoffmann for this change.

The new version can be found on the Vim scripts page.

Ansible-cmdb v1.7: New columns and togglable columns

Sunday, November 8th, 2015

I've just released ansible-cmdb v1.7. Ansible-cmdb takes the output of Ansible's fact gathering and converts it into a static HTML overview page containing system configuration information. It supports multiple templates and extending information gathered by Ansible with custom data.

This is a feature and bugfix release, including the following changes:

  • Support for showing only specific columns using the -c / –columns commandline argument. This must be supported by the template. Currently html_fancy and txt_table are supported.
  • The html_fancy template now properly automatically focusses the search box.
  • Two new columns were added to the html_fancy template: kernel and timestamp. (By Rowin Andruscavage)

Get the new release from the Github releases page.

Screenshot showing the output of ansible-cmdb -c name,fqdn,main_ipv4,os,kernel


Interesting links: October 4th 2015

Sunday, October 4th, 2015

Here's a bunch of links I found interesting in the last few weeks:

Batch create new users on Linux

Sunday, October 4th, 2015

A while ago I had to create many new users on a Linux machine. Since I'm lazy, I opted to automate this process. The newusers command combined with pwgen (to generate new passwords) was the solution.

First I installed pwgen, a utility to automatically generate passwords:

$ sudo apt-get install pwgen

I created a file with the new user names to create.

$ cat newusers.txt

A simple shell one-liner generates a new file from this in the right format for the newusers tool:

$ for USER in $(cat newusers.txt); do 
  echo "$USER:$(pwgen 12 -n1)::::/home/$USER:/bin/bash" >> newusers.created.txt;

Finally, we create the new users:

$ sudo newusers newusers.created.txt

The newusers.created.txt file was handed over to the person in charge of notifying the users about their new account.

Auto-mount external USB disk on a server

Sunday, October 4th, 2015

Althought modern Linux desktops generally automatically mount external USB disks when plugged in, servers usually don't do this. When I replaced my home server desktop model with a Raspberry Pi 2 (running Raspbian), I wanted it to automatically mount USB drives and, more importantly, make the same USB drive available at the same path at all times.

Enter usbmount

The USBmount Debian package automatically mounts USB mass storage devices (typically USB pens) when they are plugged in, and unmounts them when they are removed. The mountpoints (/media/usb[0-7] by default), filesystem types to consider, and mount options are configurable. When multiple devices are plugged in, the first available mountpoint is automatically selected. If the device provides a model name, a symlink /var/run/usbmount/MODELNAME pointing to the mountpoint is automatically created.

Just what I needed.

root@rasp# sudo apt-get install usbmount
# Plug in USB drive
root@rasp# ls -la /var/run/usbmount/
total 0
lrwxrwxrwx 1 root root 11 Oct  4 10:30 Seagate_Expansion_1 -> /media/usb0
lrwxrwxrwx 1 root root 11 Oct  4 10:30 ST4000DM_000-1F2168_1 -> /media/usb1

Great. Now I wanted the "Seagate_Expansion_1" disk to always become available at /storage. I could have created a symlink from /storage to  /var/run/usbmount/Seagate_Expansion_1, but I ran into a problem with SSHfs when trying to mount a server-side symlink on my client machine:

user@client$ sshfs -o transform_symlinks -o follow_symlinks Shares/timmy-storage/ Not a directory

So a symlink was out of the question. The binding option of 'mount' however, worked just fine:

# On the server
root@rasp# rm /storage
root@rasp# mkdir /storage
root@rasp# mount --bind /var/run/usbmount/Seagate_Expansion_1 /storage

# On the client
user@client$ sshfs Shares/timmy-storage/
user@client$ ls -l Shares/timmy-storage
total 72
drwxr-xr-x 1 1002 1003 4096 Sep 17 13:58 apps
drwxr-xr-x 1 root root 4096 Aug 24 09:15 backup

So I modified /etc/usbmount/mount.d/00_create_model_symlink and added the following code:

if [ "$name" = "Seagate_Expansion_1" ]; then
    mount --bind "/var/run/usbmount/$name" /storage

This is not a very clean solution, but it serves its purpose just fine. A nicer implementation would create a new file "01_mount_bind" which reads a config file to determine which model names to mount –bind where. That implementation is left as a reader exercise ;-)

With this setup the /storage path will automatically become available at boot-time or when the correct USB drive is plugged in. I can use SSHfs to mount the remote /storage on my Linux machine. Samba takes care of the Windows users.

Ansible-cmdb v1.6: Support for dynamic inventories (and more)

Saturday, October 3rd, 2015

I've just released ansible-cmdb v1.6. This is a feature release, including the following changes:

  • The -i switch now supports reading dynamic inventory scripts.
  • host_vars directory now supported (by Malcolm Mallardi)
  • Support for multiple inventory sources as per Ansible's documentation.
  • Improved error handling prevents ansible-cmdb from stopping if it encounters non-critical errors (malformed host definitions, etc).
  • Improved error reporting.
  • html_fancy template column headers are now visually identifiable as being sortable.

Get the new release from the Github released page.

A new Material design for Ansible-cmdb v1.5

Monday, September 21st, 2015

Ansible-cmdb takes the output of Ansible's setup module and converts it into a static HTML overview page containing system configuration information.

While the previous generated overview page was functional, it didn't look very good. So for the v1.5 release (which is now available), I gave it an overhaul. I decided on Material design because it gives a modern, clean look and feel. The host overview page now looks like this:




The column toggle buttons are more recognisable as actually being toggles and the table of hosts feels a lot cleaner. The bar at the top stays in view even when scrolling. When viewing a hosts detailed information, the header text changes to the host name, making it easier to recognise which host's information you're looking at:



The header bar also includes a link back to the top of the page. This is a big improvement over the previous design, which lacked such a feature.The new design also works better on smaller screens such as tablets or mobiles, although it could still do better.

Other than the new design, the v1.5 release also works when viewing it locally in the browser, without the need to specify the -p local_js option.

You can view a live example or download the new release from the Github releases page.

More information on ansible-cmdb can be found in the README.



Ansible-cmdb v1.4: a host overview generator for ansible-managed hosts

Tuesday, September 1st, 2015

Ansible-cmdb takes the output of Ansible's setup module and converts it into a static HTML overview page containing system configuration information. It supports multiple templates and extending information gathered by Ansible with custom data.

You can visit the Github repo, or view an example output here.

This is the v1.4 release of ansible-cmdb, which brings a bunch of bug fixes and some new features:

  • Support for host inventory patterns (e.g. foo[01:04].bar.com)
  • Support for 'vars' and 'children' groups.
  • Support passing a directory to the -i param, in which case all the files in that directory are interpreted as one big hosts file.
  • Support for the use of local jquery files instead of via a CDN. Allows you to view the hosts overview in your browser using file://. See README.md for info on how to enable it (hint: ansible-cmdb -p local_js=1).
  • Add -f/–fact-caching flag for compatibility with fact_caching=jsonfile fact dirs (Rowin Andruscavage).
  • The search box in the html_fancy template is now automatically focussed.
  • Show memory to one decimal to avoid "0g" in low-mem hosts.
  • Templates can now receive parameters via the -p option.
  • Strip ports from hostnames scanned from the host inventory file.
  • Various fixes in the documentation.
  • Fixes for Solaris output (memory and disk).

I would like to extend my gratitude to the following contributors:

  • Sebastian Gumprich
  • Rowin Andruscavage
  • Cory Wagner
  • Jeff Palmer
  • Sven Schliesing

If you've got any questions, bug reports or whatever, be sure to open a new issue on Github!

The text of all posts on this blog, unless specificly mentioned otherwise, are licensed under this license.