docs: document terraform import for incus containers and remove korax
Add comprehensive terraform import documentation for Incus resources. Includes syntax for importing containers with for_each keys, retrieving image fingerprints, and specific import commands for Uranian hosts. Covers troubleshooting for common import issues and state verification. Removes obsolete korax.helu.ca host from ansible inventory.
This commit is contained in:
@@ -303,6 +303,82 @@ ansible-playbook sandbox_down.yml
|
||||
3. **Apply** — Provision with `terraform apply`
|
||||
4. **Verify** — Check outputs and container status
|
||||
|
||||
### Terraform Import
|
||||
|
||||
When containers or other resources are created manually (outside Terraform) or need to be re-imported after recreation, use `terraform import` to sync the Terraform state with existing infrastructure.
|
||||
|
||||
#### Import Syntax
|
||||
|
||||
The correct import format for Incus resources requires quoting resource addresses with `for_each` keys and using the full ID including image fingerprints:
|
||||
|
||||
```bash
|
||||
# Import a container with correct syntax
|
||||
terraform import 'incus_instance.uranian_hosts["<name>"]' ouranos/<name>,image=<fingerprint>
|
||||
```
|
||||
|
||||
#### Getting Image Fingerprints
|
||||
|
||||
First, get the fingerprint of the image resource from Terraform state:
|
||||
|
||||
```bash
|
||||
cd terraform
|
||||
terraform state show incus_image.noble | grep fingerprint
|
||||
# Output: fingerprint = "75cde3e755b0e657c05f67e03a42683217b233b0339448be747845747df58644"
|
||||
|
||||
terraform state show incus_image.questing | grep fingerprint
|
||||
# Output: fingerprint = "e78dd4a406b7fa3592ed0a6048862260b3d2e50c76e32a6169930245c0a13fdf"
|
||||
```
|
||||
|
||||
#### Importing All Uranian Hosts
|
||||
|
||||
Replace containers missing from state (or re-import after manual recreation):
|
||||
|
||||
```bash
|
||||
# Containers using noble image
|
||||
terraform import 'incus_instance.uranian_hosts["ariel"]' ouranos/ariel,image=75cde3e755b0e657c05f67e03a42683217b233b0339448be747845747df58644
|
||||
terraform import 'incus_instance.uranian_hosts["miranda"]' ouranos/miranda,image=75cde3e755b0e657c05f67e03a42683217b233b0339448be747845747df58644
|
||||
terraform import 'incus_instance.uranian_hosts["oberon"]' ouranos/oberon,image=75cde3e755b0e657c05f67e03a42683217b233b0339448be747845747df58644
|
||||
terraform import 'incus_instance.uranian_hosts["portia"]' ouranos/portia,image=75cde3e755b0e657c05f67e03a42683217b233b0339448be747845747df58644
|
||||
terraform import 'incus_instance.uranian_hosts["prospero"]' ouranos/prospero,image=75cde3e755b0e657c05f67e03a42683217b233b0339448be747845747df58644
|
||||
terraform import 'incus_instance.uranian_hosts["rosalind"]' ouranos/rosalind,image=75cde3e755b0e657c05f67e03a42683217b233b0339448be747845747df58644
|
||||
terraform import 'incus_instance.uranian_hosts["sycorax"]' ouranos/sycorax,image=75cde3e755b0e657c05f67e03a42683217b233b0339448be747845747df58644
|
||||
terraform import 'incus_instance.uranian_hosts["titania"]' ouranos/titania,image=75cde3e755b0e657c05f67e03a42683217b233b0339448be747845747df58644
|
||||
|
||||
# Containers using questing image
|
||||
terraform import 'incus_instance.uranian_hosts["caliban"]' ouranos/caliban,image=e78dd4a406b7fa3592ed0a6048862260b3d2e50c76e32a6169930245c0a13fdf
|
||||
terraform import 'incus_instance.uranian_hosts["puck"]' ouranos/puck,image=e78dd4a406b7fa3592ed0a6048862260b3d2e50c76e32a6169930245c0a13fdf
|
||||
```
|
||||
|
||||
#### Storage Bucket Import
|
||||
|
||||
For storage buckets, use the `<project>/<pool>/<name>` format:
|
||||
|
||||
```bash
|
||||
terraform import incus_storage_bucket.<name> ouranos/default/<bucket-name>
|
||||
```
|
||||
|
||||
#### Common Issues
|
||||
|
||||
1. **Import ID format errors**: Use quotes around resource addresses with `for_each` keys: `'incus_instance.uranian_hosts["name"]'`
|
||||
|
||||
2. **Image replacement on import**: Importing without specifying the image fingerprint will cause Terraform to replace the container on next apply. Always include `image=<fingerprint>` in the import ID.
|
||||
|
||||
3. **Tainted state**: If a resource shows "will be created" but already exists, it may be tainted. Remove from state and re-import:
|
||||
```bash
|
||||
terraform state rm 'incus_instance.uranian_hosts["name"]'
|
||||
terraform import 'incus_instance.uranian_hosts["name"]' ouranos/name,image=<fingerprint>
|
||||
```
|
||||
|
||||
#### Verify Import
|
||||
|
||||
After importing, verify with `terraform plan`:
|
||||
|
||||
```bash
|
||||
terraform plan
|
||||
# Should show: Plan: 0 to add, 0 to change, 0 to destroy
|
||||
# (Minor "update in-place" changes are normal for state sync of computed attributes)
|
||||
```
|
||||
|
||||
### Ansible Workflow
|
||||
|
||||
1. **Bootstrap** — Update packages, install essentials (`apt_update.yml`)
|
||||
|
||||
Reference in New Issue
Block a user