Advanced SmartOS Management Daemon

July 25th, 2015 | Categories: Personal, Programming, Solaris, Technology

I spent the last 3 days yak-shaving. I had the intent of looking into deploying SaltStack to monitor my zones at home. Instead I give you asmd AKA “Advanced SmartOS Management Daemon”. Yes I should really get better at naming things.

So what is this asmd you speak of, you may ask? It is my one pythonbash script to replace them all. SmartOS wise anyway. As you know I run a few SmartOS nodes at home, you may also know I really try to push IPv6 everywhere. SmartOS does not support this. After a few months I had collected a few hacks to make my life easier, each had their own smf service… You could see my learning progression in them as the quality improved as I got more familiar with the SmartOS internals.

I wrote a simple “framework” to plug in my little hacks and scripts, this framework is asmd. Once I had the base line I rewrote most of my hacks to leverage this framework. I originally wrote this in python that I pushed to the SmartOS nodes as an esky package. This was powerful but also complete, on day two I rewrote everything in bash.

So how does it work? Each ‘service’ lives in $PREFIX/services/name.service and sets a few variables to describe it self and implements 3 functions:

  • asmd_service_config :: execute on asmd-setup, this can be used to prepare some files and directories.
  • asmd_service_start :: runs when the service starts
  • asmd_service_stop :: runs when the service stops

The following variables are required

  • ASMD_SERVICE_NAME :: name of the service as it appears under smf
  • ASMD_SERVICE_DESC :: description use for the smf service
  • ASMD_SERVICE_TYPE :: for now only ‘transient’ is tested, although ‘daemon’ should also be supported.
  • ASMD_SERVICE_DEPENDENCIES :: svc identifiers for service dependencies
  • ASMD_SERVICE_DEPENDENTS :: svc identifiers for services dependent on this service

Functions marked in italic can be omitted, variables marked in italic can be empty.

When asmd-setup is ran, usually once after install or when adding/removing services a smf manifest is generated and placed in /opt/custom/smf so that SmartOS loads it at boot. Each service is a named instance under system/asmd. I decided to use /usbkey/config to store all the configuration individual services need.

Currently the following services are implented:

  • hostname :: set hostname and/or domain name at boot
  • profile :: symlinks files and folders into /root to customize the user environment (aka inject bash aliasses like vmadm wrapper that can use aliasses of zones)
  • exec :: executes each script located in /usbkey/ after network is up. Mostly used for quick and dirty hacks 😉
  • swap :: manage additional swap devices / can also remove the default zones/swap device
  • mail :: configure forwarding for root mails / (smart)relay host
  • cron :: inject cron jobs defined in /usbkey/config
  • ipv6 :: configure ipv6 address/gateway on admin_nic.

You can check it out on github:

Feel free to play around, open issue on github if you find things that are broken.

Comments are closed.