Skip to content

Commit be6824e

Browse files
xnotoclaude
andauthored
refactor!: remove AAP; add boot_disk_size; bundle opencode config (#2)
## Summary - **BREAKING:** Removes the Ansible Automation Platform (AAP) integration entirely (provider, all aap_* resources/data, and the dead `private_ip_addr` / `proxyhost` variables that only fed the AAP host block). Callers configuring VMs via Ansible should now drive it from outside this module (e.g. cloud-init). - Adds a new `boot_disk_size` variable that sets `libvirt_volume.boot.capacity` in bytes so callers can grow the boot disk beyond the source image's natural size — needed for Talos's small nocloud qcow2. - Bundles the previously-staged repo-local opencode config (the prior commit on this branch). ## Test plan - [x] Pre-commit hooks pass (terraform_validate, tflint, terraform_fmt, terraform_docs, end-of-file-fixer all green locally; checkov has soft-fail and runs in CI's container) - [x] CI `make test` passes - [x] Caller (`tfroot-libvirt`) plans cleanly after AAP arguments are removed and the new k3s/talos modules are wired up ## Migration notes Any caller passing the following arguments must drop them: `enable_aap`, `aap_org_name`, `aap_inventory_name`, `aap_job_template_name`, `private_ip_addr`, `proxyhost` --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 262e95e commit be6824e

6 files changed

Lines changed: 48 additions & 100 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ permissions:
1313
jobs:
1414
test:
1515
name: Pre-commit Tests
16-
runs-on: arc-dind
16+
runs-on: ubuntu-latest
1717
container:
18-
image: ghcr.io/makeitworkcloud/runner:latest
18+
image: ghcr.io/makeitworkcloud/tfroot-runner:latest
1919
steps:
2020
- name: Checkout
2121
uses: actions/checkout@v4

README.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,12 @@ module "vm" {
3131
| Name | Version |
3232
|------|---------|
3333
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
34-
| <a name="requirement_aap"></a> [aap](#requirement\_aap) | ~> 1.4.0 |
3534
| <a name="requirement_libvirt"></a> [libvirt](#requirement\_libvirt) | ~> 0.9.0 |
3635

3736
## Providers
3837

3938
| Name | Version |
4039
|------|---------|
41-
| <a name="provider_aap"></a> [aap](#provider\_aap) | ~> 1.4.0 |
4240
| <a name="provider_libvirt"></a> [libvirt](#provider\_libvirt) | ~> 0.9.0 |
4341

4442
## Modules
@@ -49,24 +47,17 @@ No modules.
4947

5048
| Name | Type |
5149
|------|------|
52-
| aap_host.host | resource |
53-
| aap_job.job | resource |
5450
| [libvirt_cloudinit_disk.commoninit](https://registry.terraform.io/providers/dmacvicar/libvirt/latest/docs/resources/cloudinit_disk) | resource |
5551
| [libvirt_domain.vm](https://registry.terraform.io/providers/dmacvicar/libvirt/latest/docs/resources/domain) | resource |
5652
| [libvirt_volume.boot](https://registry.terraform.io/providers/dmacvicar/libvirt/latest/docs/resources/volume) | resource |
5753
| [libvirt_volume.cloudinit](https://registry.terraform.io/providers/dmacvicar/libvirt/latest/docs/resources/volume) | resource |
5854
| [libvirt_volume.extra](https://registry.terraform.io/providers/dmacvicar/libvirt/latest/docs/resources/volume) | resource |
59-
| aap_inventory.inventory | data source |
60-
| aap_job_template.job_template | data source |
61-
| aap_organization.org | data source |
6255

6356
## Inputs
6457

6558
| Name | Description | Type | Default | Required |
6659
|------|-------------|------|---------|:--------:|
67-
| <a name="input_aap_inventory_name"></a> [aap\_inventory\_name](#input\_aap\_inventory\_name) | Name of the AAP inventory to use. | `string` | `"libvirt-infra"` | no |
68-
| <a name="input_aap_job_template_name"></a> [aap\_job\_template\_name](#input\_aap\_job\_template\_name) | Name of the AAP job template to run. If left empty, will default to configure\_<name> | `string` | `""` | no |
69-
| <a name="input_aap_org_name"></a> [aap\_org\_name](#input\_aap\_org\_name) | Name of the Ansible Automation Platform (AAP) organization. | `string` | `"Default"` | no |
60+
| <a name="input_boot_disk_size"></a> [boot\_disk\_size](#input\_boot\_disk\_size) | Boot disk virtual size in bytes. Null means use the source image's natural size. | `number` | `null` | no |
7061
| <a name="input_boot_image_url"></a> [boot\_image\_url](#input\_boot\_image\_url) | URL for the base QCOW2 image used as the boot disk. | `string` | `"https://download.fedoraproject.org/pub/fedora/linux/releases/43/Cloud/x86_64/images/Fedora-Cloud-Base-Generic-43-1.6.x86_64.qcow2"` | no |
7162
| <a name="input_bridge_name"></a> [bridge\_name](#input\_bridge\_name) | Name of the network bridge for the second network interface. | `string` | `"nm-bridge"` | no |
7263
| <a name="input_cloudinit_meta_data_template"></a> [cloudinit\_meta\_data\_template](#input\_cloudinit\_meta\_data\_template) | The template content for cloud-init meta-data configuration. | `string` | n/a | yes |
@@ -76,12 +67,9 @@ No modules.
7667
| <a name="input_cloudinit_user_data_template"></a> [cloudinit\_user\_data\_template](#input\_cloudinit\_user\_data\_template) | The template content for cloud-init user-data configuration. | `string` | n/a | yes |
7768
| <a name="input_cloudinit_user_data_vars"></a> [cloudinit\_user\_data\_vars](#input\_cloudinit\_user\_data\_vars) | Variable map for the cloud-init user-data template. Set to {} if not used. | `map(string)` | n/a | yes |
7869
| <a name="input_description"></a> [description](#input\_description) | Description for the libvirt domain (virtual machine). | `string` | `""` | no |
79-
| <a name="input_enable_aap"></a> [enable\_aap](#input\_enable\_aap) | Whether to provision Ansible Automation Platform (AAP) resources for this domain. | `bool` | `false` | no |
8070
| <a name="input_extra_volumes"></a> [extra\_volumes](#input\_extra\_volumes) | List of additional volumes to attach to the domain. Each object should contain:<br/> - name: Name of the volume.<br/> - size: Size of the volume in bytes.<br/>Example:<br/>[<br/> {<br/> name = "runner-var-lib-docker.qcow2"<br/> size = 107374182400<br/> }<br/>] | <pre>list(object({<br/> name = string<br/> size = number<br/> }))</pre> | `[]` | no |
8171
| <a name="input_memory"></a> [memory](#input\_memory) | Amount of memory (in MB) to assign to the domain. | `number` | `2048` | no |
8272
| <a name="input_name"></a> [name](#input\_name) | The name of the libvirt domain (virtual machine) and related resources. | `string` | n/a | yes |
83-
| <a name="input_private_ip_addr"></a> [private\_ip\_addr](#input\_private\_ip\_addr) | Private IP address to assign to the VM (used for network config and inventory). | `string` | n/a | yes |
84-
| <a name="input_proxyhost"></a> [proxyhost](#input\_proxyhost) | Proxy host for SSH connection, used in ansible\_ssh\_common\_args. | `string` | n/a | yes |
8573
| <a name="input_storage_pool"></a> [storage\_pool](#input\_storage\_pool) | Name of the libvirt storage pool where volumes will be created. | `string` | `"default"` | no |
8674
| <a name="input_vcpu"></a> [vcpu](#input\_vcpu) | Number of virtual CPUs to assign to the domain. | `number` | `1` | no |
8775

main.tf

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
resource "libvirt_volume" "boot" {
2-
name = "${var.name}-${substr(sha256(var.boot_image_url), 0, 8)}.qcow2"
3-
pool = var.storage_pool
2+
name = "${var.name}-${substr(sha256(var.boot_image_url), 0, 8)}.qcow2"
3+
pool = var.storage_pool
4+
capacity = var.boot_disk_size
45

56
target = {
67
format = {
@@ -165,48 +166,3 @@ resource "libvirt_domain" "vm" {
165166
]
166167
}
167168
}
168-
169-
data "aap_organization" "org" {
170-
count = var.enable_aap ? 1 : 0
171-
name = var.aap_org_name
172-
depends_on = [libvirt_domain.vm]
173-
}
174-
175-
data "aap_inventory" "inventory" {
176-
count = var.enable_aap ? 1 : 0
177-
name = var.aap_inventory_name
178-
organization_name = data.aap_organization.org[0].name
179-
depends_on = [data.aap_organization.org]
180-
}
181-
182-
resource "aap_host" "host" {
183-
count = var.enable_aap ? 1 : 0
184-
name = var.name
185-
description = var.description
186-
inventory_id = data.aap_inventory.inventory[0].id
187-
enabled = true
188-
variables = jsonencode({
189-
ansible_host = var.private_ip_addr
190-
ansible_ssh_common_args = "-o ProxyCommand=\"ssh -o StrictHostKeyChecking=no -W %h:%p ${var.proxyhost}\""
191-
})
192-
depends_on = [data.aap_inventory.inventory]
193-
}
194-
195-
data "aap_job_template" "job_template" {
196-
count = var.enable_aap ? 1 : 0
197-
name = var.aap_job_template_name != "" ? var.aap_job_template_name : "configure_${var.name}"
198-
organization_name = data.aap_organization.org[0].name
199-
depends_on = [data.aap_organization.org]
200-
}
201-
202-
resource "aap_job" "job" {
203-
count = var.enable_aap ? 1 : 0
204-
job_template_id = data.aap_job_template.job_template[0].id
205-
depends_on = [aap_host.host, data.aap_job_template.job_template]
206-
207-
lifecycle {
208-
replace_triggered_by = [
209-
libvirt_domain.vm
210-
]
211-
}
212-
}

opencode.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"$schema": "https://opencode.ai/config.json",
3+
"mcp": {
4+
"agent-hub": {"type": "local", "command": ["npx", "-y", "agent-hub-mcp@latest"], "enabled": true},
5+
"context-mode": {"type": "local", "command": ["context-mode"], "enabled": true},
6+
"context7": {"type": "remote", "url": "https://mcp.context7.com/mcp", "enabled": true},
7+
"github": {"type": "remote", "url": "https://api.githubcopilot.com/mcp/", "enabled": true, "headers": {"Authorization": "Bearer {env:GITHUB_TOKEN}"}},
8+
"opentofu-docs": {"type": "local", "command": ["npx", "-y", "@opentofu/opentofu-mcp-server"], "enabled": true},
9+
"opencode-docs": {"enabled": false},
10+
"aws-docs": {"enabled": false},
11+
"kubernetes": {"enabled": false},
12+
"tmux": {"enabled": false},
13+
"linear": {"enabled": false},
14+
"notion": {"enabled": false},
15+
"aws-api-staging": {"enabled": false},
16+
"aws-api-prod": {"enabled": false},
17+
"grafana": {"enabled": false},
18+
"terraform-docs": {"enabled": false},
19+
"argocd-staging-eks": {"enabled": false},
20+
"argocd-prod-eks": {"enabled": false}
21+
},
22+
"tools": {
23+
"opencode-docs_*": false,
24+
"aws-docs_*": false,
25+
"kubernetes_*": false,
26+
"tmux_*": false,
27+
"linear_*": false,
28+
"notion_*": false,
29+
"aws-api-staging_*": false,
30+
"aws-api-prod_*": false,
31+
"grafana_*": false,
32+
"terraform-docs_*": false,
33+
"argocd-staging-eks_*": false,
34+
"argocd-prod-eks_*": false
35+
}
36+
}

providers.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,5 @@ terraform {
66
source = "dmacvicar/libvirt"
77
version = "~> 0.9.0"
88
}
9-
aap = {
10-
source = "registry.terraform.io/ansible/aap"
11-
version = "~> 1.4.0"
12-
}
139
}
1410
}

vars.tf

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ variable "boot_image_url" {
3333
default = "https://download.fedoraproject.org/pub/fedora/linux/releases/43/Cloud/x86_64/images/Fedora-Cloud-Base-Generic-43-1.6.x86_64.qcow2"
3434
}
3535

36+
variable "boot_disk_size" {
37+
description = "Boot disk virtual size in bytes. Null means use the source image's natural size."
38+
type = number
39+
default = null
40+
}
41+
3642
variable "extra_volumes" {
3743
description = <<EOF
3844
List of additional volumes to attach to the domain. Each object should contain:
@@ -88,37 +94,3 @@ variable "cloudinit_network_config_vars" {
8894
description = "Variable map for the cloud-init network configuration template."
8995
type = map(string)
9096
}
91-
92-
variable "private_ip_addr" {
93-
description = "Private IP address to assign to the VM (used for network config and inventory)."
94-
type = string
95-
}
96-
97-
variable "proxyhost" {
98-
description = "Proxy host for SSH connection, used in ansible_ssh_common_args."
99-
type = string
100-
}
101-
102-
variable "enable_aap" {
103-
description = "Whether to provision Ansible Automation Platform (AAP) resources for this domain."
104-
type = bool
105-
default = false
106-
}
107-
108-
variable "aap_org_name" {
109-
description = "Name of the Ansible Automation Platform (AAP) organization."
110-
type = string
111-
default = "Default"
112-
}
113-
114-
variable "aap_inventory_name" {
115-
description = "Name of the AAP inventory to use."
116-
type = string
117-
default = "libvirt-infra"
118-
}
119-
120-
variable "aap_job_template_name" {
121-
description = "Name of the AAP job template to run. If left empty, will default to configure_<name>"
122-
type = string
123-
default = ""
124-
}

0 commit comments

Comments
 (0)