Skip to content

Instantly share code, notes, and snippets.

@gowthamakanthan
Created May 9, 2020 17:59
Show Gist options
  • Save gowthamakanthan/6792fec2145266344b28bbac559001ce to your computer and use it in GitHub Desktop.
Save gowthamakanthan/6792fec2145266344b28bbac559001ce to your computer and use it in GitHub Desktop.
Jenkins deployment on Vshphere using terraform in container
$ docker run -t -d -u 912296:25 -e HTTP_PROXY -e HTTPS_PROXY -e NO_PROXY -e VSPHERE_SUPERUSER_USERNAME -e VSPHERE_SUPERUSER_PASSWORD --entrypoint= -w /bms/webapps/jenkins/workspace/team_XSE/Admin/Terraform-Vsphere/test -v /bms/webapps/jenkins/workspace/team_XSE/Admin/Terraform-Vsphere/test:/bms/webapps/jenkins/workspace/team_XSE/Admin/Terraform-Vsphere/test:rw,z -v /bms/webapps/jenkins/workspace/team_XSE/Admin/Terraform-Vsphere/test@tmp:/bms/webapps/jenkins/workspace/team_XSE/Admin/Terraform-Vsphere/test@tmp:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** hashicorp/terraform:0.12.24 cat
$ docker top b1b6fc1f7be0b8897099f31096bc5916d29b47db186681e295e86141c0efba9c -eo pid,comm
Masking supported pattern matches of $VSPHERE_SUPERUSER_USERNAME or $VSPHERE_SUPERUSER_PASSWORD
[Pipeline] {
[Pipeline] ansiColor
[Pipeline] {
[Pipeline] dir
Running in /bms/webapps/jenkins/workspace/team_XSE/Admin/Terraform-Vsphere/test/frisbee/terraform
[Pipeline] {
[Pipeline] sh
+ terraform init '-input=false'
Initializing the backend...
Initializing provider plugins...
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
+ terraform validate
Success! The configuration is valid.
+ terraform plan -var 'vsphere_user=****' -var 'vsphere_password=****'
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
Error: mkdir /.govmomi: permission denied
on provider.tf line 1, in provider "vsphere":
1: provider "vsphere" {
[Pipeline] }
[Pipeline] // dir
[Pipeline] }
[Pipeline] // ansiColor
[Pipeline] }
[Pipeline] // withCredentials
[Pipeline] }
$ docker stop --time=1 b1b6fc1f7be0b8897099f31096bc5916d29b47db186681e295e86141c0efba9c
In local docker directory is getting created without any issues, but whuch is failing in deployment.
GOWGOPAL-M-H0VS:Test gowgopal$ docker run -it --rm --entrypoint /bin/sh hashicorp/terraform:0.12.24
Unable to find image 'hashicorp/terraform:0.12.24' locally
0.12.24: Pulling from hashicorp/terraform
c9b1b535fdd9: Pull complete
011000b168e5: Pull complete
4c096b23c4a8: Pull complete
Digest: sha256:53fb1c0a78c8bb91c4a855c1b352ea7928f6fa65f8080dc7a845e240dd2a9bee
Status: Downloaded newer image for hashicorp/terraform:0.12.24
/ # mkdir /.govmomi
/ #
@gowthamakanthan
Copy link
Author

gowthamakanthan commented May 9, 2020

Screenshot 2020-05-09 at 19 06 50
Jenkins Pipeline details.

@gowthamakanthan
Copy link
Author

gowthamakanthan commented May 11, 2020

Locally it's able to execute the plan. Through Jenkins it's not working.

Screenshot 2020-05-11 at 13 50 12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment