chvancooten / CloudLabsAD

Terraform + Ansible deployment scripts for an Active Directory lab environment.
MIT License
277 stars 58 forks source link

Remote-exec provisioner error #8

Open Shoulderboy opened 2 years ago

Shoulderboy commented 2 years ago

I'm trying to deplpy CloudLabs with terraform in my Azure subscription. But i keep failing on "remote-exec provisioner error" (see picture) I can connect to all the VMs created i would appreciate any help on this issue.

ScreenshotTerra1

similar error when running the tmp/script from the hackbox. ScreenshotTerra2

chvancooten commented 2 years ago

Hey! Thanks for this report, it looks like Elastic introduced a breaking change by starting to ask for confirmations when running this command: https://github.com/chvancooten/CloudLabsAD/blob/507c4a4a86226460f3f6ab52b36ba6c3dfecd04c/Ansible/roles/elastic_server/tasks/main.yml#L86, triggering this script: https://github.com/chvancooten/CloudLabsAD/blob/507c4a4a86226460f3f6ab52b36ba6c3dfecd04c/Ansible/roles/elastic_server/files/set-password-elastic.sh

Root cause seems to be this command: https://www.elastic.co/guide/en/elasticsearch/reference/master/reset-password.html, which luckily does have a --batch flag.

Could you try modifying the command in the set-password-elastic.sh file to say /usr/share/elasticsearch/bin/elasticsearch-reset-password -b -u elastic instead, and try again? Let me know if it works or submit a PR and I will integrate it!

(Sorry, would do that myself, but I'm quite busy ATM :) )

Shoulderboy commented 2 years ago

I applied and tested the change, unfortunately it did not work. The issue still remains the same.

image

chvancooten commented 2 years ago

Hey, thanks for applying the fix! Looks like this is a new problem as indicated by the error message. It seems like the IP address for Elastic is not properly propagated from Terraform to Ansible this time - this could be because you tried running Ansible separately. This is possible, but in that case you would need to fill the Template files with the IP addresses from your terraform output manually. Alternatively you can re-run the provisioning from start to finish to re-populate the Ansible files for deployment. Let me know if that works!

Shoulderboy commented 2 years ago

I tried applying IP addresses manually but got the same error as the first post. i tried running what i assume is the provisioning (ansible-playbook -v cloudlabs.yml) but it ended up with the same issue :/

chvancooten commented 2 years ago

Could you please provide a bit more information on how you provided the IP address to Ansible? Since the error you get now must be related to faulty config, and not the original issue :)

chvancooten commented 2 years ago

Original issue has been addressed in https://github.com/chvancooten/CloudLabsAD/commit/9fbe65dd546445323f23288c5e1167db64d7cba2, keeping this open for support on the config issue

Shoulderboy commented 2 years ago

Hey, I decided to restart the whole process. these are the errors i have encountered. hopefully this will give some kind of insight.

First error

image

My fix Added username:

image

Second error:

image

My fix: Replace all {{ ip address }} to ip.

image

Third error:

image

This is where I'm stuck :(

sorry for a long post, if we ever meet i'll buy you a beer. :)

chvancooten commented 2 years ago

Hi @Shoulderboy, thanks for the more detailed information! I think I see what the error is now. The below line:

https://github.com/chvancooten/CloudLabsAD/blob/main/Terraform/08-ansible.tf#L45

references the wrong template (linux.tmpl where it should be elastic.tmpl), looks like a copy-paste error when a fix was made to change the templating system. Could you make this change and see if that fixes your issues and propagates the variables correctly? No other changes should be necessary!