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. 

You need to log in to create posts and topics.

Terraform Provider Plugin

I'm having the same issue as @coby-stinson and tried a few different ways to get things working.  Here is my setup.  Any help?  What version combinations work for you @mpbaum?

Versions I've tried:

Terraform OpenApi 27 | 22 | 16

EdgeLinux 2.0.0

antMan 3.0.0f

Terraform v0.12.0 | v0.12.24

Error Message:

$ terraform init

Initializing the backend...

Initializing provider plugins...

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.

$ terraform plan

Error: Failed to instantiate provider "antsle" to obtain schema: Unrecognized remote plugin message:

This usually means that the plugin is either invalid or simply
needs to be recompiled to support the latest protocol.

 

 

I had sometime this weekend (in the house because of lock down) and did a little work on this. After some trials and errors, I finally was able to get this to work with one of my Antsle setups. I built an AntMan/EdgeLinux using the community download and that’s what I used for this test.

In order to get Terraform to work, I had to configure my linux workstation with the following binary versions and setup. I hope this helps everyone trying to work on this and if there is interest, I’ll fork the repo, make updates, and put in a PR.

I'm excited to get this to work and I hope the team continues to make improvements and features available!

Versions of the Terraform and the OpenApi Provider I used:

Terraform v0.12.8

terraform-provider-openapi_0.23.0

These versions worked on the following EdgeLinux/AntMan Versions:

EdgeLinux 2.0.0

AntMan 3.0.0f

I made the following configurations to varies files:

~/.terraform.d/plugins/terraform-provider-openapi.yaml

version: 1

services:

antsle:

swagger-url: https://XXX.antsle.us/swagger.json

provider.tf

variable "apikey_auth" {

default = "Token eyJhbGciOiJI…………."

}

provider "antsle" {

api_key = var.apikey_auth

}

A few things to note to get this to work

1. I had to setup SSL in order for this to work (Documentation Link Here).  I could not use http://<privateip&gt;:3000/  I believe this link explains why.  Look at the Notes section of this link.

2. The documentation provided in the repo for the sample project shows an apikey_auth argument. This was not the case in my setup. I had to change the provider.tf to use api_key.

3. The insecure_skip_verify: true did not seem to have any affect when I used it. I believe there is a OpenAPI Provider issue there but I didn’t dig too deep into it.

4. DON’T FORGET the “TOKEN” in the apikey. I always do this and spend hours troubleshooting before I realize I forgot it.

Here are the commands I ran in the folder where my *tf files were located and the output:

$ rm -rf .terraform/ && terraform init && terraform plan && terraform apply

Initializing the backend...

Initializing provider plugins...

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see

any changes that are required for your infrastructure. All Terraform commands

should now work.

If you ever set or change modules or backend configuration for Terraform,

rerun this command to reinitialize your working directory. If you forget, other

commands will detect it and remind you to do so if necessary.

Refreshing Terraform state in-memory prior to plan...

The refreshed state will be used to calculate this plan, but will not be

persisted to local or remote state storage.

------------------------------------------------------------------------

An execution plan has been generated and is shown below.

Resource actions are indicated with the following symbols:

+ create

Terraform will perform the following actions:

# antsle_antlets.antlet1 will be created

+ resource "antsle_antlets" "antlet1" {

+ antlet_num = 33

+ autostart = (known after apply)

+ compression = "on"

+ cpu = 1

+ dname = "antlet1"

+ dtype = (known after apply)

+ id = (known after apply)

+ ip = (known after apply)

+ ram = 1024

+ ram_display = (known after apply)

+ state = (known after apply)

+ storage_display = (known after apply)

+ template = "Ubuntu16.04"

+ uuid = (known after apply)

+ zfs_quota = (known after apply)

+ zpool = (known after apply)

+ zpool_name = "antlets"

}

Plan: 1 to add, 0 to change, 0 to destroy.

------------------------------------------------------------------------

Note: You didn't specify an "-out" parameter to save this plan, so Terraform

can't guarantee that exactly these actions will be performed if

"terraform apply" is subsequently run.

An execution plan has been generated and is shown below.

Resource actions are indicated with the following symbols:

+ create

Terraform will perform the following actions:

# antsle_antlets.antlet1 will be created

+ resource "antsle_antlets" "antlet1" {

+ antlet_num = 33

+ autostart = (known after apply)

+ compression = "on"

+ cpu = 1

+ dname = "antlet1"

+ dtype = (known after apply)

+ id = (known after apply)

+ ip = (known after apply)

+ ram = 1024

+ ram_display = (known after apply)

+ state = (known after apply)

+ storage_display = (known after apply)

+ template = "Ubuntu16.04"

+ uuid = (known after apply)

+ zfs_quota = (known after apply)

+ zpool = (known after apply)

+ zpool_name = "antlets"

}

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?

Terraform will perform the actions described above.

Only 'yes' will be accepted to approve.

Enter a value: yes

antsle_antlets.antlet1: Creating...

antsle_antlets.antlet1: Creation complete after 3s [id=antlet1]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Shout out to to @tliddle30, I came back to this post-edgelinux 2.0 upgrade to find your solution, and can confirm it works. Moreover, I also tested Terraform 0.12.24 + OpenAPI plugin v0.29.0 and got it to work as well!

➜ test-29 tree -a
.
├── main.tf
├── provider.tf
├── .terraform
│      └── plugins
│               └── linux_amd64
│                       ├── lock.json
│                       └── terraform-provider-antsle_v0.29.0
├── terraform.tfstate
└── terraform.tfstate.backup

3 directories, 6 files
➜ test-29 cat main.tf
resource "antsle_antlets" "test-antlet" {
dname = "antlet1"
template = "debian"
ram = 1024
cpu = 1
antlet_num = 33
zpool_name = "antlets"
compression = "lz4"
}
➜ test-29 cat provider.tf
variable "apikey_auth" {
default = "Token ey..."
}

provider "antsle" {
api_key = var.apikey_auth
}
➜ test-29 terraform --version
Terraform v0.12.24
+ provider.antsle v0.29.0

Your version of Terraform is out of date! The latest version
is 0.12.25. You can update by downloading from https://www.terraform.io/downloads.html
➜ test-29 terraform init

Initializing the backend...

Initializing provider plugins...

The following providers do not have any version constraints in configuration,
so the latest version was installed.

To prevent automatic upgrades to new major versions that may contain breaking
changes, it is recommended to add version = "..." constraints to the
corresponding provider blocks in configuration, with the constraint strings
suggested below.

* provider.antsle: version = "~> 0.29"

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
➜ test-29 terraform apply

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create

Terraform will perform the following actions:

# antsle_antlets.test-antlet will be created
+ resource "antsle_antlets" "test-antlet" {
+ antlet_num = 33
+ autostart = (known after apply)
+ compression = "lz4"
+ cpu = 1
+ dname = "antlet1"
+ dtype = (known after apply)
+ id = (known after apply)
+ ip = (known after apply)
+ ram = 1024
+ ram_display = (known after apply)
+ state = (known after apply)
+ storage_display = (known after apply)
+ template = "debian"
+ uuid = (known after apply)
+ zfs_quota = (known after apply)
+ zpool = (known after apply)
+ zpool_name = "antlets"
}

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.

Enter a value: yes

antsle_antlets.test-antlet: Creating...
antsle_antlets.test-antlet: Creation complete after 5s [id=antlet1]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
➜ test-29 terraform destroy
antsle_antlets.test-antlet: Refreshing state... [id=antlet1]

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
- destroy

Terraform will perform the following actions:

# antsle_antlets.test-antlet will be destroyed
- resource "antsle_antlets" "test-antlet" {
- antlet_num = 33 -> null
- autostart = false -> null
- compression = "lz4" -> null
- cpu = 1 -> null
- dname = "antlet1" -> null
- dtype = "LXC" -> null
- id = "antlet1" -> null
- ip = "10.1.1.33" -> null
- ram = 1024 -> null
- ram_display = "1 GiB" -> null
- state = "Stopped" -> null
- storage_display = "∞" -> null
- template = "debian" -> null
- uuid = "7081608d-2748-4ce5-852c-5f4d33685ce4" -> null
- zfs_quota = 0 -> null
- zpool = {
- "antsle:managed_origin" = "-"
- "capacity" = "2%"
- "compression" = "off"
- "health" = "ONLINE"
- "mounted" = "true"
- "mountpoint" = "/antlets"
- "name" = "antlets"
- "size" = "1.80T"
} -> null
- zpool_name = "antlets" -> null
}

Plan: 0 to add, 0 to change, 1 to destroy.

Do you really want to destroy all resources?
Terraform will destroy all your managed infrastructure, as shown above.
There is no undo. Only 'yes' will be accepted to confirm.

Enter a value: yes

antsle_antlets.test-antlet: Destroying... [id=antlet1]
antsle_antlets.test-antlet: Destruction complete after 1s

Destroy complete! Resources: 1 destroyed.
➜ test-29

@coby-stinson and @tliddle30

Thank you both!

Thank you @tliddle30!  Saved me hours of work!

 

Able to create and destroy instances, but does anyone know how to create the antlet and start it once it's created using Terraform?  Seems like it starts in a Stopped state and the "state" variable appears to be "computed" only on creation.

Also - anyone have luck creating Load Balancing Rules?  Using the swagger definitions as a guide for what values to use, I created a resource definition as follows for a new lb-rule:

resource "antsle_antlets_lb-rules" "maria-lb40" {
id = 40
server-name = "maria40"
upstreams {
weight = 1
address = "10.1.1.40"
}
}

But terraform plan errors out with an "Invalid resource type":

The provider provider.antsle does not support resource type
"antsle_antlets_lb-rules".

What am I missing?