# Activate environment (once per session)
source env-dev.sh
# Now use tower-cli normally
tower-cli --version
tower-cli instance list
tower-cli instance health --instance 1Advantages:
- β Clean syntax as if installed
- β Code changes immediately active
- β No installation required
# Use direct script
./tower-cli-dev.sh --version
./tower-cli-dev.sh instance list
./tower-cli-dev.sh instance health --instance 1# For single commands
PYTHONPATH=. python -c "from tower_cli.cli.run import cli; cli()" --version
PYTHONPATH=. python -c "from tower_cli.cli.run import cli; cli()" instance list# 1. Navigate to directory
cd /myData/git/pythonVENV/ansible-tower-cli-3.3.9
# 2. Activate environment
source env-dev.sh
# Output: β
Tower CLI Development Environment activated!
# 3. Verify version
tower-cli --version
# Output: Tower CLI 3.3.10
# 4. Configure Tower connection (if needed)
tower-cli config host https://tower.example.com
tower-cli config username admin
tower-cli config password mypass
tower-cli config verify_ssl false
# 5. Test existing commands
tower-cli instance list
# 6. Test new gateway commands
tower-cli instance list --node-type hop
tower-cli instance health --instance gateway-01
# 7. Modify code in tower_cli/...
vim tower_cli/resources/instance.py
# 8. Test immediately (no reinstall!)
tower-cli instance list
# 9. Debug if needed
tower-cli --verbose instance listansible-tower-cli-3.3.9/
βββ tower_cli/ # Source code (modify here)
β βββ resources/
β β βββ instance.py # β Modified file for gateway
β βββ constants.py # β Version 3.3.10
β βββ ...
βββ env-dev.sh # β Script for environment
βββ tower-cli-dev.sh # β Direct wrapper script
βββ GATEWAY_SUPPORT_EN.md # Gateway documentation
βββ CHANGELOG_3.3.10_EN.md # Changes changelog
βββ README_EN.md # English quick start
source env-dev.sh
# Verify import
python -c "from tower_cli import __version__; print(__version__)"
# Output: 3.3.10
# Test help
tower-cli --help
# Test config
tower-cli config# List instances
tower-cli instance list
# Filter by type
tower-cli instance list --node-type execution
tower-cli instance list --node-type hop
tower-cli instance list --node-type hybrid
# Get specific
tower-cli instance get --id 1
tower-cli instance get --hostname gateway-01# Health check (requires Tower 3.6+)
tower-cli instance health --instance 1
tower-cli instance health --instance gateway-01 --format json
# Running jobs
tower-cli instance jobs --instance 1
tower-cli instance jobs --instance gateway-01tower-cli --verbose instance list# Run with Python debug
python -u -c "
import sys
sys.path.insert(0, '.')
from tower_cli.cli.run import cli
cli()
" instance list# Verify module imports
python -c "
import sys
sys.path.insert(0, '.')
from tower_cli.resources import instance
print('Instance resource:', instance.Resource)
print('Endpoint:', instance.Resource.endpoint)
print('Fields:', [f.name for f in instance.Resource.fields])
"# Check if node_type is in fields
python -c "
import sys
sys.path.insert(0, '.')
from tower_cli.resources.instance import Resource
r = Resource()
fields = [f.name for f in r.fields]
print('node_type in fields:', 'node_type' in fields)
print('All fields:', fields)
"# Test command help (doesn't require connection)
tower-cli instance --help
tower-cli instance list --help
tower-cli instance health --help
tower-cli instance jobs --help- Modify the code:
vim tower_cli/resources/instance.py
# Add:
# new_field = models.Field(required=False, display=True)- Test IMMEDIATELY (no reinstall):
tower-cli instance list- Verify the field:
python -c "
import sys; sys.path.insert(0, '.')
from tower_cli.resources.instance import Resource
print([f.name for f in Resource().fields])
"- Modify instance.py:
@resources.command
def my_new_command(self, **kwargs):
"""My new command"""
return {"status": "ok"}- Test:
tower-cli instance my-new-commandAdd to your ~/.bashrc:
alias tower-dev='source /myData/git/pythonVENV/ansible-tower-cli-3.3.9/env-dev.sh'Then:
tower-dev # Activate environment
tower-cli --version# Terminal 1: modify code
vim tower_cli/resources/instance.py
# Terminal 2: automatic test
watch -n 2 'PYTHONPATH=. python -c "from tower_cli.resources.instance import Resource; print([f.name for f in Resource().fields])"'#!/bin/bash
source env-dev.sh
tower-cli instance list --node-type hop || echo "No gateways found"
tower-cli instance health --instance 1 || echo "Health check failed"- Documentation:
GATEWAY_SUPPORT_EN.md - Changelog:
CHANGELOG_3.3.10_EN.md - Quick Start:
README_EN.md - API Docs:
docs/source/api_ref/
A: Make sure you've done source env-dev.sh in the current session.
A: Verify PYTHONPATH: echo $PYTHONPATH should include current directory.
A:
unset PYTHONPATH
unalias tower-cli awx-cli
source env-dev.sh # ReactivateA: Yes, each directory has its own environment. Do source env-dev.sh in the directory you want to use.
-
source env-dev.shexecuted -
tower-cli --versionshows3.3.10 - Tower connection configured (if needed)
- Code changes saved
- Test command executed
Version: 3.3.10 For development without installation Author: rUser75 Project: https://github.com/rUser75/tower-cli