Create completely offline Ansible Tower bundle installation

19 minute read


The bundled package for Ansible Tower still depends on OS repositories. This article shows you how to prepare an Ansible Tower package that includes every required package.


In some cases you might want to generate a completely bundled and independent installation that is not dependent on anything at all. In this article I show you how to do that.

The Problem

Red Hat’s Ansible Tower can be installed using a bundled package. The bundled installation program is meant for customers who cannot, or would prefer not to, install Tower (and its dependencies) from online repositories. However, access to Red Hat Enterprise Linux or CentOS repositories is still needed.

The Solution

In order to perform a fully offline installation of Ansible Tower we will use the bundled package. However, the bundled package does not include all the necessary OS packages to perform an offline installation. So we need to determine what else is required. This will depend on which OS you intend to use, since many packages come from the the base OS repository.

As stated from Ansible Tower documentation…

A list of package dependencies from Red Hat Enterprise Linux repositories can be found in the bundle/base_packages.txt file inside the setup bundle. Depending on what minor version of Red Hat Enterprise Linux you are running, the version and release specified in that file may be slightly different than what is available in your configured repository.

Note that the bundled package does not need anything from the extras repository but rather only from the OS base packages.

Download Software

You will basically need to download two pieces of software.

  • Download the latest Ansible Tower bundle from this location
  • Download the Operating System ISOs or if you are using Red Hat Satellite, then you should have your subscription manager provide the proper base Red Hat repositories.

Startup the machine

I use Vagrant for this since it’s the quickest way to startup a machine for testing purposes.

Prepare ISO repo

  • Copy software to machine

    Use scp (or even better use the vagrant-scp plugin) to get both the Ansible Tower bundle and the OS copied onto the machine.

  • Prepare Repo

    Mount the ISO and create a repo file for it so we can access the packages.

    # RHEL - Create media folder for mount point
    mkdir /media/rhel7-server
    # RHEL - Mount the ISO
    mount -o loop rhel-server-7.5-x86_64-dvd.iso /media/rhel7-server
    # RHEL - Copy repo file from DVD media
    cp /media/rhel7-server/media.repo /etc/yum.repos.d/rhel7-server.repo
    # RHEL - Change permissions
    chmod +rw /etc/yum.repos.d/rhel7-server.repo
    # RHEL - Point repo to local mount point
    echo 'baseurl=file:///media/rhel7-server/' >> /etc/yum.repos.d/rhel7-server.repo
    # RHEL - Enable repository
    echo 'enabled=1' >> /etc/yum.repos.d/rhel7-server.repo
  • Test repo

    Verify the repo works correctly.

    yum repolist

Prepare Tower

  • Unpack the Ansible Tower bundle
    cd ~
    tar -xvf ansible-tower-setup-bundle-*.el7.tar.gz
  • Modify the Inventory (optional)

    We only need to set the passwords and nothing else! Set them to password because you will eventually package this folder and use it for future installs.

    cd ansible-tower-setup-bundle-*.el7
    vi inventory

Prepare tools

We need a couple packages to be able to download the rpms and create a repository so that Ansible Tower will be able to read from it.

# install yumdownloader tool
yum install yum-utils
# install createrepo tool
rpm install createrepo

Download packages

Now let us create the folder where the extra packages will be downloaded.

# navigate again inside the tower bundle folder
cd ~/ansible-tower-setup-bundle-*.el7
# create new repo folder inside the bundle repos folder
mkdir bundle/repos/others
cd bundle/repos/others

Now comes the fun part. Ansible Tower bundle comes with a bundle/base_packages.txt file within the bundle that lists the packages we need to download. However the list of packages include versions and makes it tricky to just download these packages using yumdownloader. We need to break the package name apart to extract the name. We will use this small Python script because it acually uses the rpmUtils library that will correctly understand the breakdown of the package naming and allow us to cleanly extract the names (some names are strange and make using regex not the best solution).

Save the following Python script. It basically takes a filename as argument and outputs the names of the packages. It will help us convert the base_packages.txt to something usable for yumdownloader.

Create a file named in the new others folder.

import sys
from rpmUtils.miscutils import splitFilename

if len(sys.argv)<2:
  print "No argument provided. Exiting."
with open(filename, 'r') as handle:
    for line in handle:
      (n, v, r, e, a) = splitFilename(line)
      print n

Now we just run it all and magically we will be downloading all the necessary packages into our others folder. The command passes the location of the base_packages.txt as the argument.

# download extra packages
yumdownloader $(python ../../base_packages.txt)

Finally, we need to make it an official repository with metadata. We will use the createrepo tool to accomplish this.

createrepo .

Add our new repository to the Ansible Tower repo template file.

cd ~/ansible-tower-setup-bundle-*.el7
cat << EOF >> ./roles/repos_el/templates/tower_bundle_el7.j2

baseurl=file://{{ bundle_install_folder }}/others

Re-package the bundle

That’s it! Now you can re-package your new bundle and bring it to your Data Center or wherever and simply install Ansible Tower in a completely offline situation.

Remember that this bundle will only work with the specific OS and version you used in this process! For any other OS version you will need to do this again.

# navigate to home folder
cd ~
# create tar ball of the new bundle
tar -czvf ansible-tower-bundle-offline.tar.gz ansible-tower-setup-bundle-*.el7

If you want to test the installation, just disable all of your repos before attempting the installation.

yum-config-manager --disable *

However, for a proper test, you should destroy your vagrant machine and recreate it and use only your new bundled package to install Tower.