Antsle Forum

Welcome to our Antsle community! This forum is to connect all Antsle users to post experiences, make user-generated content available for the entire community and more. 

Please note: This forum is about discussing one specific issue at a time. No generalizations. No judgments. Please check the Forum Rules before posting. If you have specific questions about your Antsle and expect a response from our team directly, please continue to use the appropriate channels (email: [email protected]) so every inquiry is tracked. 

Please or Register to create posts and topics.

Using the Terraform Provider Antlets and VNICs resources

Page 1 of 2Next

Does anyone has a working Terraform configuration that creates an Antlet and attaches an additional vNIC to it ?

If so, would you share an example of that please ?

TIA

This could be related to this:

https://antsleone.lan/api/antlets/{antlet-name}/vnics

... which comes from the Antman swagger definition block.

"/api/antlets/{antlet-name}/vnics": {

"get": { <snip> },
"post": {
"tags": [
"vnics"
],
"summary": "Creates a vnic (virtual network interface controller) for the given antlet",
"description": "The mac-address will be computed. For type, use 'bridge'; and for model choose 'virtio' or 'e1000'",
"operationId": "create-vnic",
"parameters": [
{
"in": "path",
"name": "antlet-name",
"description": "",
"required": true,
"type": "string"
},
{
"in": "body",
"name": "VNic",
"description": "",
"required": true,
"schema": {
"$ref": "#/definitions/VNic"
}
}
],
"responses": {
"200": {
"schema": {
"$ref": "#/definitions/VNic"
},
"description": ""
},
<SNIP>

Wonder if the swagger file is not quite right and admitting I don't understand the Terraform OpenAPI provider setup that much either.  Should "antlet-name" actually be "dname" ?  I say this as once an Antlet is setup, "antlet-name" doesn't exist in a swagger-ui output from a GET /api/antlets call.  "dname" does exist.   I say this assuming the Terraform Antsle provider is doing value interpolation within the "/api/antlets/{antlet-name}/vnics" API string from swagger.

Is this remotely close ?

Theoretically it should be along the lines of this :

resource "antsle_vnics" "antlet_vnic"{
model = "VirtIO"
source = "br0"
type = "bridge"
}

When i run Terraform apply i receive :

expected a response body but response body received was empty for request = 'POST https://myserver.antsle.us/api/antlets/%7Bantlet-name%7D/vnics HTTP/1.1'. Response = '404 Not Found'

on instance.tf line 13, in resource "antsle_vnics" "antlet_vnic":
13: resource "antsle_vnics" "antlet_vnic"{

 

Upon diging into the Terraform apply logs  {$env:TF_LOG_PATH="Terraform.txt"} and searching this file i find a line :

2020-08-27T20:04:04.494-0500 [DEBUG] plugin.terraform-provider-antsle.exe: 2020/08/27 20:04:04 [DEBUG] resource path '/api/antlets/{antlet-name}/vnics' not terraform compliant: path '/api/antlets/{antlet-name}/vnics' is not a resource instance path

This sadly tells me ALOT of the Swagger.json apis are not supported by Terraform. I hope they correct this soon as this is a good piece of functionality I would love to have so I can automate my builds.

josh.converse has reacted to this post.
josh.converse

Ran into the same issue, it's trying to use {antlet-name} in the request URI like you've indicated.  In the end I was hoping to be able to spin up a container, add a dedicated vnic and deploy ssh keys, but it looks like the only thing you can really do with antsle in terraform is spin up instances based on templates..

Hi @alexray

One of our forum members, BobTheBuilder, recently wrote about Terraform and antsle.

Hopefully you may find some of the information useful:
https://bradthebuilder.me/blog/2021/antsle-and-terraform.html

Thank you,
antsle Support

@daniel-luck I saw that article and used it as a reference, I'm able to spin up LXC or KVM instances fine, like shown in the article.

I was hoping to be able to do more than that, namely add SSH keys to instances and customize cloud-init like you can with the proxmox provider, ideally bootstrap Windows instances for WinRM.  Being able to define vnics would also be helpful.

End goal being the use of terraform for initial provisioning, then using ansible to finish configuration.   I don't see any writing on using the terraform provider to do much aside from deploy some VMs, but then actually configuring them remains a manual task.

bradthebuilder and daniel.luck have reacted to this post.
bradthebuilderdaniel.luck

Hi @alexray

Glad that you were able to find the article useful.

Thanks for the suggestion, and I'll share with our team.

Thank you,
antsle Support

@daniel-luck Reviving this thread as I don't think @soneill problem was actually solved.

I am also having the same issue trying to add a Virtual NIC to an antlet. There is this related github issue here: https://github.com/antsle/antsle-terraform-provider-example/issues/2

Signs are pointing to that the Antsle swagger file is not compliant or up to par to be used with Terraform.

I can create a new antlet, no problem. What doesn't work is if I re-run the same TF script again on the newly created antlet. It tries to change zfs_info for some reason.

```
~ update in-place

Terraform will perform the following actions:

# antsle_antlets.piholetmp4 will be updated in-place
~ resource "antsle_antlets" "piholetmp4" {
id = "piholetmp4"
# (15 unchanged attributes hidden)

- zfs_info {
- antsle_managed_origin = "-" -> null
- logicalreferenced = 0 -> null
- origin = "antlets/_templates/Debian-11.lxc@snap" -> null
- origin_display = "Debian-11.lxc" -> null
- used = 0 -> null
}

# (1 unchanged block hidden)
}
```

You can recreate this scenario by running 2 applies one after another:

  1. terraform plan -out=tfplan
  2. terraform apply tfplan
  3. terraform plan -out=tfplan
  4. terraform apply tfplan

If I can't run the same plan over and over without modification or issue, there's no value in using Terraform for Antsle.

bradthebuilder and daniel.luck have reacted to this post.
bradthebuilderdaniel.luck

Hi @elte156

Thanks for the update and information.

I will bring this up to our developers and keep you updated.

Thanks.
antsle Support

Hi @elte156

I have confirmed this behavior with our developers.

They had mentioned that this would be addressed during out next major version of edgeLinux but we do not have an ETA at this time.

Thanks,
antsle Support

Page 1 of 2Next