🧑‍💻 agile sysadmin

by Ferenc Erki

Installing Rex

We briefly describe the different ways to install Rex, the friendly automation framework on the Get Rex page of our website, as well as in the Installation section of our README:

  1. Install from the Comprehensive Perl Archive Network (CPAN)
  2. Use standard, native package managers
  3. Build from source code

Depending on the situation at hand, one of these often fit better than the rest.

Let’s go through the available options in more detail to help choosing the best match.

Install from CPAN

CPAN serves as a well-established software repository for the Perl community. As a Perl project, we feel it natural to upload our official Rex releases to CPAN, and we also consider that as the canonical source for both Rex packages and documentation.

For these reasons, we recommend to install the latest stable Rex version from there. This approach ensures using Rex versions in the same way we expect Rex to get installed.

On top of stable releases, we also upload trial versions to CPAN during development to provide early access, and to gain insights from CPAN Testers about the behavior of Rex across operating systems and Perl versions.

CPAN itself supports a set of clients, like cpan, cpanm, and cpm, offering further choices to match a wide range of preferences and circumstances.

These clients support running the built-in test suite of Rex and its dependencies, to verify everything can function as expected on the given machine.

In general, we also recommend to install Rex and its dependencies into a separate Perl environment, as provided by local::lib, perlbrew, plenv, or similar. This helps to keep a clean working environment to use Rex, isolating it from the system’s own Perl installations.

Use package managers

Thanks to the generous effort of package maintainers, many operating systems ship Rex through their own official package repositories. For a known list of such packages, check our Repology page.

It provides a convenient way to install Rex system-wide through native package management tools in a way deemed appropriate for proper integration into the given operating system.

This integration means package maintainers may decide to apply patches, use different set of dependencies, or offer different testing options in a way relevant for the used operating system. Some organizations decide to apply patches to Rex according to their specific preferences, and package that for their own users.

Since it may potentially lead to a different experience compared to the official packages released by us, please keep this in mind for the use case at hand, or when looking for support.

In any case, we feel more than happy to directly collaborate with downstream package maintainers to deliver a great experience with Rex to their communities. This includes supporting packagers to stay close to the official setup, for example by merging downstream patches into Rex itself, or identifying both mandatory and optional dependencies.

When noticing differences between our official releases and their packaged versions, please let both us and the package maintainers know, so we may figure out an even more streamlined delivery together.

Build from source

Even with publishing trial releases to CPAN during development, sometimes it fits best to use an unreleased version of Rex. For example:

  • requiring a recently merged, but still unreleased change
  • during development itself, especially when evaluating the whole build process
  • applying a custom patch to Rex

We host our code in the RexOps/Rex GitHub repository, and use Dist::Zilla to build our releases.

It handles the dependencies for development, runtime, and testing, including optional ones, as well as local installation.

Follow the steps below to build Rex from source.

Preparation

  1. Install Git, a CPAN client (we will use cpanm below), and Dist::Zilla
  2. Clone the source code with git clone https://github.com/RexOps/Rex
  3. Switch to the source code directory with cd Rex

Dependencies

  1. Install author dependencies with dzil authordeps | cpanm
  2. Install common dependencies with dzil listdeps | cpanm
  3. Install optional dependencies with dzil listdeps --suggests | cpanm

Installation

  1. Install operating system-specific dependencies and Rex itself with dzil install

Verifying the installation

After installation, check the current version with the following command:

$ rex -v
(R)?ex 1.16.0

I also like to run an ad-hoc task locally, like printing the hostname:

$ rex -e 'say run q(hostname)'

Summary

We looked at the main options to install Rex, their similarities and differences, as well as how to quickly verify the results.

Choose the best approach according to the situation.