Ansible-galaxy role import results in internal server error

I’m currently trying (and failing) to update one of my roles in Galaxy:

❯ ansible-galaxy role import --token "${TOKEN}" --role-name uos.smb_backup virtuos smb_backup               
ERROR! None (HTTP Code: 500, Message: Internal Server Error)

The token should be valid and changing it will result in a 403 Forbidden:

❯ ansible-galaxy role import --token "123" --role-name uos.smb_backup virtuos smb_backup                                                                                                                                                      
ERROR! Error when finding available api versions from default (https://galaxy.ansible.com) (HTTP Code: 403, Message: Forbidden)

Not sure what I’m doing wrong. Given that it is an internal server error, it seems like the API is currently broken?

1 Like
#!/bin/bash

# Define variables
TOKEN="your_valid_token_here"
GITHUB_USER="virtuos"
GITHUB_REPO="smb_backup"
ROLE_NAME="uos.smb_backup"

# Function to import role
import_role() {
    # Attempt to import the role with the provided token
    echo "Attempting to import role $ROLE_NAME from $GITHUB_USER/$GITHUB_REPO..."
    ansible-galaxy role import --token "$TOKEN" --role-name "$ROLE_NAME" "$GITHUB_USER" "$GITHUB_REPO"
    
    # Check the exit status of the command
    if [ $? -eq 0 ]; then
        echo "Role import was successful."
    else
        echo "Role import failed."
    fi
}

# Function to test with an invalid token for comparison
test_invalid_token() {
    # Using an intentionally invalid token to check for Forbidden response
    INVALID_TOKEN="123"
    echo "Testing with invalid token to ensure proper authentication error..."
    ansible-galaxy role import --token "$INVALID_TOKEN" --role-name "$ROLE_NAME" "$GITHUB_USER" "$GITHUB_REPO"
    
    # Check for expected 403 Forbidden response
    if [ $? -ne 0 ]; then
        echo "Received expected authentication error."
    else
        echo "Unexpected success with invalid token."
    fi
}

# Main execution
echo "Starting role import procedure..."
import_role
echo "Now testing with an invalid token for comparison..."
test_invalid_token

echo "If you continue to see 'Internal Server Error', the issue might be on the server side. Here are some steps to take:"
echo "- Check if there are known issues with Galaxy API from the Ansible community or forums."
echo "- Ensure your network connection is stable."
echo "- Try importing at a different time or from a different network to rule out temporary issues."
echo "- Look into the role's meta/main.yml file for any syntax errors or issues with the role structure."
echo "- If possible, check server logs on Galaxy if you have access or contact support."

# Note: If you need to debug further, you might add verbose logging:
# ansible-galaxy role import --token "$TOKEN" --role-name "$ROLE_NAME" "$GITHUB_USER" "$GITHUB_REPO" -vvv