# Migrating Ansible Tower to RHEL8

This post is part of a series

## Summary

This is the second sever (that I run in my home lab) that I have migrated to RHEL8. At the time of writing, RHEL8 has been out for almost a year (released on May 7th, 2019) and indeed we are on RHEL8.1 as I write this.

The good news is that migrating Ansible Tower was also really, really simple

### Overview

• make a backup of the Ansible Tower
• install a fresh RHEL8 VM and install ansible
• copy the backup tar.gz over
• fresh install (./setup)
• restore the backup (./setup -r)

### Details

It really is that simple, note however, you really should be restoring to the same version as you backed up from - you can do any other upgrades after you have done your restore. If you are following my steps then you will be anyway

So first of all install a new RHEL8 VM, make sure its updated and you have ansible installed

Now on the original Tower VM (the RHEL7 one) find the location where you did the install from - it will look something like this

[root@rhel7-tower ~]# ll /root
total 581764
drwxr-xr-x. 5 root root      4096 Mar 16 07:46 ansible-tower-setup-3.6.2-1


Change into that directory take a look, mine looked like this

[root@rhel7-tower ansible-tower-setup-3.6.2-1]# ll
total 577948
-rw-r--r--.  1 root root      2526 Dec 13 23:21 README.md
-rw-r--r--.  1 root root       562 Dec 13 23:21 backup.yml
drwxr-xr-x.  2 root root        17 Dec 13 23:21 group_vars
-rw-r--r--.  1 root root      7410 Dec 13 23:21 install.yml
-rw-r--r--.  1 root root      1140 Jan  2 10:04 inventoryNow o
drwxr-xr-x.  3 root root      8192 Dec 13 23:21 licenses
-rw-r--r--.  1 root root      1335 Dec 13 23:21 rekey.yml
-rw-r--r--.  1 root root      1393 Dec 13 23:21 restore.yml
drwxr-xr-x. 20 root root      4096 Dec 13 23:21 roles
-rwxr-xr-x.  1 root root     11405 Dec 13 23:21 setup.sh
-rw-------.  1 root root 150610741 Feb  8 14:59 tower-backup-2020-02-08-15:56:41.tar.gz
lrwxrwxrwx.  1 root root        73 Feb  8 07:46 tower-backup-latest.tar.gz -> /root/ansible-tower-setup-3.6.2-1/tower-backup-2020-02-08-15:56:41.tar.gz


You can see that these is a backup but at the time of writing its over a month old. So lets do a fresh backup

[root@rhel7-tower ansible-tower-setup-3.6.2-1]# ./setup -b
Using /etc/ansible/ansible.cfg as config file

PLAY [localhost] **************************************************************************************************************

ok: [localhost]

TASK [Determine the timestamp for the backup one for all nodes] ***************************************************************
ok: [localhost] => {"ansible_facts": {"now": "2020-03-16-07:44:39"}, "changed": false}

...

PLAY RECAP ********************************************************************************************************************
localhost                  : ok=51   changed=35   unreachable=0    failed=0    skipped=19   rescued=0    ignored=0

The setup process completed successfully.
Setup log saved to /var/log/tower/setup-2020-03-16-07:44:35.log


OK so we have a fresh backup and the latest symlink is updated

[root@rhel7-tower ansible-tower-setup-3.6.2-1]# ll
total 577948
-rw-r--r--.  1 root root      2526 Dec 13 23:21 README.md
-rw-r--r--.  1 root root       562 Dec 13 23:21 backup.yml
drwxr-xr-x.  2 root root        17 Dec 13 23:21 group_vars
-rw-r--r--.  1 root root      7410 Dec 13 23:21 install.yml
-rw-r--r--.  1 root root      1140 Jan  2 10:04 inventoryNow o
drwxr-xr-x.  3 root root      8192 Dec 13 23:21 licenses
-rw-r--r--.  1 root root      1335 Dec 13 23:21 rekey.yml
-rw-r--r--.  1 root root      1393 Dec 13 23:21 restore.yml
drwxr-xr-x. 20 root root      4096 Dec 13 23:21 roles
-rwxr-xr-x.  1 root root     11405 Dec 13 23:21 setup.sh
-rw-------.  1 root root 150610741 Feb  8 14:59 tower-backup-2020-02-08-15:56:41.tar.gz
-rw-------.  1 root root 134763962 Mar 16 07:46 tower-backup-2020-03-16-07:44:39.tar.gz
lrwxrwxrwx.  1 root root        73 Mar 16 07:46 tower-backup-latest.tar.gz -> /root/ansible-tower-setup-3.6.2-1/tower-backup-2020-03-16-07:44:39.tar.gz


So lets get this zipped up and transered to our new RHEL8 VM

[root@rhel7-tower ~]# cd ..

[root@rhel7-tower ~]# tar -czvf /tmp/tower-backup.tar.gz ansible-tower-setup-3.6.2-1/

[root@rhel7-tower ~]# scp /tmp/tower-backup.tar.gz 10.10.10.164:.


Now log on to the newe RHEL8 VM (in my case its at 10.10.10.164) and install ansible

root@new-rhel8-tower ~]# yum install -y ansible


Verify we see the backup zip file, extract it and cd into the directory

[root@new-rhel8-tower ~]# ll
total 581760
-rw-r--r--. 1 root root 595721778 Mar 16 07:51 tower-backup.tar.gz

[root@new-rhel8-tower ~]# tar xf tower-backup.tar.gz

[root@new-rhel8-tower ~]# ll
total 581764
drwxr-xr-x. 5 root root      4096 Mar 16 07:46 ansible-tower-setup-3.6.2-1
-rw-r--r--. 1 root root 595721778 Mar 16 07:51 tower-backup.tar.gz

[root@new-rhel8-tower ~]# cd ansible-tower-setup-3.6.2-1


As you can see, everything looks good, even the symlink

[root@new-rhel8-tower ansible-tower-setup-3.6.2-1]# ll
total 577948
-rw-r--r--.  1 root root      2526 Dec 13 23:21 README.md
-rw-r--r--.  1 root root       562 Dec 13 23:21 backup.yml
drwxr-xr-x.  2 root root        17 Dec 13 23:21 group_vars
-rw-r--r--.  1 root root      7410 Dec 13 23:21 install.yml
-rw-r--r--.  1 root root      1140 Jan  2 10:04 inventory
drwxr-xr-x.  3 root root      8192 Dec 13 23:21 licenses
-rw-r--r--.  1 root root      1335 Dec 13 23:21 rekey.yml
-rw-r--r--.  1 root root      1393 Dec 13 23:21 restore.yml
drwxr-xr-x. 20 root root      4096 Dec 13 23:21 roles
-rwxr-xr-x.  1 root root     11405 Dec 13 23:21 setup.sh
-rw-------.  1 root root 150610741 Feb  8 14:59 tower-backup-2020-02-08-15:56:41.tar.gz
-rw-------.  1 root root 134763962 Mar 16 07:46 tower-backup-2020-03-16-07:44:39.tar.gz
lrwxrwxrwx.  1 root root        73 Mar 16 07:46 tower-backup-latest.tar.gz -> /root/ansible-tower-setup-3.6.2-1/tower-backup-2020-03-16-07:44:39.tar.gz


Before we can restore, we will need to do an installation - its very simple and will use the inventory that is present in the backup

[root@new-rhel8-tower ansible-tower-setup-3.6.2-1]# ./setup


OK, so now the installation has finished and firewall ports are opened etc, lets do the final step and restore the backup

[root@new-rhel8-tower ansible-tower-setup-3.6.2-1]# ./setup -r


And thats it !! You may need to restart the services but then you will be able to log in and test that everything is working as expected

Once you are happy with that, you may optionally want to change the hostname & IP of the new VM or change the DNS record to point to the new server

I was really pleased with how simple this process was

Hope you found this usful, OSG