packer-cn/website/source/docs/command-line/fix.html.md

35 lines
1.5 KiB
Markdown
Raw Normal View History

2013-07-14 04:38:31 -04:00
---
2015-07-22 22:31:00 -04:00
description: |
The `packer fix` Packer command takes a template and finds backwards
incompatible parts of it and brings it up to date so it can be used with the
latest version of Packer. After you update to a new Packer release, you should
run the fix command to make sure your templates work with the new release.
layout: docs
page_title: 'Fix - Command-Line'
...
2013-07-14 04:38:31 -04:00
# Command-Line: Fix
2015-07-22 22:31:00 -04:00
The `packer fix` Packer command takes a template and finds backwards
incompatible parts of it and brings it up to date so it can be used with the
latest version of Packer. After you update to a new Packer release, you should
run the fix command to make sure your templates work with the new release.
2013-07-14 04:38:31 -04:00
2015-07-22 22:31:00 -04:00
The fix command will output the changed template to standard out, so you should
redirect standard using standard OS-specific techniques if you want to save it
to a file. For example, on Linux systems, you may want to do this:
2013-07-14 04:38:31 -04:00
2016-03-11 20:29:04 -05:00
$ packer fix old.json > new.json
2013-07-14 04:38:31 -04:00
2015-07-22 22:31:00 -04:00
If fixing fails for any reason, the fix command will exit with a non-zero exit
status. Error messages appear on standard error, so if you're redirecting
2013-07-14 04:38:31 -04:00
output, you'll still see error messages.
2016-03-11 20:29:04 -05:00
-> **Even when Packer fix doesn't do anything** to the template, the template
2015-07-22 22:31:00 -04:00
will be outputted to standard out. Things such as configuration key ordering and
indentation may be changed. The output format however, is pretty-printed for
human readability.
2013-07-14 04:38:31 -04:00
2015-07-22 22:31:00 -04:00
The full list of fixes that the fix command performs is visible in the help
output, which can be seen via `packer fix -h`.