Original question, for posterity
What I'd like to do is use `truenas_dataset` to create a dataset that I then use for Samba shares later on. I did the naïve thing and set the `share_type = "smb"`, but then I ran into issues. It looks like:
- [`acl_mode`](https://github.com/dariusbakunas/terraform-provider-truenas/blob/309b5502382563dfa800a2cb00964587ee7e27af/truenas/resource_truenas_dataset.go#L90-L97) and [`case_sensitivity`](https://github.com/dariusbakunas/terraform-provider-truenas/blob/309b5502382563dfa800a2cb00964587ee7e27af/truenas/resource_truenas_dataset.go#L109-L116) both conflict with `share_type`.
- If you set the `share_type` to anything, it [forces the dataset to be recreated](https://github.com/dariusbakunas/terraform-provider-truenas/blob/309b5502382563dfa800a2cb00964587ee7e27af/truenas/resource_truenas_dataset.go#L250) each time you `terraform plan`.
- If you don't set the `share_type`, when creating you get `acl_mode = "discard"`, `acl_type = "posix"`, and `case_sensitivity = "sensitive"` (which may not be what you want).
- If you set `acl_mode = "restricted"`, it fails with:
```
│ Error: error updating dataset: 422 Unprocessable Entity
│ {
│ "pool_dataset_update.aclmode": [
│ {
│ "message": "Must be set to DISCARD when acltype is POSIX or OFF",
│ "errno": 22
│ }
│ ]
│ }
```
Is there a way to use the `truenas_dataset` to get what I want?
Sorry, I just tried it again and found out why I was having such trouble. This seems to work fine for a dataset managed entirely in terraform. In my case, I'd already created the datasets in TrueNAS through the web UI. I then tried to import them into Terraform. I had something like this:
resource "truenas_dataset" "tank_test" {
name = "test"
pool = "tank"
share_type = "smb"
}
When importing, it doesn't set the share_type in the state (maybe because it's not returned from the API?). So then when I would terraform plan, it would see that the share_type changed from null to "smb" and try to recreate the dataset.
Do you think there's a way to either get the share_type from some other API, or infer the share_type from the other attributes returned on the dataset? I haven't looked at all of the API yet (because it's pretty big), but I can do some spelunking if you don't already have an idea about the feasibility of it.
Original question, for posterity
What I'd like to do is use `truenas_dataset` to create a dataset that I then use for Samba shares later on. I did the naïve thing and set the `share_type = "smb"`, but then I ran into issues. It looks like: - [`acl_mode`](https://github.com/dariusbakunas/terraform-provider-truenas/blob/309b5502382563dfa800a2cb00964587ee7e27af/truenas/resource_truenas_dataset.go#L90-L97) and [`case_sensitivity`](https://github.com/dariusbakunas/terraform-provider-truenas/blob/309b5502382563dfa800a2cb00964587ee7e27af/truenas/resource_truenas_dataset.go#L109-L116) both conflict with `share_type`. - If you set the `share_type` to anything, it [forces the dataset to be recreated](https://github.com/dariusbakunas/terraform-provider-truenas/blob/309b5502382563dfa800a2cb00964587ee7e27af/truenas/resource_truenas_dataset.go#L250) each time you `terraform plan`. - If you don't set the `share_type`, when creating you get `acl_mode = "discard"`, `acl_type = "posix"`, and `case_sensitivity = "sensitive"` (which may not be what you want). - If you set `acl_mode = "restricted"`, it fails with: ``` │ Error: error updating dataset: 422 Unprocessable Entity │ { │ "pool_dataset_update.aclmode": [ │ { │ "message": "Must be set to DISCARD when acltype is POSIX or OFF", │ "errno": 22 │ } │ ] │ } ``` Is there a way to use the `truenas_dataset` to get what I want?Sorry, I just tried it again and found out why I was having such trouble. This seems to work fine for a dataset managed entirely in terraform. In my case, I'd already created the datasets in TrueNAS through the web UI. I then tried to import them into Terraform. I had something like this:
When importing, it doesn't set the
share_type
in the state (maybe because it's not returned from the API?). So then when I wouldterraform plan
, it would see that theshare_type
changed fromnull
to"smb"
and try to recreate the dataset.Do you think there's a way to either get the
share_type
from some other API, or infer theshare_type
from the other attributes returned on the dataset? I haven't looked at all of the API yet (because it's pretty big), but I can do some spelunking if you don't already have an idea about the feasibility of it.