Rollout Step Ordering

[ Up ]

Introduction

Rollout runs steps and custom commands in order using a priority queue which can be modified at runtime by steps and configuration.

Skipping Steps

There are few ways to cause steps not to be run on a machine or class of machines. The easiest way is using the -k command line parameter. For example, to skip the snmp and motd steps on a single run:

# rollout -k snmp -k motd

This works well when you only want to occasionally skip a step. If you want the step to be skipped permanently for this machine, use theskip_steps key in the configuration.

device machine => {
  skip_steps => [ "snmp", "motd" ],
};

Certain steps also have finer grained support for skipping parts of each step. Reading the header at the top of each step's code is the best way of finding out what can and can't be skipped.

For example, if you want to run the network step, but don't want it to change the hostname or update static routes, add the following configuration:

device machine} = {
  skip_steps => [ "network:routes", "network:hostname" ],
};

Changing Step Order

Add a reorder_steps key to the rollout block in the machine's configuration like this:

device machine => {
  rollout => {
    reorder_steps => [
      "240-dir-check" => 140,
    ],
  },
};

This will cause the dircheck step which is normally priority 240 to be run at 140 instead. If you want to make the step run at 240 and 140, use thecopysteps key:

device machine => {
  rollout => {
    copy_steps => [
      "240-dir-check" => 140,
    ],
  },
};

Custom Commands

Rollout supports the command key for defining arbitrary commands to be run at certain priority levels.

device machine => {
  command => [
   140 => "cp /bin/ls /tmp/foobar",
  ],
};

This form will cause the command to be run through the shell at level 140, and will not be run in safe mode.

Custom Perl Code

WARNING: This is probably not a good idea, as it does not do any checks for safe mode or correctness. If you want more than a single line or so of custom code, you should create a step instead. If you still want to do it, this is how:

device machine => {
  command => [
   140 => sub {
      for (my $i = 0; $i < 10; $i++) {
        l "This is some custom code";
      }
    },
  ],
};

Queueing Steps & Code from Steps

In step code you can queue up other steps and custom code to be run at a later time, using the queue_step, queue_command and queue_codefunctions.

Command Arg1 Arg2 Description
queue_step step name priority Queue a step to be run at a later time. You must specify the full filename of the step (e.g. 800-file_append)
queue_command shell code priority Run a command through the shell
queue_code coderef priority Run some perl code at a later time. You can pass either a reference to an existing function, or an anonymous sub

Each priority argument defaults to 998, which is just before completion of the current rollout run. Specify 0 as the priority to have it run immediately after the current step completes.

Examples of each function:

queue_step("240-dir_check", 0);  # Run the dir_check step next
queue_step("200-sysctl");        # Re-run the sysctl step at the end of the run
queue_command("echo complete");  # Run the command through the shell at the end of the run
queue_code(sub { print "This is some code here\n" }, 0);  # Run the anonymous sub after this current step