Vai al contenuto

Vagrazione

Traduzione: Copia tutti i comandi Traduzione: Generare PDF < > Comandi e flussi di lavoro completi HashiCorp Vagrant per la gestione dell'ambiente di sviluppo e il provisioning di macchine virtuali. ## Installazione e configurazione | | Command | Description | | | --- | --- | | | `vagrant version` | Show Vagrant version | | | | `vagrant -h` | Show help information | | | | `vagrant init` | Initialize new Vagrantfile | | | | `vagrant init ubuntu/jammy64` | Initialize with specific box | | ## Gestione della scatola ### Operazioni di scatole | | Command | Description | | | --- | --- | | | `vagrant box list` | List installed boxes | | | | `vagrant box add ubuntu/jammy64` | Add box | | | | `vagrant box add --name mybox /path/to/box.box` | Add local box | | | | `vagrant box remove ubuntu/jammy64` | Remove box | | | | `vagrant box update` | Update all boxes | | | | `vagrant box update --box ubuntu/jammy64` | Update specific box | | ### Informazioni sulla scatola | | Command | Description | | | --- | --- | | | `vagrant box outdated` | Check for outdated boxes | | | | `vagrant box prune` | Remove old box versions | | | | `vagrant box repackage ubuntu/jammy64` | Repackage box | | ## VM Gestione del ciclo di vita ### Operazioni di base | | Command | Description | | | --- | --- | | | `vagrant up` | Start and provision VM | | | | `vagrant halt` | Shutdown VM | | | | `vagrant reload` | Restart VM | | | | `vagrant destroy` | Destroy VM | | | | `vagrant suspend` | Suspend VM | | | | `vagrant resume` | Resume suspended VM | | ### VM Status e informazioni | | Command | Description | | | --- | --- | | | `vagrant status` | Show VM status | | | | `vagrant global-status` | Show all VMs status | | | | `vagrant global-status --prune` | Clean up invalid entries | | ## SSH e accesso ### Operazioni SSH | | Command | Description | | | --- | --- | | | `vagrant ssh` | SSH into VM | | | | `vagrant ssh-config` | Show SSH configuration | | | | `vagrant ssh -- -L 8080:localhost:80` | SSH with port forwarding | | ## Disposizioni ### Disposizione dei Comandi | | Command | Description | | | --- | --- | | | `vagrant provision` | Run provisioners | | | | `vagrant provision --provision-with shell` | Run specific provisioner | | | | `vagrant up --provision` | Start and provision | | | | `vagrant reload --provision` | Restart and provision | | ## Ambiente multi-macchina ### Comandi multi-macchina | | Command | Description | | | --- | --- | | | `vagrant up web` | Start specific machine | | | | `vagrant ssh web` | SSH to specific machine | | | | `vagrant halt db` | Halt specific machine | | | | `vagrant destroy --force` | Destroy all without confirmation | | ## Istantanee ### Gestione snapshot | | Command | Description | | | --- | --- | | | `vagrant snapshot save snapshot_name` | Save snapshot | | | | `vagrant snapshot list` | List snapshots | | | | `vagrant snapshot restore snapshot_name` | Restore snapshot | | | | `vagrant snapshot delete snapshot_name` | Delete snapshot | | ## Gestione Plugin ### Operazioni Plugin | | Command | Description | | | --- | --- | | | `vagrant plugin list` | List installed plugins | | | | `vagrant plugin install vagrant-vbguest` | Install plugin | | | | `vagrant plugin uninstall vagrant-vbguest` | Uninstall plugin | | | | `vagrant plugin update` | Update all plugins | | ## Esempi di Vagrantfile ### Scheda di base Traduzione: ### Setup multi-macchina Traduzione: ### Configurazione avanzata Traduzione: ## Metodi di provisioning ### Fornitura di Shell Traduzione: ### Disposizione dei file Traduzione: ### Disposizioni ansible Traduzione: ### Docker provisioning Traduzione: ## Configurazione di rete ### Reti private Traduzione: ### Reti pubbliche Traduzione: ### Inoltro del porto Traduzione: ## Configurazione del fornitore ### VirtualBox Provider Traduzione: ### VMware Provider Traduzione: ### Provider Hyper-V # ## Cartelle sincronizzate ### Cartelle sincronizzate di base Traduzione: ### Cartelle sincronizzate NFS Traduzione: ### Cartelle sincronizzate SMB (Windows) Traduzione: ## Migliori Pratiche ### Ottimizzazione delle prestazioni 1. **Resource Allocation**: Allocate CPU e memoria appropriati 2. **Synced Folders**: Utilizzare NFS per migliorare le prestazioni su macOS/Linux 3. **Box Selection**: Scegli le caselle di base minime 4. **Snapshot Management**: Utilizzare snapshot per i rollback rapidi 5. **Provider Optimization**: Configurare ottimizzazioni specifiche del fornitore ### Sicurezza 1. # SSH Keys # Utilizzare i tasti SSH invece di password 2. ** Isolamento rete ** Utilizzare reti private quando possibile 3. **Firewall**: Configurare regole firewall appropriate 4. ** Aggiornamenti**: Tenere aggiornato le caselle e Vagrant 5. **Segreti**: Non commettere segreti al controllo delle versioni ### Flusso di lavoro 1. **Version Control**: Includere Vagrantfile nel controllo della versione 2. # Documentazione # Configurazione e utilizzo dei documenti 3. **Consistenza ** Utilizzare lo stesso ambiente in team 4. **Testing**: script di provisioning dei test 5. **Cleanup**: Pulisci regolarmente VM e scatole non utilizzate ### Risoluzione dei problemi 1. **Logs**: Controllare i registri di Vagrant e provider 2. **SSH**: Utilizzare `vagrant ssh-config`_ per il debug 3. **Regolamento ** Connettività della rete di test 4. **Provisioning**: Test script di provisioning separatamente 5. **Risorse**: Monitorare le risorse del sistema host