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.

Terraform Provider Plugin

PreviousPage 4 of 5Next

Using the swagger-ui shows the exact same NullPointerException in antmand 🙁    Some other POST API work fine in swagger-ui (like antlets start and stop) but this /api/antlets API seems to have issues.

It works ... finally.    Unfortunately, the Antsle Terraform Provider example here: https://github.com/antsle/antsle-terraform-provider-example/ ... is wrong about the ram.  That should not be in Kbytes.  This 2018 Antsle Forum post got me working correctly:

https://antsle.com/forum/topic/curl-could-not-zfs-clone-for-antlet-testserver1/

My working Terraform config looks like this:

provider "antsle" {
api_key = "Token eyJh....."
version = "0.31.1"
}

resource "antsle_antlets" "seanterra" {
antlet_num = "50"
dname = "seanterra"
template = "CentOS-7.1.lxc"
zpool_name = "antlets"
compression = "off"
ram = 1
cpu = 1
}

You do not need to setup SSL on Anthill for your Antsle.  You can create a self-signed cert for the Nginx on your Antsle for that.  Simply uncomment the TLS server section of the nginx.conf file and add in this:

location ~ ^/(swagger-ui|swagger.json|api)? {
proxy_set_header X-Forwarded-Host $host:$server_port;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:3000;
}

When setting up your Terraform provider in the terraform-provider-openapi.yaml file, it needs the "insecure_skip_verify: true" as shown below as this is using a self-signed certificate.  The swagger-url should point to your Antsle Nginx controlled port 443/tcp URL as shown below in my example.

version: 1
services:
antsle:
swagger-url: https://antsleone.lan/swagger.json
insecure_skip_verify: true

And just for reference this recent 2020 video on the Antman API helped some as well: https://www.youtube.com/watch?v=dChdVIvP7zA&feature=youtu.be

Hoping at some point the documentation for the Antman API specification is tightened up indicating which arguments are required, what value setups they require (like "ram" !!! 🙂 )

Quote from soneill on August 9, 2020, 8:37 pm

It works ... finally.    Unfortunately, the Antsle Terraform Provider example here: https://github.com/antsle/antsle-terraform-provider-example/ ... is wrong about the ram.  That should not be in Kbytes.  This 2018 Antsle Forum post got me working correctly:

@soneill - where did you see the plugin asking for KB? It should all be MB.

Thanks!

One example is here:

https://docs.antsle.com/system/using-the-antman-rest-api-with-terraform

The other example is here:

https://github.com/antsle/antsle-terraform-provider-example/

The hard part here is the error you get is a NullPointerException in the antman log.

 

@soneill This is referring to MB not KB - I don't see it mention KB anywhere. Maybe the example is confusing since it says 1024? - That would make sense.

@marc - anything we can do to improve that error handling?

Uploaded files:
  • Screen-Shot-2020-08-10-at-2.30.12-PM.png

My math is all wrong !! 🙂  Actually my post is wrong.   I just tried 1024 again and it worked.   So, my apologies on the false positive posting.

Just tried it again but removed the "antlet_num" value.  And I got the null pointer again.  Is there anyway to update the provider error handling to throw an error saying that value is required vs a nullpointer ?

Back again to re-attempt this configuration with the latest Antman release!

I submitted a PR to the terraform-provider-openpi to address the provider's inability to handle the colon (":") characters in Antsle's APIs. Dikhan made some suggestions to remove the colon characters and or the "antsle" strings from the offending APIs to avoid redundancy, if the Antsle team is interested.

My changes are compatible with Antman 3.4.1's API and terraform 0.15.5. I'm likely going to try to submit another PR to support terraform > 1.0.0 as well. When all of the dust settles, I'll share a braindump so others can replicate what is working for me.

Sorry this took so long, but here's my write-up on getting Terraform to work with your Antsle. Hope it works for you!

lancem and daniel.luck have reacted to this post.
lancemdaniel.luck

Hi @coby-stinson

Thanks so much for your hard work and research into this.

Feel free to share to social media sites (such as Reddit) if you'd like.

Great job and thank you!

@coby-stinson, trying to get Terraform working following your blog post as closely as possible (which is going back MANY versions from current): antsleos-version 2.1.0, terraform v1.0.7 on darwin_amd64, built terraform-provider-openapi from your GitHub repo (tag 3.0.0 didn't work, so tried tag v2.2.0 as you used), and started off using your example .tf file.

I can successfully create a plan, but when trying to apply I keep getting the following error:

antsle_antlets.antlet1: Creating...

│ Error: request POST https://192.168.0.20:3000/api/antlets HTTP/1.1 failed. Response Error: 'Post "https://192.168.0.20:3000/api/antlets": EOF'

│ with antsle_antlets.antlet1,
│ on antlets.tf line 1, in resource "antsle_antlets" "antlet1":
│ 1: resource "antsle_antlets" "antlet1" {

From terraform log file:

2022-07-21T20:42:51.975-0700 [INFO] provider.terraform-provider-antsle: 2022/07/21 20:42:51 [DEBUG] Performing POST https://192.168.0.20:3000/api/antlets: timestamp=2022-07-21T20:42:51.975-0700
2022-07-21T20:42:51.975-0700 [INFO] provider.terraform-provider-antsle: 2022/07/21 20:42:51 [DEBUG] Request Header 'Authorization' sent: timestamp=2022-07-21T20:42:51.975-0700
2022-07-21T20:42:51.975-0700 [INFO] provider.terraform-provider-antsle: 2022/07/21 20:42:51 [DEBUG] Request Header 'User-Agent' sent: timestamp=2022-07-21T20:42:51.975-0700
2022-07-21T20:42:51.997-0700 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2022-07-21T20:42:52.001-0700 [DEBUG] provider: plugin process exited: path=.terraform/providers/localhost/antsle/antsle/2.2.0/darwin_amd64/terraform-provider-antsle pid=16731
2022-07-21T20:42:52.002-0700 [DEBUG] provider: plugin exited

There are no obvious errors, thought there are many of these:

2022-07-21T20:42:51.961-0700 [INFO] provider.terraform-provider-antsle: 2022/07/21 20:42:51 [DEBUG] found duplicate header 'antlet-name' for an operation, ignoring it as it has been registered already: timestamp=2022-07-21T20:42:51.961-0700
2022-07-21T20:42:51.961-0700 [INFO] provider.terraform-provider-antsle: 2022/07/21 20:42:51 [DEBUG] found duplicate header 'snapshot-name' for an operation, ignoring it as it has been registered already: timestamp=2022-07-21T20:42:51.961-0700

They don't seem to be the cause of the POST error, though these look odd:

2022-07-21T20:42:51.961-0700 [INFO] provider.terraform-provider-antsle: 2022/07/21 20:42:51 [DEBUG] found duplicate header '' for an operation, ignoring it as it has been registered already: timestamp=2022-07-21T20:42:51.961-0700
2022-07-21T20:42:51.961-0700 [INFO] provider.terraform-provider-antsle: 2022/07/21 20:42:51 [DEBUG] found duplicate header '' for an operation, ignoring it as it has been registered already: timestamp=2022-07-21T20:42:51.961-0700

I don't find anything useful with Google. It kind of seems like none of this is being maintained (and yes, I do know that Hashicorp tools change frequently in ways that break any software more than about 6-9 months old).

Any ideas or feedback on viability of using Terraform with the current OS?

PreviousPage 4 of 5Next