Change default project base path in Ansible AWX/Tower

2 min read 07-10-2024
Change default project base path in Ansible AWX/Tower


Changing the Default Project Base Path in Ansible AWX/Tower

Problem:

When working with Ansible AWX/Tower, the default project base path can sometimes be inconvenient. You may want to store your projects in a different location, perhaps on a shared network drive, or within a specific directory structure. This article will guide you through changing this default base path.

Scenario & Original Code:

Let's say your default project base path is ~/awx_projects/, and you want to move it to /var/lib/awx/projects/. You can achieve this by modifying the AWX_PROJECT_BASE_PATH environment variable in your AWX/Tower configuration.

Original Code (Inside AWX Configuration File):

AWX_PROJECT_BASE_PATH=/home/awx/awx_projects/

Analysis & Solution:

  1. Understanding the Environment Variable: The AWX_PROJECT_BASE_PATH environment variable directly controls where Ansible AWX/Tower stores your projects. By modifying its value, you effectively relocate your project directory.

  2. Modifying the Configuration:

    • For AWX (Standalone):
      • Locate your AWX configuration file (usually awx.cfg in the /etc/awx/ directory).
      • Open the file for editing and find the line defining AWX_PROJECT_BASE_PATH.
      • Modify the value to reflect your desired location. In our example, this would be:
        AWX_PROJECT_BASE_PATH=/var/lib/awx/projects/
        
      • Save the changes and restart the AWX service:
        systemctl restart awx
        
    • For Tower:
      • The procedure for modifying Tower is largely the same as for AWX, but the configuration file might be in a different location. Refer to the Tower documentation for specific instructions.
  3. Directory Creation: Make sure the new project base path you specified exists. You'll likely need to create this directory manually:

    sudo mkdir -p /var/lib/awx/projects
    
  4. Permissions: Pay close attention to the permissions of the new directory. Ensure that the AWX/Tower user has appropriate read/write access.

  5. Additional Considerations:

    • Shared Storage: When using a shared storage location like a network drive, ensure proper mounting and permissions are configured.
    • Project Migration: If you have existing projects within the old default path, you might need to manually move them to the new location.

Additional Value:

  • Best Practices: For optimal security and manageability, it's generally recommended to use a dedicated directory for projects, like /var/lib/awx/projects/, instead of directly under the user's home directory.
  • Version Control: Consider integrating your project directory with a version control system like Git, to manage your Ansible playbooks and roles effectively.

References:

By following these steps, you can easily adjust the default project base path in Ansible AWX/Tower to meet your specific storage and organizational needs.