diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 57bdd31..8106a89 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,9 +13,9 @@ permissions: jobs: test: name: Pre-commit Tests - runs-on: arc-dind + runs-on: ubuntu-latest container: - image: ghcr.io/makeitworkcloud/runner:latest + image: ghcr.io/makeitworkcloud/tfroot-runner:latest steps: - name: Checkout uses: actions/checkout@v4 diff --git a/README.md b/README.md index f4def20..319a080 100644 --- a/README.md +++ b/README.md @@ -31,14 +31,12 @@ module "vm" { | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 1.3 | -| [aap](#requirement\_aap) | ~> 1.4.0 | | [libvirt](#requirement\_libvirt) | ~> 0.9.0 | ## Providers | Name | Version | |------|---------| -| [aap](#provider\_aap) | ~> 1.4.0 | | [libvirt](#provider\_libvirt) | ~> 0.9.0 | ## Modules @@ -49,24 +47,17 @@ No modules. | Name | Type | |------|------| -| aap_host.host | resource | -| aap_job.job | resource | | [libvirt_cloudinit_disk.commoninit](https://registry.terraform.io/providers/dmacvicar/libvirt/latest/docs/resources/cloudinit_disk) | resource | | [libvirt_domain.vm](https://registry.terraform.io/providers/dmacvicar/libvirt/latest/docs/resources/domain) | resource | | [libvirt_volume.boot](https://registry.terraform.io/providers/dmacvicar/libvirt/latest/docs/resources/volume) | resource | | [libvirt_volume.cloudinit](https://registry.terraform.io/providers/dmacvicar/libvirt/latest/docs/resources/volume) | resource | | [libvirt_volume.extra](https://registry.terraform.io/providers/dmacvicar/libvirt/latest/docs/resources/volume) | resource | -| aap_inventory.inventory | data source | -| aap_job_template.job_template | data source | -| aap_organization.org | data source | ## Inputs | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| [aap\_inventory\_name](#input\_aap\_inventory\_name) | Name of the AAP inventory to use. | `string` | `"libvirt-infra"` | no | -| [aap\_job\_template\_name](#input\_aap\_job\_template\_name) | Name of the AAP job template to run. If left empty, will default to configure\_ | `string` | `""` | no | -| [aap\_org\_name](#input\_aap\_org\_name) | Name of the Ansible Automation Platform (AAP) organization. | `string` | `"Default"` | no | +| [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 | | [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 | | [bridge\_name](#input\_bridge\_name) | Name of the network bridge for the second network interface. | `string` | `"nm-bridge"` | no | | [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. | [cloudinit\_user\_data\_template](#input\_cloudinit\_user\_data\_template) | The template content for cloud-init user-data configuration. | `string` | n/a | yes | | [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 | | [description](#input\_description) | Description for the libvirt domain (virtual machine). | `string` | `""` | no | -| [enable\_aap](#input\_enable\_aap) | Whether to provision Ansible Automation Platform (AAP) resources for this domain. | `bool` | `false` | no | | [extra\_volumes](#input\_extra\_volumes) | List of additional volumes to attach to the domain. Each object should contain:
- name: Name of the volume.
- size: Size of the volume in bytes.
Example:
[
{
name = "runner-var-lib-docker.qcow2"
size = 107374182400
}
] |
list(object({
name = string
size = number
}))
| `[]` | no | | [memory](#input\_memory) | Amount of memory (in MB) to assign to the domain. | `number` | `2048` | no | | [name](#input\_name) | The name of the libvirt domain (virtual machine) and related resources. | `string` | n/a | yes | -| [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 | -| [proxyhost](#input\_proxyhost) | Proxy host for SSH connection, used in ansible\_ssh\_common\_args. | `string` | n/a | yes | | [storage\_pool](#input\_storage\_pool) | Name of the libvirt storage pool where volumes will be created. | `string` | `"default"` | no | | [vcpu](#input\_vcpu) | Number of virtual CPUs to assign to the domain. | `number` | `1` | no | diff --git a/main.tf b/main.tf index 6504011..36139ac 100644 --- a/main.tf +++ b/main.tf @@ -1,6 +1,7 @@ resource "libvirt_volume" "boot" { - name = "${var.name}-${substr(sha256(var.boot_image_url), 0, 8)}.qcow2" - pool = var.storage_pool + name = "${var.name}-${substr(sha256(var.boot_image_url), 0, 8)}.qcow2" + pool = var.storage_pool + capacity = var.boot_disk_size target = { format = { @@ -165,48 +166,3 @@ resource "libvirt_domain" "vm" { ] } } - -data "aap_organization" "org" { - count = var.enable_aap ? 1 : 0 - name = var.aap_org_name - depends_on = [libvirt_domain.vm] -} - -data "aap_inventory" "inventory" { - count = var.enable_aap ? 1 : 0 - name = var.aap_inventory_name - organization_name = data.aap_organization.org[0].name - depends_on = [data.aap_organization.org] -} - -resource "aap_host" "host" { - count = var.enable_aap ? 1 : 0 - name = var.name - description = var.description - inventory_id = data.aap_inventory.inventory[0].id - enabled = true - variables = jsonencode({ - ansible_host = var.private_ip_addr - ansible_ssh_common_args = "-o ProxyCommand=\"ssh -o StrictHostKeyChecking=no -W %h:%p ${var.proxyhost}\"" - }) - depends_on = [data.aap_inventory.inventory] -} - -data "aap_job_template" "job_template" { - count = var.enable_aap ? 1 : 0 - name = var.aap_job_template_name != "" ? var.aap_job_template_name : "configure_${var.name}" - organization_name = data.aap_organization.org[0].name - depends_on = [data.aap_organization.org] -} - -resource "aap_job" "job" { - count = var.enable_aap ? 1 : 0 - job_template_id = data.aap_job_template.job_template[0].id - depends_on = [aap_host.host, data.aap_job_template.job_template] - - lifecycle { - replace_triggered_by = [ - libvirt_domain.vm - ] - } -} diff --git a/opencode.json b/opencode.json new file mode 100644 index 0000000..01ecf42 --- /dev/null +++ b/opencode.json @@ -0,0 +1,36 @@ +{ + "$schema": "https://opencode.ai/config.json", + "mcp": { + "agent-hub": {"type": "local", "command": ["npx", "-y", "agent-hub-mcp@latest"], "enabled": true}, + "context-mode": {"type": "local", "command": ["context-mode"], "enabled": true}, + "context7": {"type": "remote", "url": "https://mcp.context7.com/mcp", "enabled": true}, + "github": {"type": "remote", "url": "https://api.githubcopilot.com/mcp/", "enabled": true, "headers": {"Authorization": "Bearer {env:GITHUB_TOKEN}"}}, + "opentofu-docs": {"type": "local", "command": ["npx", "-y", "@opentofu/opentofu-mcp-server"], "enabled": true}, + "opencode-docs": {"enabled": false}, + "aws-docs": {"enabled": false}, + "kubernetes": {"enabled": false}, + "tmux": {"enabled": false}, + "linear": {"enabled": false}, + "notion": {"enabled": false}, + "aws-api-staging": {"enabled": false}, + "aws-api-prod": {"enabled": false}, + "grafana": {"enabled": false}, + "terraform-docs": {"enabled": false}, + "argocd-staging-eks": {"enabled": false}, + "argocd-prod-eks": {"enabled": false} + }, + "tools": { + "opencode-docs_*": false, + "aws-docs_*": false, + "kubernetes_*": false, + "tmux_*": false, + "linear_*": false, + "notion_*": false, + "aws-api-staging_*": false, + "aws-api-prod_*": false, + "grafana_*": false, + "terraform-docs_*": false, + "argocd-staging-eks_*": false, + "argocd-prod-eks_*": false + } +} diff --git a/providers.tf b/providers.tf index df82cbf..422c625 100644 --- a/providers.tf +++ b/providers.tf @@ -6,9 +6,5 @@ terraform { source = "dmacvicar/libvirt" version = "~> 0.9.0" } - aap = { - source = "registry.terraform.io/ansible/aap" - version = "~> 1.4.0" - } } } diff --git a/vars.tf b/vars.tf index 7a8744a..2ca3476 100644 --- a/vars.tf +++ b/vars.tf @@ -33,6 +33,12 @@ variable "boot_image_url" { default = "https://download.fedoraproject.org/pub/fedora/linux/releases/43/Cloud/x86_64/images/Fedora-Cloud-Base-Generic-43-1.6.x86_64.qcow2" } +variable "boot_disk_size" { + description = "Boot disk virtual size in bytes. Null means use the source image's natural size." + type = number + default = null +} + variable "extra_volumes" { description = <