packer-cn/provisioner/shell
nywilken b80882f3b8 provisioner/shell: Fix envVarFile clean up issue
This change ensures the deletion of the external envVarFile (use_env_var_file = true) occurs after all script files have been executed and deleted.

Build results before change
```
> packer build build.pkr.hcl                                                                                                                                                             [~0]
docker: output will be in this color.

==> docker: Creating a temporary directory for sharing data...
==> docker: Pulling Docker image: ubuntu:bionic
    docker: bionic: Pulling from library/ubuntu
    docker: Digest: sha256:8d31dad0c58f552e890d68bbfb735588b6b820a46e459672d96e585871acc110
    docker: Status: Image is up to date for ubuntu:bionic
    docker: docker.io/library/ubuntu:bionic
==> docker: Starting docker container...
    docker: Run command: docker run -v /home/wilken/.packer.d/tmp476880774:/packer-files -d -i -t --entrypoint=/bin/sh -- ubuntu:bionic
    docker: Container ID: 812069b4d70746a6d4592a8f75c06867c6774b8b0bd81ade76eae7926a30f64b
==> docker: Using docker communicator to connect: 172.17.0.2
==> docker: Provisioning with shell script: sample.sh
    docker: Sample Script
    docker: wilken is NotForSale!
==> docker: Provisioning with shell script: foobar.sh
==> docker: /bin/sh: 1: .: Can't open /tmp/varfile_2555.sh
==> docker: Provisioning step had errors: Running the cleanup provisioner, if present...
==> docker: Killing the container: 812069b4d70746a6d4592a8f75c06867c6774b8b0bd81ade76eae7926a30f64b
Build 'docker' errored: Script exited with non-zero exit status: 2.Allowed exit codes are: [0]

==> Some builds didn't complete successfully and had errors:
--> docker: Script exited with non-zero exit status: 2.Allowed exit codes are: [0]

==> Builds finished but no artifacts were created.
```

Build results after change
```
> packer build build.pkr.hcl
docker: output will be in this color.

==> docker: Creating a temporary directory for sharing data...
==> docker: Pulling Docker image: ubuntu:bionic
    docker: bionic: Pulling from library/ubuntu
    docker: Digest: sha256:8d31dad0c58f552e890d68bbfb735588b6b820a46e459672d96e585871acc110
    docker: Status: Image is up to date for ubuntu:bionic
    docker: docker.io/library/ubuntu:bionic
==> docker: Starting docker container...
    docker: Run command: docker run -v /home/wilken/.packer.d/tmp819845000:/packer-files -d -i -t --entrypoint=/bin/sh -- ubuntu:bionic
    docker: Container ID: d8ed9100ff5017379bfc0d80703b2b2d10c4104941663aa5ddbbf18f6dcf74a5
==> docker: Using docker communicator to connect: 172.17.0.2
==> docker: Provisioning with shell script: sample.sh
    docker: Sample Script
    docker: wilken is NotForSale!
==> docker: Provisioning with shell script: foobar.sh
    docker: FooBar Script
    docker: wilken is NotForSale!
==> docker: Committing the container
    docker: Image ID: sha256:a412e43f134431f2049a7d06d5d691aad3717d91dd2ee5e2575e05b89384a4b3
==> docker: Killing the container: d8ed9100ff5017379bfc0d80703b2b2d10c4104941663aa5ddbbf18f6dcf74a5
Build 'docker' finished.

==> Builds finished. The artifacts of successful builds are:
--> docker: Imported Docker image: sha256:a412e43f134431f2049a7d06d5d691aad3717d91dd2ee5e2575e05b89384a4b3
```
2020-01-23 14:59:36 -05:00
..
provisioner.go provisioner/shell: Fix envVarFile clean up issue 2020-01-23 14:59:36 -05:00
provisioner.hcl2spec.go build using HCL2 (#8423) 2019-12-17 11:25:56 +01:00
provisioner_test.go provisioner/shell: Add `env_var_format` support to shell provisioner 2019-11-06 16:28:56 -05:00
unix_reader.go provisioner/shell: comment on why we return right away if advance == 0 2013-10-15 09:48:12 -10:00
unix_reader_test.go provisioner/shell: fix EOF detection 2013-10-15 05:56:10 -07:00