# Attiva environment (una volta per sessione)
source env-dev.sh
# Ora usa tower-cli normalmente
tower-cli --version
tower-cli instance list
tower-cli instance health --instance 1Vantaggi:
- β Sintassi pulita come se fosse installato
- β Modifiche al codice immediatamente attive
- β Nessuna installazione necessaria
# Usa lo script diretto
./tower-cli-dev.sh --version
./tower-cli-dev.sh instance list
./tower-cli-dev.sh instance health --instance 1# Per comandi singoli
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. Naviga nella directory
cd /myData/git/pythonVENV/ansible-tower-cli-3.3.9
# 2. Attiva environment
source env-dev.sh
# Output: β
Tower CLI Development Environment attivato!
# 3. Verifica versione
tower-cli --version
# Output: Tower CLI 3.3.10
# 4. Configura connessione Tower (se necessario)
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. Testa comandi esistenti
tower-cli instance list
# 6. Testa nuovi comandi gateway
tower-cli instance list --node-type hop
tower-cli instance health --instance gateway-01
# 7. Modifica codice in tower_cli/...
vim tower_cli/resources/instance.py
# 8. Testa immediatamente (nessun reinstall!)
tower-cli instance list
# 9. Debug se necessario
tower-cli --verbose instance listansible-tower-cli-3.3.9/
βββ tower_cli/ # Codice sorgente (modifica qui)
β βββ resources/
β β βββ instance.py # β File modificato per gateway
β βββ constants.py # β Versione 3.3.10
β βββ ...
βββ env-dev.sh # β Script per environment
βββ tower-cli-dev.sh # β Script wrapper diretto
βββ GATEWAY_SUPPORT.md # Documentazione gateway
βββ CHANGELOG_3.3.10.md # Changelog modifiche
βββ README_IT.md # Quick start italiano
source env-dev.sh
# Verifica import
python -c "from tower_cli import __version__; print(__version__)"
# Output: 3.3.10
# Test help
tower-cli --help
# Test config
tower-cli config# Lista istanze
tower-cli instance list
# Filtra per tipo
tower-cli instance list --node-type execution
tower-cli instance list --node-type hop
tower-cli instance list --node-type hybrid
# Get specifico
tower-cli instance get --id 1
tower-cli instance get --hostname gateway-01# Health check (richiede Tower 3.6+)
tower-cli instance health --instance 1
tower-cli instance health --instance gateway-01 --format json
# Jobs running
tower-cli instance jobs --instance 1
tower-cli instance jobs --instance gateway-01tower-cli --verbose instance list# Esegui con debug Python
python -u -c "
import sys
sys.path.insert(0, '.')
from tower_cli.cli.run import cli
cli()
" instance list# Verifica import moduli
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])
"# Controlla se node_type Γ¨ nei campi
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)
"# Testa help dei comandi (non richiede connessione)
tower-cli instance --help
tower-cli instance list --help
tower-cli instance health --help
tower-cli instance jobs --help- Modifica il codice:
vim tower_cli/resources/instance.py
# Aggiungi:
# new_field = models.Field(required=False, display=True)- Testa IMMEDIATAMENTE (nessun reinstall):
tower-cli instance list- Verifica il campo:
python -c "
import sys; sys.path.insert(0, '.')
from tower_cli.resources.instance import Resource
print([f.name for f in Resource().fields])
"- Modifica instance.py:
@resources.command
def my_new_command(self, **kwargs):
"""My new command"""
return {"status": "ok"}- Testa:
tower-cli instance my-new-commandAggiungi al tuo ~/.bashrc:
alias tower-dev='source /myData/git/pythonVENV/ansible-tower-cli-3.3.9/env-dev.sh'Poi:
tower-dev # Attiva environment
tower-cli --version# Terminal 1: modifica codice
vim tower_cli/resources/instance.py
# Terminal 2: test automatico
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"- Documentazione:
GATEWAY_SUPPORT.md - Changelog:
CHANGELOG_3.3.10.md - Quick Start:
README_IT.md - API Docs:
docs/source/api_ref/
A: Assicurati di aver fatto source env-dev.sh nella sessione corrente.
A: Verifica il PYTHONPATH: echo $PYTHONPATH dovrebbe includere la directory corrente.
A:
unset PYTHONPATH
unalias tower-cli awx-cli
source env-dev.sh # RiattivaA: Sì, ogni directory ha il suo environment. Fai source env-dev.sh nella directory che vuoi usare.
-
source env-dev.sheseguito -
tower-cli --versionmostra3.3.10 - Connessione Tower configurata (se necessario)
- Modifiche al codice salvate
- Test comando eseguito
Versione: 3.3.10 Per sviluppo senza installazione