Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ad_computer creation error with multiple DC #155

Open
eossf opened this issue Aug 5, 2022 · 2 comments
Open

ad_computer creation error with multiple DC #155

eossf opened this issue Aug 5, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@eossf
Copy link

eossf commented Aug 5, 2022

When creating a computer with ad_computer on multiple DC.
The creation works fine, but there is an error that let the tfstate empty.

See example below, creation of TF06211 machine in our AD.

Debug Output

│ Error: Provider produced inconsistent result after apply

│ When applying changes to ad_computer.TF06211, provider "provider["registry.terraform.io/hashicorp/ad"]" produced an unexpected new value: Root resource was present, but now absent.

│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

Terraform Version and Provider Version

terraform 1.2.6 (latest at this date)
provider ad 0.4.4

Windows Version

Windows 2016+

Context

the terraform apply is done on

  1. linux docker ubi8, which calls
  2. win2016 (HTTPS) with powershell & winrm capabilities, which calls
  3. pool of AD
provider "ad" {
  domain_controller   = var.pool_AD
  winrm_hostname =  var.AD_hostname
  winrm_username = var.AD_user
  winrm_password = var.AD_password
  winrm_port             = 5986
  winrm_proto            = "https"
  winrm_pass_credentials = true
  winrm_insecure         = true
  winrm_use_ntlm         = true
}

Affected Resource(s)

ressource ad_computer

Steps to Reproduce

simply create this ressource

resource "ad_computer" "TF06211" {
  container= "OU=IAC,OU=Servers,DC=myhost,DC=local"
  description= ""
  name= "TF06211"
  pre2kname= "TF06211$"
}

Important

When I replace the pool of DCs (see above(3)) with a targeted DC, that works fine. The code throwing error is the return resourceADComputerRead(d, meta)

Cause : the object is requested to a server not udated yet

func resourceADComputerCreate(d *schema.ResourceData, meta interface{}) error {
    computer := winrmhelper.NewComputerFromResource(d)
    guid, err := computer.Create(meta.(*config.ProviderConf))
    if err != nil {
        return fmt.Errorf("error while creating new computer object: %s", err)
    }
    d.SetId(guid)
    return resourceADComputerRead(d, meta)
}
@eossf eossf added the bug Something isn't working label Aug 5, 2022
@eossf
Copy link
Author

eossf commented Aug 5, 2022

I could fix this issue but maybe before it woud be nice to have a short discussion on method ?

@Khatib19
Copy link

Hello. I have quite the same error :

  • I target one dc
  • I create multiple computer objects
  • I have the message "error while creating new computer object" on some computer objects and the computers appear in Active Directory with a down arrow. This message appear as said above in the func resourceADComputerCreate(d *schema.ResourceData, meta interface{})

Is there any fix for this issue ?
I never encountered the issue when I create only one object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants