{
  "builders": [
    {
      "access_key": "{{user `aws_access_key`}}",
      "ami_description": "{{user `ami_description`}}",
      "ami_groups": "{{user `ami_groups`}}",
      "ami_name": "capa-ami-{{user `build_name`}}-{{user `kubernetes_semver` | clean_resource_name}}-{{user `build_timestamp`}}",
      "ami_product_codes": "",
      "ami_regions": "{{user `ami_regions`}}",
      "ami_users": "{{user `ami_users`}}",
      "encrypt_boot": "{{user `encrypted`}}",
      "iam_instance_profile": "{{user `iam_instance_profile`}}",
      "instance_type": "{{user `builder_instance_type`}}",
      "kms_key_id": "{{user `kms_key_id`}}",
      "launch_block_device_mappings": [
        {
          "delete_on_termination": true,
          "device_name": "{{ user `root_device_name` }}",
          "iops": "{{ user `iops`}}",
          "throughput": "{{ user `throughput` }}",
          "volume_size": "{{ user `volume_size` }}",
          "volume_type": "{{ user `volume_type` }}"
        }
      ],
      "name": "{{user `build_name`}}",
      "profile": "{{ user `aws_profile`}}",
      "region": "{{ user `aws_region` }}",
      "secret_key": "{{user `aws_secret_key`}}",
      "security_group_ids": "{{user `aws_security_group_ids`}}",
      "skip_create_ami": "{{ user `skip_create_ami`}}",
      "skip_profile_validation": "{{user `skip_profile_validation`}}",
      "snapshot_groups": "{{user `snapshot_groups`}}",
      "snapshot_users": "{{user `snapshot_users`}}",
      "source_ami": "{{user `source_ami`}}",
      "source_ami_filter": {
        "filters": {
          "architecture": "x86_64",
          "name": "{{user `ami_filter_name`}}",
          "root-device-type": "ebs",
          "virtualization-type": "hvm"
        },
        "most_recent": true,
        "owners": "{{user `ami_filter_owners`}}"
      },
      "ssh_keypair_name": "{{user `ssh_keypair_name`}}",
      "ssh_private_key_file": "{{user `ssh_private_key_file`}}",
      "ssh_username": "{{user `ssh_username`}}",
      "subnet_id": "{{ user `subnet_id` }}",
      "tags": {
        "build_date": "{{isotime}}",
        "build_timestamp": "{{user `build_timestamp`}}",
        "containerd_version": "{{user `containerd_version`}}",
        "distribution": "{{user `distribution`}}",
        "distribution_release": "{{user `distribution_release`}}",
        "distribution_version": "{{user `distribution_version`}}",
        "image_builder_version": "{{user `ib_version`}}",
        "kubernetes_cni_version": "{{user `kubernetes_cni_semver`}}",
        "kubernetes_version": "{{user `kubernetes_semver`}}",
        "source_ami": "{{user `source_ami`}}"
      },
      "temporary_security_group_source_cidrs": "{{ user `temporary_security_group_source_cidrs` }}",
      "token": "{{ user `aws_session_token` }}",
      "type": "amazon-ebs",
      "user_data": "{{ user `user_data` }}",
      "vpc_id": "{{ user `vpc_id` }}"
    }
  ],
  "post-processors": [
    {
      "custom_data": {
        "containerd_version": "{{user `containerd_version`}}",
        "kubernetes_cni_version": "{{user `kubernetes_cni_semver`}}",
        "kubernetes_version": "{{user `kubernetes_semver`}}"
      },
      "output": "{{user `manifest_output`}}",
      "type": "manifest"
    }
  ],
  "provisioners": [
    {
      "environment_vars": [
        "BUILD_NAME={{user `build_name`}}"
      ],
      "inline": [
        "if [ $BUILD_NAME != \"ubuntu-1804\" ]; then exit 0; fi",
        "while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done",
        "sudo apt-get -qq update && sudo DEBIAN_FRONTEND=noninteractive apt-get -qqy install python python-pip"
      ],
      "type": "shell"
    },
    {
      "execute_command": "BUILD_NAME={{user `build_name`}}; if [[ \"${BUILD_NAME}\" == *\"flatcar\"* ]]; then sudo {{.Vars}} -S -E bash '{{.Path}}'; fi",
      "script": "./packer/files/flatcar/scripts/bootstrap-flatcar.sh",
      "type": "shell"
    },
    {
      "ansible_env_vars": [
        "ANSIBLE_SSH_ARGS='{{user `existing_ansible_ssh_args`}} {{user `ansible_common_ssh_args`}}'"
      ],
      "extra_arguments": [
        "--extra-vars",
        "{{user `ansible_common_vars`}}",
        "--extra-vars",
        "{{user `ansible_extra_vars`}}",
        "--extra-vars",
        "{{user `ansible_user_vars`}}",
        "--scp-extra-args",
        "{{user `ansible_scp_extra_args`}}"
      ],
      "playbook_file": "./ansible/node.yml",
      "type": "ansible"
    },
    {
      "arch": "{{user `goss_arch`}}",
      "download_path": "{{user `goss_download_path`}}",
      "format": "{{user `goss_format`}}",
      "format_options": "{{user `goss_format_options`}}",
      "goss_file": "{{user `goss_entry_file`}}",
      "inspect": "{{user `goss_inspect_mode`}}",
      "remote_folder": "{{user `goss_remote_folder`}}",
      "remote_path": "{{user `goss_remote_path`}}",
      "skip_install": "{{user `goss_skip_install`}}",
      "tests": [
        "{{user `goss_tests_dir`}}"
      ],
      "type": "goss",
      "url": "{{user `goss_url`}}",
      "use_sudo": true,
      "vars_file": "{{user `goss_vars_file`}}",
      "vars_inline": {
        "ARCH": "amd64",
        "OS": "{{user `distribution` | lower}}",
        "OS_VERSION": "{{user `distribution_version` | lower}}",
        "PROVIDER": "amazon",
        "containerd_version": "{{user `containerd_version`}}",
        "kubernetes_cni_deb_version": "{{ user `kubernetes_cni_deb_version` }}",
        "kubernetes_cni_rpm_version": "{{ split (user `kubernetes_cni_rpm_version`) \"-\" 0 }}",
        "kubernetes_cni_source_type": "{{user `kubernetes_cni_source_type`}}",
        "kubernetes_cni_version": "{{user `kubernetes_cni_semver` | replace \"v\" \"\" 1}}",
        "kubernetes_deb_version": "{{ user `kubernetes_deb_version` }}",
        "kubernetes_rpm_version": "{{ split (user `kubernetes_rpm_version`) \"-\" 0 }}",
        "kubernetes_source_type": "{{user `kubernetes_source_type`}}",
        "kubernetes_version": "{{user `kubernetes_semver` | replace \"v\" \"\" 1}}"
      },
      "version": "{{user `goss_version`}}"
    }
  ],
  "variables": {
    "amazon_ssm_agent_rpm": "https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm",
    "ami_description": "Cluster API base image designed for {{user `kubernetes_semver`}}",
    "ami_groups": "all",
    "ami_regions": "ap-south-1,eu-west-3,eu-west-2,eu-west-1,ap-northeast-2,ap-northeast-1,sa-east-1,ca-central-1,ap-southeast-1,ap-southeast-2,eu-central-1,us-east-1,us-east-2,us-west-1,us-west-2",
    "ami_users": "",
    "ansible_common_vars": "",
    "ansible_extra_vars": "",
    "ansible_scp_extra_args": "",
    "ansible_user_vars": "",
    "aws_access_key": "",
    "aws_profile": "",
    "aws_region": "us-east-1",
    "aws_secret_key": "",
    "aws_security_group_ids": "",
    "aws_session_token": "",
    "build_timestamp": "{{timestamp}}",
    "builder_instance_type": "t3.small",
    "containerd_sha256": null,
    "containerd_url": "https://github.com/containerd/containerd/releases/download/v{{user `containerd_version`}}/cri-containerd-cni-{{user `containerd_version`}}-linux-amd64.tar.gz",
    "containerd_version": null,
    "crictl_url": "https://github.com/kubernetes-sigs/cri-tools/releases/download/v{{user `crictl_version`}}/crictl-v{{user `crictl_version`}}-linux-amd64.tar.gz",
    "crictl_version": null,
    "encrypted": "false",
    "existing_ansible_ssh_args": "{{env `ANSIBLE_SSH_ARGS`}}",
    "iam_instance_profile": "",
    "ib_version": "{{env `IB_VERSION`}}",
    "iops": "3000",
    "kms_key_id": "",
    "kubernetes_cni_deb_version": null,
    "kubernetes_cni_http_source": null,
    "kubernetes_cni_rpm_version": null,
    "kubernetes_cni_semver": null,
    "kubernetes_cni_source_type": null,
    "kubernetes_container_registry": null,
    "kubernetes_deb_gpg_key": null,
    "kubernetes_deb_repo": null,
    "kubernetes_deb_version": null,
    "kubernetes_http_source": null,
    "kubernetes_load_additional_imgs": null,
    "kubernetes_rpm_gpg_check": null,
    "kubernetes_rpm_gpg_key": null,
    "kubernetes_rpm_repo": null,
    "kubernetes_rpm_version": null,
    "kubernetes_semver": null,
    "kubernetes_source_type": null,
    "manifest_output": "manifest.json",
    "python_path": "",
    "skip_create_ami": "false",
    "skip_profile_validation": "false",
    "snapshot_groups": "all",
    "snapshot_users": "",
    "ssh_keypair_name": "",
    "ssh_private_key_file": "",
    "subnet_id": "",
    "temporary_security_group_source_cidrs": "",
    "throughput": "125",
    "user_data": "#cloud-config\nrepo_upgrade: none",
    "volume_size": "8",
    "volume_type": "gp3",
    "vpc_id": ""
  }
}