ws2019.json

{
  "variables": {
    "azure_client_id": "",
    "azure_client_secret": "",
    "azure_location": "",
    "azure_resource_group_name": "",
    "azure_storage_account": "",
    "azure_subscription_id": "",
    "aws_access_key": "",
    "aws_secret_key": "",
    "aws_region": "",
    "gce_account_file": "",
    "gce_zone": "",
    "gce_project": "",
    "gce_source_image": "windows-server-2016-dc-v20190108",
    "gce_source_image_family": "windows-2016",
    "azure_vm_size": "Standard_D4s_v3",

    "install_user": "",
    "install_password": "",
    "build_agent_mode": "",
    "image_description": "",
    "deploy_parts": "",

    "iso_url": "https://software-download.microsoft.com/download/sg/17763.379.190312-0539.rs5_release_svc_refresh_SERVER_EVAL_x64FRE_en-us.iso",
    "iso_checksum": "221F9ACBC727297A56674A0F1722B8AC7B6E840B4E1FFBDD538A9ED0DA823562",
    "iso_checksum_type": "sha256",

    "helper_script_folder": "C:\\Program Files\\WindowsPowerShell\\Modules\\"
  },
  "provisioners": [
    {
        "type": "powershell",
        "scripts": [
            "{{ template_dir }}/scripts/Windows/create_appveyor_user.ps1"
        ],
        "environment_vars": [
            "appveyor_user={{user `install_user`}}",
            "appveyor_password={{user `install_password`}}"
        ]
    },
    {
        "type": "powershell",
        "inline":[
            "Write-Host \"Current user: $(whoami)\""
        ],
        "elevated_user": "{{user `install_user`}}",
        "elevated_password": "{{user `install_password`}}"
    },
    {
        "type": "powershell",
        "scripts":[
            "{{ template_dir }}/scripts/Windows/init_server.ps1"
        ],
        "elevated_user": "{{user `install_user`}}",
        "elevated_password": "{{user `install_password`}}"
    },
    {
        "type": "windows-restart",
        "restart_timeout": "30m"
    },
    {
        "type": "powershell",
        "scripts":[
            "{{ template_dir }}/scripts/Windows/install_path_utils.ps1",
            "{{ template_dir }}/scripts/Windows/install_powershell_core.ps1",
            "{{ template_dir }}/scripts/Windows/install_powershell_get.ps1",
            "{{ template_dir }}/scripts/Windows/install_7zip.ps1",
            "{{ template_dir }}/scripts/Windows/install_chocolatey.ps1",
            "{{ template_dir }}/scripts/Windows/install_webpi.ps1",
            "{{ template_dir }}/scripts/Windows/install_nuget.ps1",
            "{{ template_dir }}/scripts/Windows/install_pstools.ps1"
        ],
        "elevated_user": "{{user `install_user`}}",
        "elevated_password": "{{user `install_password`}}"
    },
    {
        "type": "powershell",
        "scripts":[
            "{{ template_dir }}/scripts/Windows/install_git.ps1",
            "{{ template_dir }}/scripts/Windows/install_git_lfs.ps1",
            "{{ template_dir }}/scripts/Windows/install_mercurial.ps1",
            "{{ template_dir }}/scripts/Windows/install_subversion.ps1",
            "{{ template_dir }}/scripts/Windows/add_ssh_known_hosts.ps1"
        ],
        "elevated_user": "{{user `install_user`}}",
        "elevated_password": "{{user `install_password`}}"
    },
    {
        "type": "powershell",
        "scripts":[
            "{{ template_dir }}/scripts/Windows/install_vs2017.ps1",
            "{{ template_dir }}/scripts/Windows/update_msbuild_path.ps1",
            "{{ template_dir }}/scripts/Windows/install_xunit_20.ps1",
            "{{ template_dir }}/scripts/Windows/install_nunit.ps1",
            "{{ template_dir }}/scripts/Windows/install_nunit3.ps1",
            "{{ template_dir }}/scripts/Windows/install_vstest_console_logger.ps1"
        ],
        "elevated_user": "{{user `install_user`}}",
        "elevated_password": "{{user `install_password`}}"
    },
    {
        "type": "powershell",
        "scripts":[
            "{{ template_dir }}/scripts/Windows/install_nodejs_latest.ps1",
            "{{ template_dir }}/scripts/Windows/install_ruby.ps1",
            "{{ template_dir }}/scripts/Windows/install_miniconda.ps1",
            "{{ template_dir }}/scripts/Windows/install_python.ps1",
            "{{ template_dir }}/scripts/Windows/install_dotnet_sdk.ps1",
            "{{ template_dir }}/scripts/Windows/install_openssl.ps1",
            "{{ template_dir }}/scripts/Windows/install_cmake.ps1",
            "{{ template_dir }}/scripts/Windows/install_postgres96.ps1",
            "{{ template_dir }}/scripts/Windows/install_postgres10.ps1",
            "{{ template_dir }}/scripts/Windows/install_postgres11.ps1",
            "{{ template_dir }}/scripts/Windows/install_aws_cli.ps1",
            "{{ template_dir }}/scripts/Windows/install_erlang.ps1",
            "{{ template_dir }}/scripts/Windows/install_mongo.ps1"
        ],
        "elevated_user": "{{user `install_user`}}",
        "elevated_password": "{{user `install_password`}}"
    },
    {
        "type": "powershell",
        "scripts":[
            "{{ template_dir }}/scripts/Windows/install_sql_server_2017.ps1"
        ],
        "elevated_user": "{{user `install_user`}}",
        "elevated_password": "{{user `install_password`}}"
    },
    {
        "type": "windows-restart",
        "restart_timeout": "30m"
    },
    {
        "type": "powershell",
        "scripts":[
            "{{ template_dir }}/scripts/Windows/sql_server_2017_after_reboot.ps1"
        ],
        "elevated_user": "{{user `install_user`}}",
        "elevated_password": "{{user `install_password`}}"
    },
    {
        "type": "powershell",
        "scripts":[
            "{{ template_dir }}/scripts/Windows/install_appveyor_build_agent.ps1",
            "{{ template_dir }}/scripts/Windows/enable_autologon.ps1"
        ],
        "environment_vars": [
            "appveyor_user={{user `install_user`}}",
            "appveyor_password={{user `install_password`}}",
            "build_agent_mode={{user `build_agent_mode`}}"
        ],
        "elevated_user": "{{user `install_user`}}",
        "elevated_password": "{{user `install_password`}}"
    },
    {
        "type": "powershell",
        "scripts":[
            "{{ template_dir }}/scripts/Windows/install_docker_hyperv_wsl_features.ps1"
        ],
        "elevated_user": "{{user `install_user`}}",
        "elevated_password": "{{user `install_password`}}"
    },
    {
        "type": "windows-restart",
        "restart_timeout": "30m"
    },
    {
        "type": "powershell",
        "scripts":[
            "{{ template_dir }}/scripts/Windows/noop-plug.ps1",
            "{{ template_dir }}/scripts/Windows/install_wsl.ps1"
        ],
        "elevated_user": "{{user `install_user`}}",
        "elevated_password": "{{user `install_password`}}"
    },
    {
        "type": "powershell",
        "scripts":[
            "{{ template_dir }}/scripts/Windows/install_docker_desktop.ps1"
        ],
        "elevated_user": "{{user `install_user`}}",
        "elevated_password": "{{user `install_password`}}"
    },
    {
        "type": "windows-restart",
        "restart_timeout": "70m"
    },
    {
        "type": "powershell",
        "scripts":[
            "{{ template_dir }}/scripts/Windows/wait_docker.ps1"
        ],
        "elevated_user": "{{user `install_user`}}",
        "elevated_password": "{{user `install_password`}}"
    }
  ],
  "builders": [
    {
        "type": "azure-arm",
        "subscription_id": "{{ user `azure_subscription_id` }}",
        "client_id": "{{ user `azure_client_id` }}",
        "client_secret": "{{ user `azure_client_secret` }}",
        "location": "{{ user `azure_location` }}",

        "temp_resource_group_name": "packer-RG-ws2019-{{uuid}}",

        "os_type": "Windows",
        "image_publisher": "MicrosoftWindowsServer",
        "image_offer": "WindowsServer",
        "image_sku": "2019-Datacenter",
        "vm_size": "{{user `azure_vm_size`}}",
        "os_disk_size_gb": 128,

        "capture_container_name": "appveyor-images-ws2019",
        "capture_name_prefix": "ws2019-{{user `datemark`}}",
        "resource_group_name": "{{ user `azure_resource_group_name` }}",
        "storage_account": "{{ user `azure_storage_account` }}",

        "communicator": "winrm",
        "winrm_use_ssl": "true",
        "winrm_insecure": "true",
        "winrm_timeout": "50m",
        "winrm_username": "packer",

        "azure_tags": {
          "automation": "packer",
          "OS": "WindowsServer 2019-Datacenter",
          "description": "{{user `image_description`}}",
          "date": "{{user `datemark`}}"
        }
    },
    {
      "type": "googlecompute",
      "account_file": "{{user `gce_account_file`}}",
      "project_id": "{{ user `gce_project` }}",
      "zone": "{{ user `gce_zone` }}",
      "source_image": "{{ user `gce_source_image` }}",
      "state_timeout" : "15m",
      "scopes": [
          "https://www.googleapis.com/auth/userinfo.email",
          "https://www.googleapis.com/auth/compute",
          "https://www.googleapis.com/auth/devstorage.full_control",
          "https://www.googleapis.com/auth/devstorage.read_only",
          "https://www.googleapis.com/auth/logging.write",
          "https://www.googleapis.com/auth/monitoring.write",
          "https://www.googleapis.com/auth/servicecontrol",
          "https://www.googleapis.com/auth/service.management.readonly",
          "https://www.googleapis.com/auth/trace.append"
        ],
      "machine_type": "n1-standard-2",
      "communicator": "winrm",
      "winrm_username": "packer_user",
      "winrm_insecure": true,
      "winrm_use_ssl": true,
      "instance_name": "packer-vs2017-{{uuid}}",
      "image_name": "packer-vs2017-{{timestamp}}",
      "image_description": "{{ user `image_description` }}",
      "disk_size": 200,
      "metadata": {
        "windows-startup-script-cmd": "winrm quickconfig -quiet & net user /add packer_user & net localgroup administrators packer_user /add & winrm set winrm/config/service/auth @{Basic=\"true\"}"
      }
    },
    {
      "type": "amazon-ebs",
      "access_key": "{{user `aws_access_key`}}",
      "secret_key": "{{user `aws_secret_key`}}",
      "region": "{{user `aws_region`}}",
      "source_ami_filter": {
        "filters": {
        "virtualization-type": "hvm",
        "name": "Windows_Server-1809-English-Core-Containers*",
        "root-device-type": "ebs"
        },
        "owners": ["801119661308"],
        "most_recent": true
      },
      "instance_type": "t2.medium",
      "communicator": "winrm",
      "winrm_username": "Administrator",
      "winrm_use_ssl": true,
      "winrm_insecure": true,
      "ami_name": "Appveyor Worker Windows2019 {{uuid}}",
      "ami_description": "{{user `image_description`}}",
      "launch_block_device_mappings": [
        {
          "device_name": "/dev/sda1",
          "volume_size": 400,
          "volume_type": "gp2",
          "delete_on_termination": true
        }
      ]
    },
    {
      "type": "hyperv-vmcx",
      "clone_from_vm_name": "vs2017_empty",
      "vm_name": "packer-vs2017-{{ user `datemark` }}",
      "winrm_username": "{{ user `appveyor_username` }}",
      "winrm_password": "{{ user `appveyor_password` }}",
      "shutdown_command": "c:\\run-sysprep.cmd",
      "communicator":"winrm",
      "winrm_timeout" : "1h",
      "cpu": "1",
      "ram_size": "3072",
      "generation": 2,
      "enable_secure_boot": "true"
    }
  ]
}