United Kingdom | How to change the database name for Ansible Tower (or AWX)

Sebastian Baszcyj - 25.05.202220220525

How to change the database name for Ansible Tower (or AWX)

United Kingdom | How to change the database name for Ansible Tower (or AWX)

1. Stop Ansible Tower daemons on all AT nodes: 

ansible-tower-service stop 

2. Use psql to connect to the DB: 

psql "host=dbname01.postgres.database.azure.com port=5432 dbname=postgres user=dbname01admin@dbname01 password=<your_pass> sslmode=require"

3. List available databases: 

postgres=> \l   List of databases   Name          |        Owner        | Encoding |          Collate           |           Ctype            |          Access privileges   -----------------------+---------------------+----------+----------------------------+----------------------------+-------------------------------------    awx                   | dbname01admin | UTF8     | en-US                      | en-US            

4. Rename the existing awx db to awx2 (postgres will not allow you to do any changes if there are any Ansible Tower daemons running and connecting to the database):  

postgres=> alter database awx rename to awx2; 

5. Confirm the db has been renamed: 

postgres=> \l            List of databases   Name          |        Owner        | Encoding |          Collate           |           Ctype            |          Access privileges   -----------------------+---------------------+----------+----------------------------+----------------------------+-------------------------------------    awx2                  | dbname01admin | UTF8     | en-us                      | en-us 

6. Create a new awx db if required (this step is required if you would like to use awx database as a target to restore from the postgresql dump):  

postgres=> CREATE DATABASE awx WITH TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE = 'en-US' LC_CTYPE = 'en-US'; 

7 . Update the /etc/tower/conf.d/postgres.py on all the nodes: 

FROM: 

# Ansible Tower database settings.      DATABASES = {      'default': {          'ATOMIC_REQUESTS': True,          'ENGINE': 'awx.main.db.profiled_pg',          'NAME': 'awx',          'USER': 'dbname01admin@dbname01',          'PASSWORD': """PASSWORD""",          'HOST': 'dbname01.postgres.database.azure.com',          'PORT': '5432',          'OPTIONS': { 'sslmode': 'prefer',                       'sslrootcert': '/etc/pki/tls/certs/ca-bundle.crt',          },      }   } 

TO: 

# Ansible Tower database settings.      DATABASES = {      'default': {          'ATOMIC_REQUESTS': True,          'ENGINE': 'awx.main.db.profiled_pg',          'NAME': 'awx2',          'USER': 'dbname01admin@dbname01',          'PASSWORD': """PASSWORD""",          'HOST': 'dbname01.postgres.database.azure.com',          'PORT': '5432',          'OPTIONS': { 'sslmode': 'prefer',                       'sslrootcert': '/etc/pki/tls/certs/ca-bundle.crt',          },      }   } 

8. Start the ansible tower on all nodes: 

ansible-tower-service start 

9. Verify the nodes: 

# awx-manage list_instances   [tower capacity=411]           node01 capacity=137 version=3.8.4 heartbeat="2021-11-19 02:39:07"           node02 capacity=137 version=3.8.4 heartbeat="2021-11-19 02:39:15"           node03 capacity=137 version=3.8.4 heartbeat="2021-11-19 02:38:57" 

THANK YOU FOR YOUR SUBMISSION!

United Kingdom | How to change the database name for Ansible Tower (or AWX)

The form was submitted successfully.

Join the Insentra Community with the Insentragram Newsletter

Hungry for more?

If you’re waiting for a sign, this is it.

We’re a certified amazing place to work, with an incredible team and fascinating projects – and we’re ready for you to join us! Go through our simple application process. Once you’re done, we will be in touch shortly!

Who is Insentra?

Imagine a business which exists to help IT Partners & Vendors grow and thrive.

Insentra is a 100% channel business. This means we provide a range of Advisory, Professional and Managed IT services exclusively for and through our Partners.

Our #PartnerObsessed business model achieves powerful results for our Partners and their Clients with our crew’s deep expertise and specialised knowledge.

We love what we do and are driven by a relentless determination to deliver exceptional service excellence.

United Kingdom | How to change the database name for Ansible Tower (or AWX)

Insentra ISO 27001:2013 Certification

SYDNEY, WEDNESDAY 20TH APRIL 2022 – We are proud to announce that Insentra has achieved the  ISO 27001 Certification.