Files
gitea-pages/engineering-guide/puppet/components/utils.rst

33 lines
918 B
ReStructuredText

``utils``
=========
This module contains a number of utility functions used at PSI. It is the
PSI-specific analogue to Puppetlabs' ``stdlib``.
Functions
---------
``check_os``
~~~~~~~~~~~~
Accepts an arbitrary number of arguments, each of which is a string of the form
``$osfamily $majorversion`` as reported by ``facter(8)``. If the facts of the
client system **do not** match any of the arguments, the function aborts the
Puppet run.
``rand_time``
~~~~~~~~~~~~~
This function takes a parameter specifying a time window and returns a specific
time within this window based on the MD5 on the hostname. This allows scheduling
cron jobs etc uniformly across a fleet of system within a given window, while
keeping the time on each system predictable.
The format for the argument specifying the time window is ``HH:MM--HH:MM``. The
window must not include midnight.
The format of the return value is ``HH:MM``.