Skip to content

Commit 859b002

Browse files
xnotoclaude
andcommitted
refactor!: remove AAP integration; add boot_disk_size
The Ansible Automation Platform integration (aap_organization, aap_inventory, aap_host, aap_job_template, aap_job) is removed along with its provider declaration. The companion variables (enable_aap, aap_org_name, aap_inventory_name, aap_job_template_name) are dropped, as are the now-orphaned private_ip_addr and proxyhost variables which were only consumed by the AAP host block. Adds a new boot_disk_size variable that sets the libvirt_volume.boot capacity in bytes, allowing callers to grow the boot disk beyond the source image's natural size (useful for Talos nocloud images that ship small). BREAKING CHANGE: Callers passing enable_aap, aap_*, private_ip_addr, or proxyhost arguments must remove them. Hosts requiring Ansible configuration should drive it from outside this module. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 21a8e1e commit 859b002

4 files changed

Lines changed: 15 additions & 103 deletions

File tree

README.md

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,14 @@ module "vm" {
2929
## Requirements
3030

3131
| Name | Version |
32-
|------|---------|
32+
| ---- | ------- |
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 |
40-
|------|---------|
41-
| <a name="provider_aap"></a> [aap](#provider\_aap) | ~> 1.4.0 |
39+
| ---- | ------- |
4240
| <a name="provider_libvirt"></a> [libvirt](#provider\_libvirt) | ~> 0.9.0 |
4341

4442
## Modules
@@ -48,25 +46,18 @@ No modules.
4846
## Resources
4947

5048
| Name | Type |
51-
|------|------|
52-
| aap_host.host | resource |
53-
| aap_job.job | resource |
49+
| ---- | ---- |
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 |
66-
|------|-------------|------|---------|:--------:|
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 |
59+
| ---- | ----------- | ---- | ------- | :------: |
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,19 +67,16 @@ 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

8876
## Outputs
8977

9078
| Name | Description |
91-
|------|-------------|
79+
| ---- | ----------- |
9280
| <a name="output_boot_volume_id"></a> [boot\_volume\_id](#output\_boot\_volume\_id) | The ID of the boot volume |
9381
| <a name="output_cloudinit_disk_id"></a> [cloudinit\_disk\_id](#output\_cloudinit\_disk\_id) | The ID of the cloud-init disk |
9482
| <a name="output_domain_id"></a> [domain\_id](#output\_domain\_id) | The ID of the libvirt domain |

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-
}

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)