KANIF(1)

πŸ“¦
version 1.2.2 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu questing

πŸ’– KANIF β€” kanif(1) πŸ’–

okay bestie, sit DOWN, because we're about to talk about kanif β€” a TakTuk wrapper for cluster management. yes, that kanif. the one your sysadmin bestie has been gatekeeping. let's get into it ✨


🌸 NAME 🌸

kanif β€” a TakTuk wrapper for cluster management. that's it, that's the whole name section, slay.


✨ SYNOPSIS ✨

kash|kaget|kaput [-aFHhimqsV] [-f conf-file] [-l login] [-M
machines-list] [-n|-w nodes] [-o options] [-p level] [-r command] [-T
options] [-t timeout] [-u timeout] [-x nodes] [machines specifications]
[command body]

no cap, that's the whole vibe right there πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so kanif is a tool for cluster management and administration. it's giving "I took the best parts of c3, pdsh and dsh" β€” it combines the main features of those well-known cluster management tools and it mimics their syntax, because your fave could never make you relearn everything. for the effective cluster management it relies on TakTuk, a tool for large scale remote execution deployment. iconic behavior honestly 🫢

and like, here's the tea: for simple parallel tasks that have to be executed on regular machines such as clusters, the TakTuk syntax is too complicated. so the goal of kanif is to provide an easier and familiar syntax to cluster administrators while still taking advantage of TakTuk characteristics and features β€” that's adaptivity, scalability, portability, autopropagation and information redirection. periodt. 🌈

to work, kanif needs to find the "taktuk" command (version 3.3 and above) in the user path. the other requirements are the same as TakTuk: it requires, on all the nodes of the cluster, a working Perl interpreter (version 5.8 and above) and a command to log without password (such as "ssh" with proper rsa keys installed). no shortcuts bestie, get those keys set up πŸ”‘

kanif provides three simple commands for clusters administration and management:

  • kash: runs the same command on multiple nodes
  • kaput: broadcasts the copy of files or directories to several nodes
  • kaget: gathers several remote files or directories

kanif combines the advantages of several cluster management tools. its main features can be summarized as follows:

  • C3-style configuration file for static clusters setups πŸ—‚οΈ
  • pdsh-like options such as nodes ranges and timeouts ⏱️
  • dshbak-like gathering, sorting and merging of output πŸ“¦

as with "pdsh", kanif deployment can be monitored and controlled by signals. when kanif receives a SIGINT (usually sent by typing Ctrl-C), it displays a brief summary of its deployment state and commands execution progress. after this first SIGINT, if kanif receives a second signal within one second:

  • it terminates its execution (cancelling any ongoing task) if this is a SIGINT
  • it cancels any ongoing connections and start executions on the already deployed nodes if this is a SIGTSTP (usually sent by typing Ctrl-Z)
πŸ’€ bestie the double-signal thing is real, so don't just mash Ctrl-C and expect nothing to happen. second signal within a second = big mood, big consequences.

at the end of executions, kanif also reports a quick summary of failures: connections and commands execution. so you'll know exactly what ate and what flopped πŸ™ˆ


πŸŽ€ OPTIONS πŸŽ€

to help administrators in their task, kanif options syntax is as close as possible to C3/pdsh/dsh well known tools. so if you already know those, you're lowkey already fluent πŸ’…

  • -a, --all β€” Deploys on all nodes of all configured clusters. the whole squad, no one left out ✨
  • -f conf-file, --file conf-file β€” Uses "conf-file" as configuration file instead of default. Several possibilities are examined for default configuration file, in order: "$HOME/.kanif.conf", "/etc/kanif.conf", "/etc/c3.conf". it's giving "I'll find my own way home" 🏠
  • -F, --flat-deployment β€” Deploys all remote execution from the root node (which executes kanif). Useful when remote nodes cannot log on each other. flat hierarchy, very demure, very mindful πŸ¦‹
  • -H, --head β€” Deploys only on clusters "head" node (using local interface) for all specified clusters. just the main character of each cluster πŸ‘‘
  • -h, --help β€” Prints a short help text and exits. the "help me bestie" button 🫢
  • -i, --interactive β€” Asks confirmation before any action. An action is either the execution of one command on all the hosts (default) or the execution of one command on one host (sequential mode, see -s switch). consent before action, as it should be πŸ’–
  • -l login, --login login β€” Uses the given "login" to connect to remote hosts. who are you logging in as, bestie? πŸ”‘
  • -M machines-list, --list machines-list β€” Adds to the remote hosts the names contained in the file named "machines-list". kanif accepts as many -M options as you wish. stack 'em like friendship bracelets πŸŽ€
  • -m, --monitoring β€” Makes kanif more verbose about whats happening during deployment commands execution. it's giving narrator voiceover πŸ—£οΈ
  • -n nodes, --nodes nodes β€” Adds the given "nodes" to the deployment. See section "HOSTNAMES SPECIFICATION" for more information about "nodes" syntax. kanif accepts as many -n options as you wish. yes bestie, as many as you want ✨
  • -o options, --remote-opts options β€” Sets additional options to be passed to the remote shell command. little extra sprinkle on top 🌸
  • -p level, --postprocess level β€” Sets the level of output formatting made in kanif. The general idea is: the higher the level, the more sorted, merged and human readable the output. Default is 4. different levels are:
    • 0 β€” No processing at all: raw commands output is printed to stdout and raw commands error is printed to stderr. Connections and executions errors are not reported. feral mode, no filter πŸ’€
    • 1 β€” Same as 0 except that the name of the host which produced the output is prepended before each line. now with name tags 🏷️
    • 2 β€” Same as 1 except that the output is sorted by command (one complete command execution is outputed entirely before another one). Connections and executions errors are summarized at the end to stderr. organized queen πŸ‘‘
    • 3 β€” Same as 2 except that the hostname is printed once, formatted as a title, before its output. title card energy 🎬
    • 4 β€” Same as 3 except that identical output produced by multiple nodes is printed once with all the hosts summarized in the title. the "you're all saying the same thing" merger πŸ’–
  • -q, --dry-run β€” When this option is given, kanif does nothing and prints its configuration, the remote nodes it would have tried to contact and the TakTuk command that would have been executed. manifesting without doing, honestly iconic πŸ¦‹
  • -r command, --remote-cmd command β€” Sets the name of the "command" used to contact remote hosts (default is "ssh -o StrictHostKeyChecking=no -o BatchMode=yes"). the way that default is SO specific, I'm obsessed 😭
  • -s, --sequential β€” Each command is executed sequentially on remote hosts (using the order given on the command line as hosts order). one at a time, patient bestie 🧚
  • -T options, --taktuk-options options β€” Allows power users to pass some options to the TakTuk command executed.
⚠️ caution: always include -s which is the default unless you really know what you are doing. fr fr, do not skip the -s unless you're built different. πŸ”₯
  • -t timeout, --timeout timeout β€” Gives a timeout value for connection attempts. At expiration, connection is canceled and deployment on the remote host is aborted. ghosted by the host, respectfully πŸ‘»
  • -u timeout, --upper-limit timeout β€” Gives a timeout value for commands execution. At expiration the command is killed with a TERM signal. time's up bestie πŸ•°οΈ
  • -V, --version β€” Prints kanif version and exits. the "who even am I" check ✨
  • -w, -wcoll β€” Synonym to -n. just a little nickname, iykyk πŸ’…
  • -x nodes, --exclude nodes β€” Excludes some nodes from the ones given using -n or -w. Applies to all hosts sets that do not already contain an exclusion part. Does not apply to host given with -M option. the "not you bestie" list πŸ™ˆ

🌈 ENVIRONMENT 🌈

usually all kanif options can be set by environment variables. the rationale is that boolean options have 0/1 value and environment settings are overridden by command line switches. so CLI always wins, as it should πŸ’…

the name of an environment variable used by kanif is made of the long option name capitalized with dashes replaced by underscores and "KANIF_" prepended (for instance "KANIF_ALL", "KANIF_HEAD", and so on). this rule admits the following exceptions (that have been chosen to mimic C3/dsh behavior):

  • KANIF_CONF β€” Instead of KANIF_FILE for configuration file. plot twist πŸŽ€
  • KANIF_USER β€” Instead of KANIF_LOGIN for login name. another plot twist ✨

notice also that the variable KANIF_WCOLL has no meaning to kanif. it's giving "I'm here but I do nothing" πŸ’€


πŸ¦‹ HOSTNAMES SPECIFICATION πŸ¦‹

hostnames given to kanif might be simple machine name or complex hosts lists specifications. in its general form, an hostname is made of an host set and an optional exclusion set separated by a slash. each of those sets is a comma separated list of host templates. each of these templates is made of constant parts (characters outside brackets) and optional range parts (characters inside brackets). each range part is a comma separated list of intervals or single values. each interval is made of two single values separated by a dash. this is true for all hostnames given to kanif (both with -M or -n/-w options). okay so basically it's a whole grammar and honestly? she ate 🌸

in other words, the following expressions are valid host specifications:

node1
node[19]
node[1-3]
node[1-3],otherhost/node2
node[1-3,5]part[a-b]/node[3-5]parta,node1partb

they respectively expand to:

node1
node19
node1 node2 node3
node1 node3 otherhost
node1parta node2parta node2partb node3partb node5partb

notice that these list of values are not regular expressions ("node[19]" is "node19" and not "node1, node2, ...., node9"). this trips people up EVERY time, bestie, so read it twice πŸ“–

intervals are implemented using the perl magical auto increment feature, thus you can use alphanumeric values as interval bounds (see perl documentation, operator ++ for limitations of this auto increment). magical indeed ✨


πŸŽ€ MACHINES SPECIFICATIONS πŸŽ€

with kanif, you can specify the remote nodes on which you want to do some stuff using the command line switches (-n and -x, pdsh/dsh style), using machines specifications (C3 style) or both. thus, this part of the documentation might be ignored if you do not want to use C3 style nodes management. no pressure, bestie, skip it if it's not your era 🫢

to use machines specification you must describe your cluster in a configuration file (see -f option and kanif.conf(5)). machines specifications are nodes intervals taken from clusters defined in this file. so like, the config file is the blueprint πŸ“

a machine specification is an optional cluster name followed by a colon and an optional range. the default cluster is taken if no cluster name is given. all the nodes of the cluster are taken if no range is given. notice that if none of -n/-w, -M or machine specification is given on the command line, the remote hosts are assumed to be all the nodes of the default cluster. default behavior, default cluster, default everything β€” very "going with the flow" of her 🌊

✨ COMMAND BODY ✨

okay so depending on the name you used to call it β€” kash, kaput or kaget β€” kanif is doing a completely different job. it's giving three separate main character eras, and here's what each one does:


kash

kash [options] [command line]

runs the last part of the command line on all the remote hosts. if that last part is empty, it drops into interactive mode where kanif waits for a command (one per line) on stdin. in interactive mode, just send an EOF character (Ctrl-D) to exit kash. πŸ’…

kaput

kaput [options] src1 [src2 ...] dest

copies one or more files or directories to all the remote hosts. the last argument is the path to the destination file or directory on the remote machine. the other arguments are local files or directories to copy. its behavior and limitations are similar to the command cp(1). 🫢

kaget

kaget [options] src1 [src2 ...] dest

downloads one or more files or directories from all the remote hosts. the last argument is the path to the destination directory on the local machine. the other arguments are paths to files or directories on remote hosts. each source must be present on all the remote hosts. sources are copied to the destination directory having the originating host appended to their name. 🌸


notice that when using kaget or kaput each file or directory is completely copied before proceeding to the next one. no cutting corners, bestie. ✨

🌈 EXAMPLES 🌈

when a configuration file exists on the system or is given on the command line (see option -f), remote machines can be specified via clusters names. for instance, the simple execution of the command "ls -l" on all the nodes of the cluster named "megacluster" can be written:

kash megacluster: ls -l

intervals can also be given. the following command copies the local .cshrc file to the login directory of a subset of the default cluster and another subset of the "megacluster":

kaput :3-6 megacluster:2-5 $HOME/.cshrc .

finally, one can take advantage of the default behavior to gather a file named "results.txt" placed in the /tmp directory on all the nodes of the default cluster to the local directory "results":

kaget /tmp/results.txt results

when a user does not want to write a configuration file or just wants to deploy on some other nodes, it is possible to give remote hosts on the command line:

kash -n localhost,supernode uptime

this last command will just execute "uptime" on "localhost" and "supernode". giving intervals and exclusion lists is also possible on the command line. the following command copies the file /tmp/temporary.txt to the remote /tmp directories of node1 and node5:

kaput -n node[1-6] -x node[2-4],node6 /tmp/temporary.txt /tmp

finally, without entering into the details of each option, the final command illustrates the -u option. it executes during 5 seconds a "ping" to "gateway" from 5 nodes:

kash -n node[1-2],node[4-6] -u 5 ping gateway

πŸ’€ BUGS πŸ’€

missing features:

  • indirect clusters not supported (see C3 documentation about such clusters)
  • when there are no machine to deploy and kanif runs in interactive mode, kanif still waits for a command (or eof) before exiting

performance issues:

  • the algorithm used by kaput is not very efficient for transferring large files. although the precise limit depends on the machine, it should not scale well above a few hundreds of megabytes.

πŸ‘€ SEE ALSO πŸ‘€

taktuk(1), kanif.conf(5)

πŸ’– AUTHOR πŸ’–

the author of kanif and current maintainer of the package is Guillaume Huard. acknowledgements to Lucas Nussbaum for the idea of the name "kanif".

kanif is provided under the terms of the GNU General Public License version 2 or later.


this page came from perl v5.34.0 and is dated 2022-07-28. mwah, go slay some remote hosts πŸ’…βœ¨

πŸ“¦ where this page comes from