GithubHelp home page GithubHelp logo

disc / terraform-provider-pritunl Goto Github PK

View Code? Open in Web Editor NEW
35.0 3.0 18.0 360 KB

Pritunl Terraform provider

Home Page: https://pritunl.com

License: Mozilla Public License 2.0

Makefile 0.80% Go 94.68% Shell 4.52%
terraform pritunl terraform-provider

terraform-provider-pritunl's Introduction

Pritunl logo Terraform logo

Terraform Provider for Pritunl VPN Server

Release Registry License
Go Report Card

Requirements

  • Terraform >=0.13.x
  • Go 1.18.x (to build the provider plugin)

Building The Provider

$ git clone [email protected]:disc/terraform-provider-pritunl
$ make build

Example usage

Take a look at the examples in the documentation of the registry or use the following example:

# Set the required provider and versions
terraform {
  required_providers {
    pritunl = {
      source  = "disc/pritunl"
      version = "0.1.13"
    }
  }
}

# Configure the pritunl provider
provider "pritunl" {
  url    = "https://vpn.server.com"
  token  = "api-token"
  secret = "api-secret"
  insecure = false
}

# Create a pritunl organization resource
resource "pritunl_organization" "developers" {
  name = "Developers"
}

# Create a pritunl user resource 
resource "pritunl_user" "steve" {
  name            = "steve"
  organization_id = pritunl_organization.developers.id
  email           = "[email protected]"
  groups = [
    "developers",
  ]
}

# Create a pritunl server resource
resource "pritunl_server" "example" {
  name      = "example"
  port      = 15500
  protocol  = "udp"
  network   = "192.168.1.0/24"
  groups    = [
    "admins",
    "developers",
  ]
  
  # Attach the organization to the server
  organization_ids = [
    pritunl_organization.developers.id,
  ]

  # Describe all the routes manually
  # Default route 0.0.0.0/0 will be deleted on the server creation
  route {
    network = "10.0.0.0/24"
    comment = "Private network #1"
    nat     = true
  }
  
  route {
    network = "10.2.0.0/24"
    comment = "Private network #2"
    nat     = false
  }
  
  # Or create dynamic routes from variables
  dynamic "route" {
    for_each = var.common_routes
    content {
        network = route.value["network"]
        comment = route.value["comment"]
        nat     = route.value["nat"]
      }
  }
}

Multiple hosts per server (Replicated servers feature)

It also supports multiple host server's configuration with host datasource which can be matched by a hostname.

data "pritunl_host" "main" {
  hostname = "nyc1.vpn.host"
}

data "pritunl_host" "reserve" {
  hostname = "nyc3.vpn.host"
}

resource "pritunl_server" "test" {
  name    = "some-server"
  network = "192.168.250.0/24"
  port    = 15500

  host_ids = [
    data.pritunl_host.main.id,
    data.pritunl_host.reserve.id,
  ]
}

Importing exist resources

Describe exist resource in the terraform file first and then import them:

Import an organization:

# Describe a pritunl organization resource
resource "pritunl_organization" "developers" {
  name = "Developers"
}

Execute the shell command:

terraform import pritunl_organization.developers ${ORGANIZATION_ID}
terraform import pritunl_organization.developers 610e42d2a0ed366f41dfe6e8

The organization ID (as well as other resource IDs) can be found in the Pritunl API responses or in the HTML document response.

Import a user:

# Describe a pritunl user resource
resource "pritunl_user" "steve" {
  name            = "steve"
  organization_id = pritunl_organization.developers.id
  email           = "[email protected]"
}

Execute the shell command:

terraform import pritunl_user.steve ${ORGANIZATION_ID}-${USER_ID}
terraform import pritunl_user.steve 610e42d2a0ed366f41dfe6e8-610e42d6a0ed366f41dfe72b

Import a server:

# Describe a pritunl server resource
resource "pritunl_server" "example" {
  name      = "example"
  port      = 15500
  protocol  = "udp"
  network   = "192.168.1.0/24"
  groups    = [
    "developers",
  ]

  # Attach the organization to the server
  organization_ids = [
    pritunl_organization.developers.id,
  ]

  # Describe all the routes manually
  # Default route 0.0.0.0/0 will be deleted on the server creation
  route {
    network = "10.0.0.0/24"
    comment = "Private network #1"
    nat     = true
  }
}

Execute the shell command:

terraform import pritunl_server.example ${SERVER_ID}
terraform import pritunl_server.example 60cd0bfa7723cf3c911468a8

License

The Terraform Pritunl Provider is available to everyone under the terms of the Mozilla Public License Version 2.0. Take a look the LICENSE file.

terraform-provider-pritunl's People

Contributors

alessiodionisi avatar dependabot[bot] avatar disc avatar jackslateur avatar lephanff avatar lorepanichi avatar lotooo avatar quentinbtd avatar swissgipfel avatar ygelfand avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

terraform-provider-pritunl's Issues

Organizations are not imported by importing their server and being in the code.

Given the following example after importing and running the plan we see that you have not attached the organizations to their server.

# ...

resource "pritunl_organization" "this" {
  name = "example"
}

resource "pritunl_server" "this" {
  # ...
  organization_ids  = [
    pritunl_organization.this.id
  ]
}

Output after planning:

Terraform will perform the following actions:

  # pritunl_server.this will be updated in-place
  ~ resource "pritunl_server" "this" {
      #...
      ~ organization_ids   = [
          + "example-organization-id",
        ]
    }

support for cloud advertisement on the server's virtual network route?

When creating a server, pritunl includes with it a non-removable 'virtual network` route. You can then edit that route and mark the route with 'cloud advertise' which allows the active server's host (assuming it has the proper credentials) to edit the route tables in the VPC to direct routes to it.

Is this functionality that can be added to the server resource to allow setting cloud advertise? I'm wondering the best way to model this. Maybe something like this?

resource "pritunl_server" "test" {
  name="test"

  organization_ids = [
    "xxx"
  ]

  network = "w.x.y.z/n"
  port = NNN
  ...

  # new field.  If not present, default is no cloud_advertise?

  virtual_network_route = {
    cloud_advertise = true
  }

Thoughts? Thanks.

Any plans to support links?

I'm trying to use pritunl to manage multiple site-to-site configurations and would like to configure the links via Terraform. I don't see any resources to manage links, locations or routes to support this use case. Am I missing something or is this not currently implemented in the provider?

Multiple applying of changes

Hello.

When I have more than 8 changes I have the following problem:
Plan: 2 to add, 13 to change, 0 to destroy.

Error: Error on starting server: Non-200 response on starting the server
body=500: Internal Server Error

For 13 changes, I got 9 errors like above (I sent one error because the other 8 are the same).

Also after second terraform apply where I already have:
Plan: 1 to add, 8 to change, 1 to destroy.

Error: Error on starting server: Non-200 response on starting the server
body=500: Internal Server Error

For 8 changes, I got 3 error like above. After the third executing terraform apply terraform worked without errors.

I think it depends on time of waiting the pritunl will apply new changes. Probably pritunl provider doesn't wait when pritunl will apply new changes and moves on.

any plans for host related resources?

Great plugin -- thanks for starting and sharing this. I've only briefly tried it out with a new test server and it looked like it was doing the right thing. Would make a nice change from the manual work we're doing today as the number of servers we support grows.

Are there any plans for adding support for hosts in the near future? I could potentially try to take a crack at it with a PR, but would hold off if it's currently planned and/or in the works.

Any thoughts on how best to implement it? I was assuming given you can't add hosts directly through the UI, that implementing a host data resource, searchable by id might be the way to go, along with a host_settings resource.
Then there's the question of how to handle host server attachments -- whether to embed them directly in the server resource, similar to what you did with organization attachments, or create a host_server_attachment resource which takes as input a host_id and server_id.

Cheers.

Groups with spaces are not saved to terraform state

When the resource pritunl_server has groups that contain spaces, the groups are never saved to the terraform state.

Example:

resource "pritunl_server" "DIV" {
    name = "DIV-Server"
    groups =  ["DG - Planet Express", "DG - Guardians of Galaxus"]
    network = "172.31.68.0/24"
    network_wg = "172.31.69.0/24"
    organization_ids = [pritunl_organization.digitecgalaxus.id]
    port = 15400
    port_wg = 52000
    route {
        network = "10.1.3.4/32"
        comment = "DIV Server"
    }
}

results in this piece of terraform state:

"groups": [
              ""
],

This seems to be due to the pritunl server removing whitespace characters in the groups, then it will not match in this function:

func matchStringEntitiesWithSchema(entities []string, declaredEntities []interface{}) []string {

One workaround is to not use whitespace in the terraform configuration itself, e.g. use
groups = [for group in ["DG - Planet Express", "DG - Guardians of Galaxus"] : replace(group, " ", "")]

What do you think would be the best solution to handle this problem? I can see these options:

  1. Create a validation function for the groups attribute
  2. Fix the function matchStringEntitiesWithSchema to remove whitespace characters as well
  3. Check the Pritunl server, why it removes whitespace characters and fix it there

dynamic inventory: querying multiple pritunl hosts by criteria

Hello,

I was trying to use this module to configure a pritunl_server on dynamic ec2, this worked on first launch!
I think it worked because pritunl assumes if the pritunl_server host_ids field is empty, to use all current hosts, however that host quickly has been terminated and replaced with a new host with the same ip address, and now the pritunl_server definition is broken and tf has no plan to fix it.

I have repaired this by hand for the last few weeks, it becomes broken every time this reprovision happens. The reprovision happens due to a different ami id from a data provider filter, and that change forces the aws_instance to be replaced, and that generates a new unknown pritunl_host hostname. Dealing with it in terraform is an option for this here i think, but I also think there is no way to solve this without a change in this data provider.

Looking into it, at one point here, we have all the host information in memory, which is encouraging, seems like this is really close to being nearly a cosmetic change!

hosts, err := apiClient.GetHosts()

  1. Can we expose the full pritunl_host result set?
    This would enable me to filter it in hcl expressions.
  2. Can we expose the full pritunl host data for each host in the host set?
    Without more data than just hostname and id, I have no way to test which hosts are online and would probably remain stuck.

With a full list of host objects, populated with the full api data from pritunl (example below) I could have filtered the data I needed with a terraform expression and (maybe) been done fixing this dynamic inventory incompatibility.

Are there other ways to work around this limitation? If i could know the generated pritunl_host hostname ahead of committing the hcl, maybe I could explicitly query the data I need. Presently, the data provider has to way I understand to query the list of hostnames that exist, so by definition can't query any pritunl_host data unless I describe them from the pritunl api out of band of this provider, which maybe I could do with a presumptuous curl/wget shell out, would really prefer not to.
maybe I misunderstand: without having the full list of pritunl-generated host names, how can we write a query for a specific hostname? No way to get that string, can only ask for data about a specific string.

Is there some way to request a pritunl server instance use a specific hostname? I looked at the generated /etc/pritunl.conf and there is no setting for server hostname it seems, so i think these strings are just, generated only, so I feel pretty stuck here and confused how this could be used at all.


In case it helps, here is some sample data, with unique values replaced with fake data

{
  "page": 0,
  "page_total": 0,
  "hosts": [
    {
      "id": "0000000000000000000000000000000a",
      "name": "fake-genname-1",
      "hostname": "ip-0-0-0-0",
      "instance_id": null,
      "status": "offline",
      "uptime": null,
      "version": "1.30.2960.4",
      "user_count": 1,
      "users_online": 0,
      "local_networks": [
        "0.0.0.0/0"
      ],
      "public_addr": "0.0.0.0",
      "public_address": null,
      "public_addr6": null,
      "public_address6": null,
      "routed_subnet6": null,
      "routed_subnet6_wg": null,
      "proxy_ndp": null,
      "link_addr": "0.0.0.0",
      "link_address": null,
      "sync_address": null,
      "local_address": null,
      "local_addr": "0.0.0.0",
      "local_address6": null,
      "local_addr6": "::",
      "availability_group": "default"
    },
    {
      "id": "0000000000000000000000000000000b",
      "name": "fake-genname-2",
      "hostname": "ip-0.0.0.0",
      "instance_id": null,
      "status": "online",
      "uptime": 153454,
      "version": "1.30.2960.4",
      "user_count": 0,
      "users_online": 0,
      "local_networks": [
        "0.0.0.0/0"
      ],
      "public_addr": "0.0.0.0",
      "public_address": null,
      "public_addr6": null,
      "public_address6": null,
      "routed_subnet6": null,
      "routed_subnet6_wg": null,
      "proxy_ndp": null,
      "link_addr": "0.0.0.0",
      "link_address": null,
      "sync_address": null,
      "local_address": null,
      "local_addr": "0.0.0.0",
      "local_address6": null,
      "local_addr6": "::",
      "availability_group": "default"
    } 
  ] 
}

for my own needs, I think I need the cross section of status="online" and availability_group="default", and then from that cross section resource.pritunl_server.host_ids = [for i in data.pritunl_host : i.id]

presently, I see no way to get there with the source as is.

Thanks for your attention, I am comfortable proposing some edits to the source with your blessing, so lmk, is there a specific way this case should be dealt with, presumably backwards compatibility is a big deal, and I think the existing provider's hostname requirement makes changing this provider may be complicated to keep backwards compat.

validation needed for fields requiring CIDR

I created a server and accidentally forgot the number of bit at the end:

route {
     network =     "10.100.0.2"
     # should have been this
     #network =     "10.100.0.2/32"
     nat = false
   }

when applying the terraform plan, the server got created correctly, but then on a susequent plan, I got the following:

  # pritunl_server.test will be updated in-place
  ~ resource "pritunl_server" "test" {
        id                 = "[REDACTED]"
        name               = "test"
        # (30 unchanged attributes hidden)

      ~ route {
          + network = "10.100.0.2"
            # (1 unchanged attribute hidden)
        }
      - route {
          - nat     = false -> null
          - network = "10.100.0.2/32" -> null
        }
    }

Realizing my mistake, I then decided to update my plan correctly to this:

route {
     network =     "10.100.0.2/32"
     nat = false
   }

I thought running a plan then would show now changes, but instead I got this:

  # pritunl_server.test will be updated in-place
  ~ resource "pritunl_server" "test" {
        id                 = "REDACTED"
        name               = "test"
        # (30 unchanged attributes hidden)

      ~ route {
          + network = "10.20.0.2/32"
            # (1 unchanged attribute hidden)
        }
      - route {
          - nat     = false -> null
          - network = "10.20.0.2/32" -> null
        }
    }

And attempting to apply that change results in the following error:

pritunl_server.test: Modifying... [id=REDACTED]
╷
│ Error: Error on detaching route from the server: Non-200 response on deleting a route on the server
│ body=404 page not found
│
│   with pritunl_server.test,
│   on main.tf line 87, in resource "pritunl_server" "test":
│   87: resource "pritunl_server" "test" {
│

Can validation be added to require a route network to be valid CIDR?

After running into this problem, I tested this also with the network field for the pritunl_server resource and ran into issues as well:

resource "pritunl_server" "test" {
  name="test"

  network = "172.20.68.0/24"
  # should be valid CIDR like:
  network = "172.20.68.0"

When applying this plan to create the pritunl server, I get a 500 error:

pritunl_server.test: Creating...
╷
│ Error: Error on attaching server to the organization: Non-200 response on arrachhing an organization the server
│ body=500: Internal Server Error
│
│   with pritunl_server.test,
│   on main.tf line 87, in resource "pritunl_server" "test":
│   87: resource "pritunl_server" "test" {
│

I noticed in the pritunl admin UI a server with that name does get created, but there is no network value assigned to it.

Can validation be added for these fields to prevent this accidental state from occurring? Thanks.

Server routes order

Hi,
Thanks for the great provider, I've been dreaming to have it for such a long time.
After importing existing server as pritunl_server resource, terraform_plan suggests multiple changes to the routes which looks like something related to routes ordering:

resource "pritunl_server" "my-vpn" {
    name    = "my-vpn"
    port    = 1196
    network = "10.8.35.0/25"
  
    organization_ids = [
      pritunl_organization.this_orgs["_tools_"].id
    ]

    route {
      network = "10.1.0.0/16"
      comment = "route-1"
      nat     = true
    }
    route {
      network = "10.2.4.234/32"
      comment = "route-2"
      nat     = true
    }  
    route {
      network = "10.4.0.0/16"
      comment = "route-3"
      nat     = true
    }
  }

$terraform plan --target pritunl_server.my-vpn
pritunl_server.my-vpn: Refreshing state... [id=5e45018371f6b2996983beac]

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

Terraform will perform the following actions:

  # pritunl_server.my-vpn will be updated in-place
  ~ resource "pritunl_server" "my-vpn" {
        id                 = "5e45018371f6b2996983beac"
        name               = "my-vpn"
        # (31 unchanged attributes hidden)

      ~ route {
          ~ comment = "route-2" -> "route-1"
          ~ network = "10.2.4.234/32" -> "10.1.0.0/16"
            # (1 unchanged attribute hidden)
        }
      ~ route {
          ~ comment = "route-3" -> "route-2"
          ~ network = "10.4.0.0/16" -> "10.2.4.234/32"
            # (1 unchanged attribute hidden)
        }
      ~ route {
          ~ comment = "route-1" -> "route-3"
          ~ network = "10.1.0.0/16" -> "10.4.0.0/16"
            # (1 unchanged attribute hidden)
        }
    }

Pritunl API returns data in the same order as stated in pritunl_server resource :
'GET', '/server/5e45018371f6b2996983beac/route'

[
   {
      "comment":"None",
      "nat_netmap":"None",
      "network":"10.8.35.0/25",
      "vpc_region":"None",
      "net_gateway":false,
      "network_link":false,
      "metric":"None",
      "server":"5e45018371f6b2996983beac",
      "nat":false,
      "virtual_network":true,
      "vpc_id":"None",
      "advertise":"None",
      "link_virtual_network":false,
      "nat_interface":"None",
      "id":"31302e382e33352e302f3235",
      "server_link":false
   },
   {
      "comment":"route-1",
      "nat_netmap":"None",
      "network":"10.1.0.0/16",
      "vpc_region":"None",
      "net_gateway":false,
      "network_link":false,
      "metric":"None",
      "server":"5e45018371f6b2996983beac",
      "nat":true,
      "virtual_network":false,
      "vpc_id":"None",
      "advertise":false,
      "link_virtual_network":false,
      "nat_interface":"None",
      "id":"31302e312e302e302f3136",
      "server_link":false
   },
   {
      "comment":"route-2",
      "nat_netmap":"None",
      "network":"10.2.4.234/32",
      "vpc_region":"None",
      "net_gateway":false,
      "network_link":false,
      "metric":"None",
      "server":"5e45018371f6b2996983beac",
      "nat":true,
      "virtual_network":false,
      "vpc_id":"None",
      "advertise":false,
      "link_virtual_network":false,
      "nat_interface":"None",
      "id":"31302e322e342e3233342f3332",
      "server_link":false
   },
   {
      "comment":"route-3",
      "nat_netmap":"None",
      "network":"10.4.0.0/16",
      "vpc_region":"None",
      "net_gateway":false,
      "network_link":false,
      "metric":"None",
      "server":"5e45018371f6b2996983beac",
      "nat":true,
      "virtual_network":false,
      "vpc_id":"None",
      "advertise":false,
      "link_virtual_network":false,
      "nat_interface":"None",
      "id":"31302e342e302e302f3136",
      "server_link":false
   }
]

Is there anything to do with this? Thanks!

Settings resource

Hi,
Thanks again for the provider.
I was just wondering if there are plans to add settings resource to control box-level settings? This can be probably achieved by interacting with /settings endpoint.

intermittent test failures

Hello there. I'm running into issues where the test suite for this project intermittently fails with some errors. I ran the tests in a loop a loop and at times the following happens:

  • A server is expected to be in a pending state but its offline.
  • The order of host_ids returned by the server is different from what the provider expects
  • There's an issue with the authorization - seems the token/secret is not accepted
  • there's a panic exception with an invalid memory address

I think the authorization issue is possibly one of timing. I added a sleep statement of 5 seconds after running the mongo script to set the token in the database and that seemed to have helped.

I suspect the issue with host_ids is similar to the problem reported in #11 .
Not sure what's going on with the other issues. Some form of timing issue perhaps?

I'm including the output of the test runs here. For context, I've been trying to carve some time to continue working on a PR to add support for #5 and and have the functionality working but wanted to write some tests which requires me to understand the pritunl provider test framework. I started running the tests on my branch and ran into problems so I tried to run them on the mainline master with latest and the same problems exist.

This is the latest commit on master I'm building from:

commit c4e3ed54caf9d7ebde5c87172e9c636f2e1e46a6 (HEAD, original/master)
Merge: fcf711c ad73d46
Author: Alexandr Hacicheant <[email protected]>
Date:   Tue Nov 2 23:40:11 2021 +0200

    Merge pull request #11 from disc/server-attributes-reordering-on-import

    Fixed some server's attribute value reordering during importing stage

Happy to help if I can to troubleshoot. Let me know if you need more information.
I'm running tests on a mac pro. Using go version 1.16.3.

Test output:

❯ for i in 1 2 3 4 5 6 7 8 9 10; do make test; done
tf_pritunl_acc_test
ccc7ac955beeb649934047611cab1358a835c8b1bcdf50990893b984a5a463c9
sleep 10
./tools/wait-for-it.sh localhost:27017 -- echo "mongodb is up"
wait-for-it.sh: waiting 15 seconds for localhost:27017
wait-for-it.sh: localhost:27017 is available after 0 seconds
mongodb is up
# enables an api access for the pritunl user, updates an api token and secret
MongoDB shell version: 3.2.22
connecting to: test
switched to db pritunl
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
bye
TF_ACC=1 \
	PRITUNL_URL="https://localhost/" \
	PRITUNL_INSECURE="true" \
	PRITUNL_TOKEN=tfacctest_token \
	PRITUNL_SECRET=tfacctest_secret \
	go test -v -cover -count 1 ./internal/provider
=== RUN   TestDataSourceHost
=== PAUSE TestDataSourceHost
=== RUN   TestAccOrganization_basic
=== PAUSE TestAccOrganization_basic
=== RUN   TestGetServer_basic
    resource_server_test.go:14: ImportStateVerify attributes not equivalent. Difference is shown below. Top is actual, bottom is expected.

        (map[string]string) (len=1) {
         (string) (len=6) "status": (string) (len=7) "offline"
        }


        (map[string]string) (len=1) {
         (string) (len=6) "status": (string) (len=7) "pending"
        }
--- FAIL: TestGetServer_basic (39.78s)
=== RUN   TestGetServer_with_attached_organization
--- PASS: TestGetServer_with_attached_organization (58.49s)
=== RUN   TestGetServer_with_a_few_attached_organizations
    resource_server_test.go:102: ImportStateVerify attributes not equivalent. Difference is shown below. Top is actual, bottom is expected.

        (map[string]string) (len=1) {
         (string) (len=6) "status": (string) (len=7) "offline"
        }


        (map[string]string) (len=1) {
         (string) (len=6) "status": (string) (len=7) "pending"
        }
--- FAIL: TestGetServer_with_a_few_attached_organizations (52.63s)
=== RUN   TestGetServer_with_attached_route
--- PASS: TestGetServer_with_attached_route (50.78s)
=== RUN   TestGetServer_with_a_few_attached_routes
    resource_server_test.go:216: ImportStateVerify attributes not equivalent. Difference is shown below. Top is actual, bottom is expected.

        (map[string]string) (len=1) {
         (string) (len=6) "status": (string) (len=7) "offline"
        }


        (map[string]string) (len=1) {
         (string) (len=6) "status": (string) (len=7) "pending"
        }
--- FAIL: TestGetServer_with_a_few_attached_routes (42.06s)
=== RUN   TestGetServer_with_invalid_route
--- PASS: TestGetServer_with_invalid_route (16.64s)
=== RUN   TestCreateServer_with_invalid_network
--- PASS: TestCreateServer_with_invalid_network (9.67s)
=== RUN   TestCreateServer_with_unsupported_network
--- PASS: TestCreateServer_with_unsupported_network (21.51s)
=== RUN   TestCreateServer_with_invalid_bind_address
--- PASS: TestCreateServer_with_invalid_bind_address (20.96s)
=== RUN   TestGetServer_with_default_host
--- PASS: TestGetServer_with_default_host (18.99s)
=== RUN   TestGetServer_without_hosts
--- PASS: TestGetServer_without_hosts (31.33s)
=== RUN   TestAccUser_basic
=== PAUSE TestAccUser_basic
=== CONT  TestDataSourceHost
=== CONT  TestAccUser_basic
=== CONT  TestAccOrganization_basic
--- PASS: TestDataSourceHost (24.78s)
--- PASS: TestAccOrganization_basic (54.90s)
--- PASS: TestAccUser_basic (55.98s)
FAIL
coverage: 64.1% of statements
FAIL	github.com/disc/terraform-provider-pritunl/internal/provider	419.063s
FAIL
make: *** [test] Error 1
tf_pritunl_acc_test
452946e4896be03f21db9832e177480ce1d64cee9612f007415f3e2f52d6d8af
sleep 10
./tools/wait-for-it.sh localhost:27017 -- echo "mongodb is up"
wait-for-it.sh: waiting 15 seconds for localhost:27017
wait-for-it.sh: localhost:27017 is available after 0 seconds
mongodb is up
# enables an api access for the pritunl user, updates an api token and secret
MongoDB shell version: 3.2.22
connecting to: test
switched to db pritunl
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
bye
TF_ACC=1 \
	PRITUNL_URL="https://localhost/" \
	PRITUNL_INSECURE="true" \
	PRITUNL_TOKEN=tfacctest_token \
	PRITUNL_SECRET=tfacctest_secret \
	go test -v -cover -count 1 ./internal/provider
=== RUN   TestDataSourceHost
=== PAUSE TestDataSourceHost
=== RUN   TestAccOrganization_basic
=== PAUSE TestAccOrganization_basic
=== RUN   TestGetServer_basic
--- PASS: TestGetServer_basic (50.93s)
=== RUN   TestGetServer_with_attached_organization
--- PASS: TestGetServer_with_attached_organization (32.37s)
=== RUN   TestGetServer_with_a_few_attached_organizations
    resource_server_test.go:102: ImportStateVerify attributes not equivalent. Difference is shown below. Top is actual, bottom is expected.

        (map[string]string) (len=3) {
         (string) (len=18) "organization_ids.0": (string) (len=24) "6183d5c9b7e22d0001ace447",
         (string) (len=18) "organization_ids.1": (string) (len=24) "6183d5c9b7e22d0001ace44d",
         (string) (len=6) "status": (string) (len=7) "offline"
        }


        (map[string]string) (len=3) {
         (string) (len=18) "organization_ids.0": (string) (len=24) "6183d5c9b7e22d0001ace44d",
         (string) (len=18) "organization_ids.1": (string) (len=24) "6183d5c9b7e22d0001ace447",
         (string) (len=6) "status": (string) (len=7) "pending"
        }
--- FAIL: TestGetServer_with_a_few_attached_organizations (26.77s)
=== RUN   TestGetServer_with_attached_route
--- PASS: TestGetServer_with_attached_route (33.73s)
=== RUN   TestGetServer_with_a_few_attached_routes
--- PASS: TestGetServer_with_a_few_attached_routes (31.57s)
=== RUN   TestGetServer_with_invalid_route
--- PASS: TestGetServer_with_invalid_route (7.09s)
=== RUN   TestCreateServer_with_invalid_network
--- PASS: TestCreateServer_with_invalid_network (9.11s)
=== RUN   TestCreateServer_with_unsupported_network
--- PASS: TestCreateServer_with_unsupported_network (21.32s)
=== RUN   TestCreateServer_with_invalid_bind_address
--- PASS: TestCreateServer_with_invalid_bind_address (21.03s)
=== RUN   TestGetServer_with_default_host
--- PASS: TestGetServer_with_default_host (18.58s)
=== RUN   TestGetServer_without_hosts
--- PASS: TestGetServer_without_hosts (32.63s)
=== RUN   TestAccUser_basic
=== PAUSE TestAccUser_basic
=== CONT  TestDataSourceHost
=== CONT  TestAccUser_basic
=== CONT  TestAccOrganization_basic
--- PASS: TestDataSourceHost (23.97s)
--- PASS: TestAccOrganization_basic (54.56s)
--- PASS: TestAccUser_basic (61.17s)
FAIL
coverage: 64.1% of statements
FAIL	github.com/disc/terraform-provider-pritunl/internal/provider	346.608s
FAIL
make: *** [test] Error 1
tf_pritunl_acc_test
13aa7fcbdd7f1114514e2f2cd83c85b2dbfbd7ffde91a423628c3d53458d35b7
sleep 10
./tools/wait-for-it.sh localhost:27017 -- echo "mongodb is up"
wait-for-it.sh: waiting 15 seconds for localhost:27017
wait-for-it.sh: localhost:27017 is available after 0 seconds
mongodb is up
# enables an api access for the pritunl user, updates an api token and secret
MongoDB shell version: 3.2.22
connecting to: test
switched to db pritunl
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
bye
TF_ACC=1 \
	PRITUNL_URL="https://localhost/" \
	PRITUNL_INSECURE="true" \
	PRITUNL_TOKEN=tfacctest_token \
	PRITUNL_SECRET=tfacctest_secret \
	go test -v -cover -count 1 ./internal/provider
=== RUN   TestDataSourceHost
=== PAUSE TestDataSourceHost
=== RUN   TestAccOrganization_basic
=== PAUSE TestAccOrganization_basic
=== RUN   TestGetServer_basic
--- PASS: TestGetServer_basic (50.36s)
=== RUN   TestGetServer_with_attached_organization
--- PASS: TestGetServer_with_attached_organization (30.64s)
=== RUN   TestGetServer_with_a_few_attached_organizations
    resource_server_test.go:102: ImportStateVerify attributes not equivalent. Difference is shown below. Top is actual, bottom is expected.

        (map[string]string) (len=2) {
         (string) (len=18) "organization_ids.0": (string) (len=24) "6183d70fb7e22d0001a8e58a",
         (string) (len=18) "organization_ids.1": (string) (len=24) "6183d72eb7e22d0001a8e5f6"
        }


        (map[string]string) (len=2) {
         (string) (len=18) "organization_ids.0": (string) (len=24) "6183d72eb7e22d0001a8e5f6",
         (string) (len=18) "organization_ids.1": (string) (len=24) "6183d70fb7e22d0001a8e58a"
        }
--- FAIL: TestGetServer_with_a_few_attached_organizations (26.13s)
=== RUN   TestGetServer_with_attached_route
--- PASS: TestGetServer_with_attached_route (31.05s)
=== RUN   TestGetServer_with_a_few_attached_routes
--- PASS: TestGetServer_with_a_few_attached_routes (32.76s)
=== RUN   TestGetServer_with_invalid_route
--- PASS: TestGetServer_with_invalid_route (7.34s)
=== RUN   TestCreateServer_with_invalid_network
--- PASS: TestCreateServer_with_invalid_network (9.41s)
=== RUN   TestCreateServer_with_unsupported_network
--- PASS: TestCreateServer_with_unsupported_network (21.46s)
=== RUN   TestCreateServer_with_invalid_bind_address
--- PASS: TestCreateServer_with_invalid_bind_address (21.58s)
=== RUN   TestGetServer_with_default_host
--- PASS: TestGetServer_with_default_host (19.04s)
=== RUN   TestGetServer_without_hosts
--- PASS: TestGetServer_without_hosts (31.71s)
=== RUN   TestAccUser_basic
=== PAUSE TestAccUser_basic
=== CONT  TestDataSourceHost
=== CONT  TestAccUser_basic
=== CONT  TestAccOrganization_basic
--- PASS: TestDataSourceHost (23.61s)
--- PASS: TestAccUser_basic (53.69s)
--- PASS: TestAccOrganization_basic (54.31s)
FAIL
coverage: 64.1% of statements
FAIL	github.com/disc/terraform-provider-pritunl/internal/provider	336.073s
FAIL
make: *** [test] Error 1
tf_pritunl_acc_test
3b6f32da89154eec5c64330f247ee8ade9d7485cc4980d1627ead58314ffcb10
sleep 10
./tools/wait-for-it.sh localhost:27017 -- echo "mongodb is up"
wait-for-it.sh: waiting 15 seconds for localhost:27017
wait-for-it.sh: localhost:27017 is available after 0 seconds
mongodb is up
# enables an api access for the pritunl user, updates an api token and secret
MongoDB shell version: 3.2.22
connecting to: test
switched to db pritunl
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
bye
TF_ACC=1 \
	PRITUNL_URL="https://localhost/" \
	PRITUNL_INSECURE="true" \
	PRITUNL_TOKEN=tfacctest_token \
	PRITUNL_SECRET=tfacctest_secret \
	go test -v -cover -count 1 ./internal/provider
=== RUN   TestDataSourceHost
=== PAUSE TestDataSourceHost
=== RUN   TestAccOrganization_basic
=== PAUSE TestAccOrganization_basic
=== RUN   TestGetServer_basic
    resource_server_test.go:14: ImportStateVerify attributes not equivalent. Difference is shown below. Top is actual, bottom is expected.

        (map[string]string) (len=1) {
         (string) (len=6) "status": (string) (len=7) "offline"
        }


        (map[string]string) (len=1) {
         (string) (len=6) "status": (string) (len=7) "pending"
        }
--- FAIL: TestGetServer_basic (25.55s)
=== RUN   TestGetServer_with_attached_organization
--- PASS: TestGetServer_with_attached_organization (34.04s)
=== RUN   TestGetServer_with_a_few_attached_organizations
    resource_server_test.go:102: Step 1/3 error: Error running apply: exit status 1
        2021/11/04 08:56:23 [DEBUG] Using modified User-Agent: Terraform/0.12.31 HashiCorp-terraform-exec/0.14.0

        Error: Non-200 response on creating the organization
        body=401: Unauthorized

          on terraform_plugin_test.tf line 2, in resource "pritunl_organization" "test":
           2: resource "pritunl_organization" "test" {


--- FAIL: TestGetServer_with_a_few_attached_organizations (12.97s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x19de82d]

goroutine 1492 [running]:
testing.tRunner.func1.2(0x1ac18a0, 0x22fd5a0)
	/usr/local/opt/go/libexec/src/testing/testing.go:1143 +0x332
testing.tRunner.func1(0xc00065a900)
	/usr/local/opt/go/libexec/src/testing/testing.go:1146 +0x4b6
panic(0x1ac18a0, 0x22fd5a0)
	/usr/local/opt/go/libexec/src/runtime/panic.go:965 +0x1b9
github.com/disc/terraform-provider-pritunl/internal/provider.testGetServerDestroy(0xc0003fc1c0, 0xc00065a900, 0xc0002a9348)
	/Users/douglethin/.go/src/github.com/disc/terraform-provider-pritunl/internal/provider/resource_server_test.go:520 +0xad
github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource.runPostTestDestroy(0x1d94548, 0xc00065a900, 0x0, 0xc0000e4c90, 0xc0004788d0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/Users/douglethin/.go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/resource/testing_new.go:34 +0xeb
github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource.runNewTest.func1(0x1d94548, 0xc00065a900, 0xc0002c6c00, 0xc0002a9ac8)
	/Users/douglethin/.go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/resource/testing_new.go:68 +0x328
runtime.Goexit()
	/usr/local/opt/go/libexec/src/runtime/panic.go:613 +0x1e5
testing.(*common).FailNow(0xc00065a900)
	/usr/local/opt/go/libexec/src/testing/testing.go:741 +0x3c
testing.(*common).Fatalf(0xc00065a900, 0x1bfa39d, 0x14, 0xc0006e6780, 0x3, 0x3)
	/usr/local/opt/go/libexec/src/testing/testing.go:815 +0x93
github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource.runNewTest(0x1d94548, 0xc00065a900, 0x0, 0xc0000e4c90, 0xc0004788d0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/Users/douglethin/.go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/resource/testing_new.go:151 +0x568
github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource.Test(0x1d94548, 0xc00065a900, 0x0, 0xc0000e4c90, 0xc0004788d0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/Users/douglethin/.go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/resource/testing.go:566 +0x3e5
github.com/disc/terraform-provider-pritunl/internal/provider.TestGetServer_with_a_few_attached_organizations(0xc00065a900)
	/Users/douglethin/.go/src/github.com/disc/terraform-provider-pritunl/internal/provider/resource_server_test.go:102 +0x57e
testing.tRunner(0xc00065a900, 0x1c347f0)
	/usr/local/opt/go/libexec/src/testing/testing.go:1193 +0xef
created by testing.(*T).Run
	/usr/local/opt/go/libexec/src/testing/testing.go:1238 +0x2b3
FAIL	github.com/disc/terraform-provider-pritunl/internal/provider	72.817s
FAIL
make: *** [test] Error 1
tf_pritunl_acc_test
a4fa3ef9d277f5325658f160c535b84b00b1a86e7233f0f6c2ddec9f0de461a8
sleep 10
./tools/wait-for-it.sh localhost:27017 -- echo "mongodb is up"
wait-for-it.sh: waiting 15 seconds for localhost:27017
wait-for-it.sh: localhost:27017 is available after 0 seconds
mongodb is up
# enables an api access for the pritunl user, updates an api token and secret
MongoDB shell version: 3.2.22
connecting to: test
switched to db pritunl
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
bye
TF_ACC=1 \
	PRITUNL_URL="https://localhost/" \
	PRITUNL_INSECURE="true" \
	PRITUNL_TOKEN=tfacctest_token \
	PRITUNL_SECRET=tfacctest_secret \
	go test -v -cover -count 1 ./internal/provider
=== RUN   TestDataSourceHost
=== PAUSE TestDataSourceHost
=== RUN   TestAccOrganization_basic
=== PAUSE TestAccOrganization_basic
=== RUN   TestGetServer_basic
--- PASS: TestGetServer_basic (51.41s)
=== RUN   TestGetServer_with_attached_organization
    resource_server_test.go:58: ImportStateVerify attributes not equivalent. Difference is shown below. Top is actual, bottom is expected.

        (map[string]string) (len=1) {
         (string) (len=6) "status": (string) (len=7) "offline"
        }


        (map[string]string) (len=1) {
         (string) (len=6) "status": (string) (len=7) "pending"
        }
--- FAIL: TestGetServer_with_attached_organization (26.92s)
=== RUN   TestGetServer_with_a_few_attached_organizations
    resource_server_test.go:102: Step 1/3 error: Error running apply: exit status 1
        2021/11/04 08:58:07 [DEBUG] Using modified User-Agent: Terraform/0.12.31 HashiCorp-terraform-exec/0.14.0

        Error: Non-200 response on creating the organization
        body=401: Unauthorized

          on terraform_plugin_test.tf line 6, in resource "pritunl_organization" "test2":
           6: resource "pritunl_organization" "test2" {


--- FAIL: TestGetServer_with_a_few_attached_organizations (12.85s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x19de82d]

goroutine 2061 [running]:
testing.tRunner.func1.2(0x1ac18a0, 0x22fd5a0)
	/usr/local/opt/go/libexec/src/testing/testing.go:1143 +0x332
testing.tRunner.func1(0xc000336900)
	/usr/local/opt/go/libexec/src/testing/testing.go:1146 +0x4b6
panic(0x1ac18a0, 0x22fd5a0)
	/usr/local/opt/go/libexec/src/runtime/panic.go:965 +0x1b9
github.com/disc/terraform-provider-pritunl/internal/provider.testGetServerDestroy(0xc00024a000, 0xc000336900, 0xc000c0b348)
	/Users/douglethin/.go/src/github.com/disc/terraform-provider-pritunl/internal/provider/resource_server_test.go:520 +0xad
github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource.runPostTestDestroy(0x1d94548, 0xc000336900, 0x0, 0xc0006861e0, 0xc000110330, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/Users/douglethin/.go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/resource/testing_new.go:34 +0xeb
github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource.runNewTest.func1(0x1d94548, 0xc000336900, 0xc0008a5500, 0xc000c0bac8)
	/Users/douglethin/.go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/resource/testing_new.go:68 +0x328
runtime.Goexit()
	/usr/local/opt/go/libexec/src/runtime/panic.go:613 +0x1e5
testing.(*common).FailNow(0xc000336900)
	/usr/local/opt/go/libexec/src/testing/testing.go:741 +0x3c
testing.(*common).Fatalf(0xc000336900, 0x1bfa39d, 0x14, 0xc0005150e0, 0x3, 0x3)
	/usr/local/opt/go/libexec/src/testing/testing.go:815 +0x93
github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource.runNewTest(0x1d94548, 0xc000336900, 0x0, 0xc0006861e0, 0xc000110330, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/Users/douglethin/.go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/resource/testing_new.go:151 +0x568
github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource.Test(0x1d94548, 0xc000336900, 0x0, 0xc0006861e0, 0xc000110330, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/Users/douglethin/.go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/resource/testing.go:566 +0x3e5
github.com/disc/terraform-provider-pritunl/internal/provider.TestGetServer_with_a_few_attached_organizations(0xc000336900)
	/Users/douglethin/.go/src/github.com/disc/terraform-provider-pritunl/internal/provider/resource_server_test.go:102 +0x57e
testing.tRunner(0xc000336900, 0x1c347f0)
	/usr/local/opt/go/libexec/src/testing/testing.go:1193 +0xef
created by testing.(*T).Run
	/usr/local/opt/go/libexec/src/testing/testing.go:1238 +0x2b3
FAIL	github.com/disc/terraform-provider-pritunl/internal/provider	91.430s
FAIL
make: *** [test] Error 1
tf_pritunl_acc_test
785788a630d62ed115925a4d04239dbc5d278ee77b7df52a80705b3f43470e27
sleep 10
./tools/wait-for-it.sh localhost:27017 -- echo "mongodb is up"
wait-for-it.sh: waiting 15 seconds for localhost:27017
wait-for-it.sh: localhost:27017 is available after 0 seconds
mongodb is up
# enables an api access for the pritunl user, updates an api token and secret
MongoDB shell version: 3.2.22
connecting to: test
switched to db pritunl
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
bye
TF_ACC=1 \
	PRITUNL_URL="https://localhost/" \
	PRITUNL_INSECURE="true" \
	PRITUNL_TOKEN=tfacctest_token \
	PRITUNL_SECRET=tfacctest_secret \
	go test -v -cover -count 1 ./internal/provider
=== RUN   TestDataSourceHost
=== PAUSE TestDataSourceHost
=== RUN   TestAccOrganization_basic
=== PAUSE TestAccOrganization_basic
=== RUN   TestGetServer_basic
--- PASS: TestGetServer_basic (51.05s)
=== RUN   TestGetServer_with_attached_organization
--- PASS: TestGetServer_with_attached_organization (33.32s)
=== RUN   TestGetServer_with_a_few_attached_organizations
    resource_server_test.go:102: ImportStateVerify attributes not equivalent. Difference is shown below. Top is actual, bottom is expected.

        (map[string]string) (len=2) {
         (string) (len=18) "organization_ids.0": (string) (len=24) "6183d94eb7e22d00016255fe",
         (string) (len=18) "organization_ids.1": (string) (len=24) "6183d94eb7e22d0001625603"
        }


        (map[string]string) (len=2) {
         (string) (len=18) "organization_ids.0": (string) (len=24) "6183d94eb7e22d0001625603",
         (string) (len=18) "organization_ids.1": (string) (len=24) "6183d94eb7e22d00016255fe"
        }
--- FAIL: TestGetServer_with_a_few_attached_organizations (28.42s)
=== RUN   TestGetServer_with_attached_route
--- PASS: TestGetServer_with_attached_route (32.63s)
=== RUN   TestGetServer_with_a_few_attached_routes
--- PASS: TestGetServer_with_a_few_attached_routes (32.09s)
=== RUN   TestGetServer_with_invalid_route
--- PASS: TestGetServer_with_invalid_route (7.37s)
=== RUN   TestCreateServer_with_invalid_network
--- PASS: TestCreateServer_with_invalid_network (9.57s)
=== RUN   TestCreateServer_with_unsupported_network
--- PASS: TestCreateServer_with_unsupported_network (21.41s)
=== RUN   TestCreateServer_with_invalid_bind_address
--- PASS: TestCreateServer_with_invalid_bind_address (21.42s)
=== RUN   TestGetServer_with_default_host
--- PASS: TestGetServer_with_default_host (19.42s)
=== RUN   TestGetServer_without_hosts
--- PASS: TestGetServer_without_hosts (32.39s)
=== RUN   TestAccUser_basic
=== PAUSE TestAccUser_basic
=== CONT  TestDataSourceHost
=== CONT  TestAccUser_basic
=== CONT  TestAccOrganization_basic
--- PASS: TestDataSourceHost (23.13s)
--- PASS: TestAccOrganization_basic (53.95s)
--- PASS: TestAccUser_basic (55.63s)
FAIL
coverage: 64.1% of statements
FAIL	github.com/disc/terraform-provider-pritunl/internal/provider	345.004s
FAIL
make: *** [test] Error 1
tf_pritunl_acc_test
587f0221a88ef610a953c4259f2ed032c177ead6e1913ad4ac5416d948ba485e
sleep 10
./tools/wait-for-it.sh localhost:27017 -- echo "mongodb is up"
wait-for-it.sh: waiting 15 seconds for localhost:27017
wait-for-it.sh: localhost:27017 is available after 0 seconds
mongodb is up
# enables an api access for the pritunl user, updates an api token and secret
MongoDB shell version: 3.2.22
connecting to: test
switched to db pritunl
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
bye
TF_ACC=1 \
	PRITUNL_URL="https://localhost/" \
	PRITUNL_INSECURE="true" \
	PRITUNL_TOKEN=tfacctest_token \
	PRITUNL_SECRET=tfacctest_secret \
	go test -v -cover -count 1 ./internal/provider
=== RUN   TestDataSourceHost
=== PAUSE TestDataSourceHost
=== RUN   TestAccOrganization_basic
=== PAUSE TestAccOrganization_basic
=== RUN   TestGetServer_basic
    resource_server_test.go:14: ImportStateVerify attributes not equivalent. Difference is shown below. Top is actual, bottom is expected.

        (map[string]string) (len=1) {
         (string) (len=6) "status": (string) (len=7) "offline"
        }


        (map[string]string) (len=1) {
         (string) (len=6) "status": (string) (len=7) "pending"
        }
--- FAIL: TestGetServer_basic (26.17s)
=== RUN   TestGetServer_with_attached_organization
^CFAIL	github.com/disc/terraform-provider-pritunl/internal/provider	47.730s
make: *** [test] Error 1
❯

Here's my test output.

Create data_source for pritunl_user

Hello.

We have an inconvenience when we want to update existed user. For this we need to make terraform import.

Can you create data "pritunl_user" "username" for get user_id?

I think it might look like this:

data "pritunl_user" "username" {
  username = "[email protected]"
}

resource "pritunl_user" "username" {
  name            = "[email protected]"
  id              = data.pritunl_user.username.id
  organization_id = pritunl_organization.default.id
  email           = "[email protected]"
}

warnings in terraform log file

I happened to notice a warning message scroll when running terraform import on one of my pritunl_host resources.

2021-10-23T07:32:18.609-0400 [WARN]  Provider "registry.terraform.io/disc/pritunl" produced an unexpected new value for pritunl_server.test during refresh.
      - .name: was null, but now cty.StringVal("terraform_test")
      - .network: was null, but now cty.StringVal("172.20.68.0/24")
      - .network_wg: was null, but now cty.StringVal("")
      - .organization_ids: was null, but now cty.ListVal([]cty.Value{cty.StringVal("[REDACTED]")})
      - .replica_count: was null, but now cty.NumberIntVal(1)
      - .search_domain: was null, but now cty.StringVal("")
      - .host_ids: was null, but now cty.ListVal([]cty.Value{cty.StringVal("[REDACTED]"), cty.StringVal("[REDACTED]")})
      - .block_outside_dns: was null, but now cty.False
      - .hash: was null, but now cty.StringVal("sha1")
      - .network_mode: was null, but now cty.StringVal("")
      - .bind_address: was null, but now cty.StringVal("")
      - .network_start: was null, but now cty.StringVal("")
      - .vxlan: was null, but now cty.False
      - .inter_client: was null, but now cty.False
      - .multi_device: was null, but now cty.False
      - .port_wg: was null, but now cty.NumberIntVal(0)
      - .cipher: was null, but now cty.StringVal("aes256")
      - .dns_servers: was null, but now cty.ListVal([]cty.Value{cty.StringVal("10.20.0.2"), cty.StringVal("9.9.9.9")})
      - .otp_auth: was null, but now cty.False
      - .port: was null, but now cty.NumberIntVal(20068)
      - .allowed_devices: was null, but now cty.StringVal("")
      - .ping_timeout: was null, but now cty.NumberIntVal(60)
      - .status: was null, but now cty.StringVal("offline")
      - .link_ping_timeout: was null, but now cty.NumberIntVal(5)
      - .inactive_timeout: was null, but now cty.NumberIntVal(0)
      - .ipv6: was null, but now cty.False
      - .network_end: was null, but now cty.StringVal("")
      - .pre_connect_msg: was null, but now cty.StringVal("")
      - .dh_param_bits: was null, but now cty.NumberIntVal(2048)
      - .dns_mapping: was null, but now cty.False
      - .link_ping_interval: was null, but now cty.NumberIntVal(1)
      - .max_clients: was null, but now cty.NumberIntVal(2000)
      - .max_devices: was null, but now cty.NumberIntVal(0)
      - .mss_fix: was null, but now cty.NumberIntVal(0)
      - .debug: was null, but now cty.False
      - .protocol: was null, but now cty.StringVal("udp")
      - .restrict_routes: was null, but now cty.False
      - .ping_interval: was null, but now cty.NumberIntVal(10)
      - .route: block count changed from 0 to 1

I'm running essentially these commands:

terraform init
terraform apply
terraform state rm pritunl_server.test
TF_LOG=debug terraform import pritunl_server.test [REDACTED-hostid]
terraform plan

Everything appears to work fine. The plan runs cleanly, showing no changes.

Actually, I noticed another warning when I running terraform plan with logging enabled

pritunl_server.test: Refreshing state... [id=[REDACTED]]
2021-10-23T07:41:44.237-0400 [WARN]  Provider "registry.terraform.io/disc/pritunl" produced an invalid plan for pritunl_server.test, but we are tolerating it because it is using the legacy plugin SDK.
    The following problems may be the cause of any confusing errors from downstream operations:
      - .groups: planned value cty.NullVal(cty.List(cty.String)) does not match config value cty.ListValEmpty(cty.String)
      - .inactive_timeout: planned value cty.NumberIntVal(0) for a non-computed attribute
      - .inter_client: planned value cty.False for a non-computed attribute
      - .ipv6: planned value cty.False for a non-computed attribute
      - .block_outside_dns: planned value cty.False for a non-computed attribute
      - .protocol: planned value cty.StringVal("udp") for a non-computed attribute
      - .dns_mapping: planned value cty.False for a non-computed attribute
      - .vxlan: planned value cty.False for a non-computed attribute
      - .allowed_devices: planned value cty.StringVal("") for a non-computed attribute
      - .pre_connect_msg: planned value cty.StringVal("") for a non-computed attribute
      - .max_devices: planned value cty.NumberIntVal(0) for a non-computed attribute
      - .network_end: planned value cty.StringVal("") for a non-computed attribute
      - .restrict_routes: planned value cty.False for a non-computed attribute
      - .bind_address: planned value cty.StringVal("") for a non-computed attribute
      - .network_start: planned value cty.StringVal("") for a non-computed attribute
      - .hash: planned value cty.StringVal("sha1") for a non-computed attribute
      - .network_mode: planned value cty.StringVal("") for a non-computed attribute
      - .network_wg: planned value cty.StringVal("") for a non-computed attribute
      - .debug: planned value cty.False for a non-computed attribute
      - .mss_fix: planned value cty.NumberIntVal(0) for a non-computed attribute
      - .multi_device: planned value cty.False for a non-computed attribute
      - .otp_auth: planned value cty.False for a non-computed attribute
      - .port_wg: planned value cty.NumberIntVal(0) for a non-computed attribute
      - .search_domain: planned value cty.StringVal("") for a non-computed attribute
      - .route[0].comment: planned value cty.StringVal("") for a non-computed attribute
2021-10-23T07:41:44.239-0400 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2021-10-23T07:41:44.240-0400 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/disc/pritunl/0.1.1/darwin_amd64/terraform-provider-pritunl_v0.1.1 pid=2318
2021-10-23T07:41:44.240-0400 [DEBUG] provider: plugin exited
2021-10-23T07:41:44.240-0400 [INFO]  backend/local: plan operation completed

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.

Maybe the first warning shown above is related to the message from the second warning - "but we are tolerating it because it is using the legacy plugin SDK."?

My resource looks like this:

resource "pritunl_server" "test" {
  name="terraform_test"

  groups = []

  organization_ids = [
    "[REDACTED]"
  ]

  # looking these up.
  host_ids = [for host in local.host_names:
    data.pritunl_host.host[host].id
  ]

  network = "172.20.68.0/24"
  port = 20068
  cipher             = "aes256"
  dns_servers        = [
    "10.20.0.2",
    "9.9.9.9",
  ]

  route {
     network =     "10.20.0.2/32"
     nat = false
  }
}

I guess if the functionality is working, maybe I shouldn't worry so much about noise in the log files as we don't regularly look there. Just wanted to report this in case it was indicative of a problem in the code. Not sure if terraform is planning on deprecating the legacy plugin API at some point?

Cheers.

Refreshing state problem

Currently when you create resources using Terraform and delete them on UI, terraform will give an error like this:

╷
│ Error: Non-200 response on getting the organization
│ body=500: Internal Server Error
│ 
│   with module.test_org.pritunl_organization.this,
│   on ../../modules/pritunl_org/main.tf line 1, in resource "pritunl_organization" "this":
│    1: resource "pritunl_organization" "this" {
│ 
╵

Missing session_timeout on sever config

Cannot find the session_timeout parameter on the provider for server configuration, think it will be good to add it. Named as "User Session Timeout" on Pritunl server dashboard

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.