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.
Using the Terraform Provider Antlets and VNICs resources
Quote from soneill on August 12, 2020, 10:29 amDoes 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
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
Quote from soneill on August 16, 2020, 7:50 pmThis 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 ?
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 ?
Quote from Grasume on August 27, 2020, 6:11 pmTheoretically 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.
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.
Quote from alexray on March 7, 2022, 12:56 pmRan 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..
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..
Quote from daniel.luck on March 7, 2022, 6:55 pmHi @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.htmlThank you,
antsle Support
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
Quote from alexray on March 8, 2022, 8:20 am@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.
@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.
Quote from daniel.luck on March 11, 2022, 5:16 pmHi @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
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
Quote from elte156 on January 4, 2023, 11:56 pm@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-placeTerraform 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:
- terraform plan -out=tfplan
- terraform apply tfplan
- terraform plan -out=tfplan
- 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.
@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:
- terraform plan -out=tfplan
- terraform apply tfplan
- terraform plan -out=tfplan
- 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.
Quote from daniel.luck on January 5, 2023, 5:38 pmHi @elte156
Thanks for the update and information.
I will bring this up to our developers and keep you updated.
Thanks.
antsle Support
Hi @elte156
Thanks for the update and information.
I will bring this up to our developers and keep you updated.
Thanks.
antsle Support
Quote from daniel.luck on January 9, 2023, 10:23 amHi @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
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