Skip to content

Commit

Permalink
feat: add debug (#706)
Browse files Browse the repository at this point in the history
- Adds `--help` / `-h` option to `./build.sh` for help.
- Adds `--debug` / `-d` option to `./build.sh` for debug mode.

Ref: #697

Signed-off-by: Ryan Johnson <johnsonryan@vmware.com>
  • Loading branch information
tenthirtyam committed Sep 29, 2023
1 parent 23eb54c commit 12dd9a3
Show file tree
Hide file tree
Showing 5 changed files with 323 additions and 194 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- Adds an example `.gitlab.yml` file for GitLab CI/CD. [GH-675](https://github.com/vmware-samples/packer-examples-for-vsphere/pull/675)
- Adds a `build-ci.tmpl` that can be used to create or update the `.gitlab-ci.yml` file using gomplate. [GH-675](https://github.com/vmware-samples/packer-examples-for-vsphere/pull/675)
- Adds Packer logging settings to `set-envvars.sh`. [GH-705](https://github.com/vmware-samples/packer-examples-for-vsphere/pull/705)
- Adds a debug option (`--debug` or `-d`) to`./build.sh` to enable debug logging for Packer. [GH-706](https://github.com/vmware-samples/packer-examples-for-vsphere/pull/706)

:bug: **Bugfix**:

Expand Down
48 changes: 40 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,38 @@ rainpole@macos> export HCP_CLIENT_SECRET=<client_secret>

Start a build by running the build script (`./build.sh`). The script presents a menu the which simply calls Packer and the respective build(s).

```console
./build.sh
```

This example will look for the configuration files in the `config` directory.

```console
./build.sh us-west-1
```

This example will look for the configuration files in the `us-west-1` directory.

If you need help for script options, pass the `--help` or `-h` flag to the build script to display the help for the build script.

```console
./build.sh --help
```

If you need to enable debugging, pass the `--debug` or `-d` flag to the build script to enable debug mode for Packer.

```console
./build.sh --debug
```

This example will look for the configuration files in the `config` directory and enable debug mode for Packer.

```console
./build.sh --debug us-west-1
```

This example will look for the configuration files in the `us-west-1` directory and enable debug mode for Packer.

You can also start a build based on a specific source for some of the virtual machine images.

For example, if you simply want to build a Microsoft Windows Server 2022 Standard Core, run the following:
Expand All @@ -997,17 +1029,17 @@ rainpole@macos> packer init builds/windows/server/2022/.
Build a specific machine image:

```console
rainpole@macos> packer build -force \
--only vsphere-iso.windows-server-standard-core \
-var-file="config/vsphere.pkrvars.hcl" \
-var-file="config/build.pkrvars.hcl" \
-var-file="config/common.pkrvars.hcl" \
builds/windows/server/2022
rainpole@macos> packer build -force on-error=ask\
--only vsphere-iso.windows-server-standard-core \
-var-file="config/vsphere.pkrvars.hcl" \
-var-file="config/build.pkrvars.hcl" \
-var-file="config/common.pkrvars.hcl" \
builds/windows/server/2022
```

### Build with Environmental Variables

You can set your environment variables if you would prefer not to save sensitive information in cleartext files.
You can set your environment variables if you would prefer not to save sensitive information in clear-text files.

You can add these to environmental variables using the included `set-envvars.sh` script.

Expand All @@ -1028,7 +1060,7 @@ rainpole@macos> packer init builds/windows/server/2022/.
Build a specific machine image using environmental variables:

```console
rainpole@macos> packer build -force \
rainpole@macos> packer build -force -on-error=ask\
--only vsphere-iso.windows-server-standard-core \
builds/windows/server/2022
```
Expand Down
Loading

0 comments on commit 12dd9a3

Please sign in to comment.