Merge branch 'master' into yandex/prepare-user-data
This commit is contained in:
commit
a56477c2e4
|
@ -26,6 +26,7 @@
|
|||
* builder/amazon: Fix single `tag` interpolation to allow for templating engine
|
||||
usage. [GH-10224]
|
||||
* builder/yandex: Fixed using cloud config when using IPv6 [GH-10297]
|
||||
* post-processort/yandex-export: added check of service account id
|
||||
|
||||
## 1.6.5 (October 30, 2020)
|
||||
|
||||
|
|
|
@ -32,12 +32,11 @@ func (s *stepCreateDisk) Run(ctx context.Context, state multistep.StateBag) mult
|
|||
return multistep.ActionContinue
|
||||
}
|
||||
|
||||
var diskFullPaths, diskSizes []string
|
||||
|
||||
ui.Say("Creating required virtual machine disks")
|
||||
// The 'main' or 'default' disk
|
||||
diskFullPaths = append(diskFullPaths, filepath.Join(s.OutputDir, name))
|
||||
diskSizes = append(diskSizes, s.DiskSize)
|
||||
diskFullPaths := []string{filepath.Join(s.OutputDir, name)}
|
||||
diskSizes := []string{s.DiskSize}
|
||||
|
||||
// Additional disks
|
||||
if len(s.AdditionalDiskSize) > 0 {
|
||||
for i, diskSize := range s.AdditionalDiskSize {
|
||||
|
|
|
@ -216,8 +216,10 @@ func (s *stepRun) getDeviceAndDriveArgs(config *Config, state multistep.StateBag
|
|||
drivesToAttach = append(drivesToAttach, imgPath)
|
||||
}
|
||||
|
||||
diskFullPaths := state.Get("qemu_disk_paths").([]string)
|
||||
drivesToAttach = append(drivesToAttach, diskFullPaths...)
|
||||
if v, ok := state.GetOk("qemu_disk_paths"); ok {
|
||||
diskFullPaths := v.([]string)
|
||||
drivesToAttach = append(drivesToAttach, diskFullPaths...)
|
||||
}
|
||||
|
||||
for i, drivePath := range drivesToAttach {
|
||||
driveArgumentString := fmt.Sprintf("file=%s,if=%s,cache=%s,discard=%s,format=%s", drivePath, config.DiskInterface, config.DiskCache, config.DiskDiscard, config.Format)
|
||||
|
@ -284,7 +286,9 @@ func (s *stepRun) applyUserOverrides(defaultArgs map[string]interface{}, config
|
|||
|
||||
commHostPort := 0
|
||||
if config.CommConfig.Comm.Type != "none" {
|
||||
commHostPort = state.Get("commHostPort").(int)
|
||||
if v, ok := state.GetOk("commHostPort"); ok {
|
||||
commHostPort = v.(int)
|
||||
}
|
||||
}
|
||||
httpIp := state.Get("http_ip").(string)
|
||||
httpPort := state.Get("http_port").(int)
|
||||
|
|
|
@ -83,9 +83,9 @@ func (c *GuestAdditionsConfig) Prepare(communicatorType string) []error {
|
|||
fmt.Errorf("guest_additions_mode is invalid. Must be one of: %v", validModes))
|
||||
}
|
||||
|
||||
if communicatorType == "none" && c.GuestAdditionsMode != "disable" {
|
||||
errs = append(errs, fmt.Errorf("guest_additions_mode has to be "+
|
||||
"'disable' when communicator = 'none'."))
|
||||
if communicatorType == "none" && c.GuestAdditionsMode == "upload" {
|
||||
errs = append(errs, fmt.Errorf("communicator must not be 'none' "+
|
||||
"when guest_additions_mode = 'upload'."))
|
||||
}
|
||||
|
||||
return errs
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
packer {
|
||||
required_version = ">= v1.0.0"
|
||||
}
|
||||
|
||||
source "file" "chocolate" {
|
||||
target = "chocolate.txt"
|
||||
content = "chocolate"
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
packer {
|
||||
version = ">= v1.0.0"
|
||||
}
|
|
@ -26,6 +26,9 @@ func TestValidateCommand(t *testing.T) {
|
|||
|
||||
// wrong version field
|
||||
{path: filepath.Join(testFixture("version_req", "wrong_field_name")), exitCode: 1},
|
||||
|
||||
// wrong packer block
|
||||
{path: filepath.Join(testFixture("validate", "invalid_packer_block.pkr.hcl")), exitCode: 1},
|
||||
}
|
||||
|
||||
for _, tc := range tt {
|
||||
|
|
|
@ -21,6 +21,8 @@ import (
|
|||
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
|
||||
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
|
||||
"github.com/hashicorp/packer/post-processor/artifice"
|
||||
"github.com/yandex-cloud/go-genproto/yandex/cloud/iam/v1"
|
||||
ycsdk "github.com/yandex-cloud/go-sdk"
|
||||
)
|
||||
|
||||
const defaultStorageEndpoint = "storage.yandexcloud.net"
|
||||
|
@ -196,6 +198,11 @@ func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact
|
|||
return nil, false, false, err
|
||||
}
|
||||
|
||||
ui.Say(fmt.Sprintf("Validating service_account_id: '%s'...", yandexConfig.ServiceAccountID))
|
||||
if err := validateServiceAccount(ctx, driver.SDK(), yandexConfig.ServiceAccountID); err != nil {
|
||||
return nil, false, false, err
|
||||
}
|
||||
|
||||
// Set up the state.
|
||||
state := new(multistep.BasicStateBag)
|
||||
state.Put("config", &yandexConfig)
|
||||
|
@ -259,3 +266,10 @@ func formUrls(paths []string) []string {
|
|||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func validateServiceAccount(ctx context.Context, ycsdk *ycsdk.SDK, serviceAccountID string) error {
|
||||
_, err := ycsdk.IAM().ServiceAccount().Get(ctx, &iam.GetServiceAccountRequest{
|
||||
ServiceAccountId: serviceAccountID,
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -110,8 +110,23 @@ if ! yc compute instance attach-disk ${INSTANCE_ID} --disk-name ${DISKNAME} --de
|
|||
Exit 1
|
||||
fi
|
||||
|
||||
DISK_LINK="/dev/disk/by-id/virtio-doexport"
|
||||
echo "Waiting for disk..."
|
||||
for attempt in 1 2 3; do
|
||||
sleep 3
|
||||
/sbin/udevadm trigger
|
||||
if [ -L "${DISK_LINK}" ]; then
|
||||
break
|
||||
fi
|
||||
echo "Attempt ${attempt}"
|
||||
if [ ${attempt} -eq 3 ]; then
|
||||
echo "Symlink ${DISK_LINK} not found"
|
||||
Exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Dumping disk..."
|
||||
if ! qemu-img convert -O qcow2 -o cluster_size=2M /dev/disk/by-id/virtio-doexport disk.qcow2 ; then
|
||||
if ! qemu-img convert -O qcow2 -o cluster_size=2M "${DISK_LINK}" disk.qcow2 ; then
|
||||
echo "Failed to dump disk to qcow2 image."
|
||||
Exit 1
|
||||
fi
|
||||
|
|
|
@ -141,7 +141,9 @@ can be done via environment variable:
|
|||
"network_interface": {
|
||||
"ipv4_address": "10.0.0.10",
|
||||
"ipv4_netmask": "24"
|
||||
}
|
||||
},
|
||||
"ipv4_gateway": "10.0.0.1",
|
||||
"dns_server_list": ["10.0.0.18"]
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -159,6 +161,9 @@ can be done via environment variable:
|
|||
ipv4_address = "10.0.0.10"
|
||||
ipv4_netmask = "24"
|
||||
}
|
||||
|
||||
ipv4_gateway = 10.0.0.1
|
||||
dns_server_list = ["10.0.0.18"]
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -288,6 +288,8 @@ Minimal example of usage to import a OVF template:
|
|||
|
||||
@include 'helper/communicator/SSH-not-required.mdx'
|
||||
|
||||
@include 'helper/communicator/SSH-Private-Key-File-not-required.mdx'
|
||||
|
||||
#### Optional WinRM fields:
|
||||
|
||||
@include 'helper/communicator/WinRM-not-required.mdx'
|
||||
|
|
|
@ -11,6 +11,8 @@ description: |-
|
|||
|
||||
`@include 'from-1.5/beta-hcl2-note.mdx'`
|
||||
|
||||
-> **Note:** The Packer block is only available in Packer v1.6.5 and later.
|
||||
|
||||
The `packer` configuration block type is used to configure some
|
||||
behaviors of Packer itself, such as the minimum required Packer version needed to
|
||||
apply your configuration.
|
||||
|
|
Loading…
Reference in New Issue