tfstack / terraform-provider-utilities

Terraform provider utilities
MIT License
0 stars 0 forks source link

fix: set default user and group #11

Open jajera opened 1 week ago

jajera commented 1 week ago
jajera commented 1 week ago

1st apply

terraform apply --auto-approve
random_string.suffix: Refreshing state... [id=mutpwo3b]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # module.name.utilities_local_directory.destination will be created
  + resource "utilities_local_directory" "destination" {
      + force       = true
      + group       = "root"
      + id          = (known after apply)
      + managed     = (known after apply)
      + path        = "/tmp/mutpwo3b"
      + permissions = "0755"
      + user        = "root"
    }

Plan: 1 to add, 0 to change, 0 to destroy.
module.name.utilities_local_directory.destination: Creating...
╷
│ Error: Error Setting Owner
│ 
│   with module.name.utilities_local_directory.destination,
│   on ../../main.tf line 21, in resource "utilities_local_directory" "destination":
│   21: resource "utilities_local_directory" "destination" {
│ 
│ Failed to set directory owner: chown /tmp/mutpwo3b: operation not permitted

2nd apply

terraform apply --auto-approve
random_string.suffix: Refreshing state... [id=mutpwo3b]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # module.name.utilities_local_directory.destination will be created
  + resource "utilities_local_directory" "destination" {
      + force       = true
      + group       = "root"
      + id          = (known after apply)
      + managed     = (known after apply)
      + path        = "/tmp/mutpwo3b"
      + permissions = "0755"
      + user        = "root"
    }

Plan: 1 to add, 0 to change, 0 to destroy.
module.name.utilities_local_directory.destination: Creating...
module.name.utilities_local_directory.destination: Creation complete after 0s [id=/tmp/mutpwo3b]

terraform plan. this becomes an infinite loop

terraform plan
random_string.suffix: Refreshing state... [id=mutpwo3b]
module.name.utilities_local_directory.destination: Refreshing state... [id=/tmp/mutpwo3b]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # module.name.utilities_local_directory.destination will be updated in-place
  ~ resource "utilities_local_directory" "destination" {
      ~ group       = "johna" -> "root"
        id          = "/tmp/mutpwo3b"
      ~ user        = "johna" -> "root"
        # (4 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.
jajera commented 1 week ago

workaround is to set

resource "utilities_local_directory" "destination" {
  force = true
  path  = var.destination_path
  user  = "johna"
  group = "johna"
}