From 0e4fec03d7c09bd3c105e24318a845288076620c Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Tue, 15 Oct 2019 12:47:59 +0200 Subject: [PATCH] make complete tests files link as windows can't handle synlinks --- hcl2template/testdata/complete/build.pkr.hcl | 67 ++++++++++++++++++- .../testdata/complete/communicator.pkr.hcl | 28 +++++++- .../testdata/complete/sources.pkr.hcl | 38 ++++++++++- .../testdata/complete/variables.pkr.hcl | 7 +- 4 files changed, 136 insertions(+), 4 deletions(-) mode change 120000 => 100644 hcl2template/testdata/complete/build.pkr.hcl mode change 120000 => 100644 hcl2template/testdata/complete/communicator.pkr.hcl mode change 120000 => 100644 hcl2template/testdata/complete/sources.pkr.hcl mode change 120000 => 100644 hcl2template/testdata/complete/variables.pkr.hcl diff --git a/hcl2template/testdata/complete/build.pkr.hcl b/hcl2template/testdata/complete/build.pkr.hcl deleted file mode 120000 index bf17682ed..000000000 --- a/hcl2template/testdata/complete/build.pkr.hcl +++ /dev/null @@ -1 +0,0 @@ -../build/basic.pkr.hcl \ No newline at end of file diff --git a/hcl2template/testdata/complete/build.pkr.hcl b/hcl2template/testdata/complete/build.pkr.hcl new file mode 100644 index 000000000..c48847c94 --- /dev/null +++ b/hcl2template/testdata/complete/build.pkr.hcl @@ -0,0 +1,66 @@ + +// starts resources to provision them. +build { + from "src.amazon-ebs.ubuntu-1604" { + ami_name = "that-ubuntu-1.0" + } + + from "src.virtualbox-iso.ubuntu-1204" { + // build name is defaulted from the label "src.virtualbox-iso.ubuntu-1204" + outout_dir = "path/" + } + + provision { + communicator = "comm.ssh.vagrant" + + shell { + inline = [ + "echo '{{user `my_secret`}}' :D" + ] + } + + shell { + valid_exit_codes = [ + 0, + 42, + ] + scripts = [ + "script-1.sh", + "script-2.sh", + ] + // override "vmware-iso" { // TODO(azr): handle common fields + // execute_command = "echo 'password' | sudo -S bash {{.Path}}" + // } + } + + file { + source = "app.tar.gz" + destination = "/tmp/app.tar.gz" + // timeout = "5s" // TODO(azr): handle common fields + } + + } + + post_provision { + amazon-import { + // only = ["src.virtualbox-iso.ubuntu-1204"] // TODO(azr): handle common fields + ami_name = "that-ubuntu-1.0" + } + } +} + +build { + // build an ami using the ami from the previous build block. + from "src.amazon.that-ubuntu-1.0" { + ami_name = "fooooobaaaar" + } + + provision { + + shell { + inline = [ + "echo HOLY GUACAMOLE !" + ] + } + } +} \ No newline at end of file diff --git a/hcl2template/testdata/complete/communicator.pkr.hcl b/hcl2template/testdata/complete/communicator.pkr.hcl deleted file mode 120000 index 2a350af04..000000000 --- a/hcl2template/testdata/complete/communicator.pkr.hcl +++ /dev/null @@ -1 +0,0 @@ -../communicator/basic.pkr.hcl \ No newline at end of file diff --git a/hcl2template/testdata/complete/communicator.pkr.hcl b/hcl2template/testdata/complete/communicator.pkr.hcl new file mode 100644 index 000000000..b752333e9 --- /dev/null +++ b/hcl2template/testdata/complete/communicator.pkr.hcl @@ -0,0 +1,27 @@ + +communicator "ssh" "vagrant" { + ssh_password = "s3cr4t" + ssh_username = "vagrant" + ssh_agent_auth = false + ssh_bastion_agent_auth = true + ssh_bastion_host = "" + ssh_bastion_password = "" + ssh_bastion_port = 0 + ssh_bastion_private_key_file = "" + ssh_bastion_username = "" + ssh_clear_authorized_keys = true + ssh_disable_agent_forwarding = true + ssh_file_transfer_method = "scp" + ssh_handshake_attempts = 32 + ssh_host = "sssssh.hashicorp.io" + ssh_port = 42 + ssh_keep_alive_interval = "10s" + ssh_private_key_file = "file.pem" + ssh_proxy_host = "ninja-potatoes.com" + ssh_proxy_password = "pickle-rick" + ssh_proxy_port = "42" + ssh_proxy_username = "dark-father" + ssh_pty = false + ssh_read_write_timeout = "5m" + ssh_timeout = "5m" +} diff --git a/hcl2template/testdata/complete/sources.pkr.hcl b/hcl2template/testdata/complete/sources.pkr.hcl deleted file mode 120000 index 68b98eaa6..000000000 --- a/hcl2template/testdata/complete/sources.pkr.hcl +++ /dev/null @@ -1 +0,0 @@ -../sources/basic.pkr.hcl \ No newline at end of file diff --git a/hcl2template/testdata/complete/sources.pkr.hcl b/hcl2template/testdata/complete/sources.pkr.hcl new file mode 100644 index 000000000..43e3af082 --- /dev/null +++ b/hcl2template/testdata/complete/sources.pkr.hcl @@ -0,0 +1,37 @@ +// a source represents a reusable setting for a system boot/start. +source "virtualbox-iso" "ubuntu-1204" { + iso_url = "http://releases.ubuntu.com/12.04/ubuntu-12.04.5-server-amd64.iso" + iso_checksum = "769474248a3897f4865817446f9a4a53" + iso_checksum_type = "md5" + + boot_wait = "10s" + http_directory = "xxx" + boot_command = ["..."] + + shutdown_command = "echo 'vagrant' | sudo -S shutdown -P now" +} + +source "amazon-ebs" "ubuntu-1604" { + instance_type = "t2.micro" + encrypt_boot = true + region = "eu-west-3" + source_ami_filter { + filters { + virtualization-type = "hvm" + name = "ubuntu/images/*ubuntu-xenial-{16.04}-amd64-server-*" + root-device-type = "ebs" + } + owners = [ + "099720109477" + ] + } +} + +source "amazon-ebs" "that-ubuntu-1.0" { + instance_type = "t2.micro" + encrypt_boot = true + region = "eu-west-3" + source_ami_filter { + most_recent = true + } +} diff --git a/hcl2template/testdata/complete/variables.pkr.hcl b/hcl2template/testdata/complete/variables.pkr.hcl deleted file mode 120000 index c8296b22b..000000000 --- a/hcl2template/testdata/complete/variables.pkr.hcl +++ /dev/null @@ -1 +0,0 @@ -../variables/basic.pkr.hcl \ No newline at end of file diff --git a/hcl2template/testdata/complete/variables.pkr.hcl b/hcl2template/testdata/complete/variables.pkr.hcl new file mode 100644 index 000000000..d4e651247 --- /dev/null +++ b/hcl2template/testdata/complete/variables.pkr.hcl @@ -0,0 +1,6 @@ + +variables { + key = "value" + my_secret = "foo" + image_name = "foo-image-{{user `my_secret`}}" +}