christophetd / Adaz

:wrench: Deploy customizable Active Directory labs in Azure - automatically.
https://blog.christophetd.fr/automating-the-provisioning-of-active-directory-labs-in-azure/
409 stars 84 forks source link

Fix race condition problem #40

Closed dange0 closed 3 years ago

dange0 commented 3 years ago

The Winlogbeat running on DC depends on the Elasticsearch server. However, the creation time sequence of DC and Elasticsearch is uncontrollable. The error occurs when DC tries to fetch the Elasticsearch server's private IP before the Elasticsearch server finishes its creation. And it will raise the error shown below:

null_resource.provision_rest_of_dc_after_creation (local-exec): TASK [winlogbeat : Find Elasticsearch IP] **************************************
null_resource.provision_rest_of_dc_after_creation (local-exec): fatal: [domain-controller_2a61]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'elasticsearch'\n\nThe error appears to be in 'Adaz/ansible/roles/winlogbeat/tasks/main.yml': line 8, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Find Elasticsearch IP\n  ^ here\n"}

In addition, the creation of the workstation also depends on DC. The user account must be already created on DC before starting the creation of the workstation. Otherwise, it will raise the error when doing the task "Ensure domain users can RDP on any workstation".

christophetd commented 3 years ago

Thanks a lot for your contribution! Out of curiosity, in which Azure region did you encounter this error?

Nevertheless, let me give it a quick run and I will merge it shortly.